• Blog
  • Docs
  • Careers
  • Get Support
  • Contact Sales
DigitalOcean
  • Browse all products

    Featured AI Products

    Managed Agents

    Run AI agents in the cloud with governed tool access

    New

    Learning Services

    Improve agents and models with evidence

    New

    Data Services

    Store, retrieve, and surface the context you need

    Inference Engine

    Run inference at scale with policy-driven routing

    Model Library

    Discover, compare, and evaluate AI models

    GPU Droplets

    GPU-powered virtual machines to build and run AI apps

    Browse all products
  • See all solutions

    AI/ML

    AI HR Knowledge Assistant

    Deploy AI tools developed for Human Resources

    AI Training GPU

    Accelerate model training with dedicated GPU infrastructure

    AI Recommendation Engine

    Build tools to personalize user experiences

    Multimodal AI

    Run models that process multiple data types

    GPU Clusters

    GPUs clustered together for large-scale tasks

    GPU Inference

    Serve models efficiently with optimized GPU compute

  • Community

    Blog

    The latest product releases and insights from our experts

    The Wave

    Content to level up your business

    Tutorials

    Our extensive library of technical articles

    Q&A

    Answers to your cloud and coding questions

    YouTube

    Educational content and tutorials

    Visit DigitalOcean's Community Site
  • Become a Partner

    About Partner Pod

    Discounts, revenue share, and more for businesses

    AI Partner Program

    Boost your AI business

    DigitalOcean Startups

    Resources and support to propel your startup

    Partners Directory

    Current list of DigitalOcean Partners

    Customer Stories

    Customers growing on DigitalOcean

    Need help? Talk to an expert
    Become a Partner
  • Pricing
  • Log in
  • Sign up
  • Log in
  • Sign up

Company

AboutLeadershipBlogCareersCustomersPartnersReferral ProgramAffiliate ProgramPressLegalPrivacy PolicySecurityBrandInvestor Relations

Products

Managed AgentsKnowledge BasesGPU DropletsBare Metal GPUsInference EngineData ServicesLearning ServicesInsightsEvaluationsModel LibraryMicroVMsDropletsKubernetesFunctionsApp PlatformLoad BalancersManaged DatabasesSpacesBlock StorageNetwork File StorageAPIUptimeSecrets ManagerCloud Security Posture Management (CSPM)Identity and Access Management (IAM)CloudwaysView all Products

Resources

Community TutorialsCommunity Q&AWrite for DOnationsCurrents ResearchDigitalOcean StartupsWavemakers ProgramCompass CouncilOpen SourceNewsletter SignupMarketplacePricingPricing CalculatorDocumentationRelease NotesCode of ConductShop Swag

Solutions

AI Training GPUGPU InferenceVPS HostingWebsite HostingVPNDocker HostingNode.js HostingWeb Mobile AppsWordPress HostingVirtual MachinesView all Solutions

Contact

SupportSalesReport AbuseSystem StatusShare your ideas
AboutLeadershipBlogCareersCustomersPartnersReferral ProgramAffiliate ProgramPressLegalPrivacy PolicySecurityBrandInvestor Relations
Managed AgentsKnowledge BasesGPU DropletsBare Metal GPUsInference EngineData ServicesLearning ServicesInsightsEvaluationsModel LibraryMicroVMsDropletsKubernetesFunctionsApp PlatformLoad BalancersManaged DatabasesSpacesBlock StorageNetwork File StorageAPIUptimeSecrets ManagerCloud Security Posture Management (CSPM)Identity and Access Management (IAM)CloudwaysView all Products
Community TutorialsCommunity Q&AWrite for DOnationsCurrents ResearchDigitalOcean StartupsWavemakers ProgramCompass CouncilOpen SourceNewsletter SignupMarketplacePricingPricing CalculatorDocumentationRelease NotesCode of ConductShop Swag
AI Training GPUGPU InferenceVPS HostingWebsite HostingVPNDocker HostingNode.js HostingWeb Mobile AppsWordPress HostingVirtual MachinesView all Solutions
SupportSalesReport AbuseSystem StatusShare your ideas

© 2026 DigitalOcean, LLC.

Sitemap
Cloud education

Best Practices for Serverless

author

By Brittany King

  • Published: May 9, 2022
  • 3 min read
<- Back to blog home

Function as a Service (FaaS) is the subset of serverless computing that’s focused on event-driven triggers where code runs in response to events or requests. Reports and Data predicts that Function as a Service (FaaS) will reach around $53 billion by 2028. As the adoption of FaaS continues to increase, it’s important to consider the best approach for implementing these serverless solutions. 

The basics of FaaS

A FaaS solution allows developers to write and deploy code without worrying about servers or other infrastructure management. FaaS solutions differ from Platform as a Service (PaaS) solutions because the functions are completely event-driven and stateless. Developers using functions tend to write less code because there’s less to manage on their own. Functions can easily scale horizontally to meet demand, simply duplicating the function to perform the same task for each request. When the demand drops, the functions automatically scale back down as they are no longer needed. 

FaaS thrives on simple and repetitive functions without consistent workloads or continuously high volumes of requests. Adding a FaaS component to an existing architecture to handle event-driven functions can save significant resources and reduce costs. By combining long-running servers with on-demand reactive functions, developers can use the speed and agility of simply writing functions to extend existing applications with serverless functionality. 

Best practices for using FaaS

Developers who choose to use FaaS can take advantage of its fast time to market due to the ease of development and testing it provides. Since they no longer need to worry about things like capacity planning or ongoing maintenance, they can focus solely on coding and development for the application. Simply put: developers can do less to get their cloud applications running. While FaaS is a great solution, it may not be the best choice in every scenario, and there are key practices that developers must follow to get the best results. To use FaaS appropriately, make sure that each event triggers only one function, that the functions are short-lived, and that they are stateless. 

One event, one task

To keep FaaS solutions simple and working well, it’s important that each event only triggers one function. For instance, a function should be responsible for a singular task like getting a list of records from an external API or geolocating a request. Although it can be done, it’s best to avoid having one function call another function. Keep your code short and lightweight to optimize the performance of FaaS. By narrowing the scope of each function, it starts faster, it’s easier to test, and it has a smaller attach surface. It also allows secrets needed by functions to be scoped to just the ones that need them instead of all functions. 

Keep functions short-lived

There are typically timeouts for function executions and the amount of time varies based on your provider. It’s important to keep functions short-lived, as they’re intended to execute efficiently and then power down to open up more compute capacity.

Remember functions are stateless

Stateless functions are simpler. Their components are easier to implement and provide the predictability that makes testing and deploying to production simpler. If functions do need persistent data, that information can be stored in a database so that it can be pulled again from the database in subsequent requests.

Test and configure

Test your functions to find the optimal duration/memory needs. Keep dependencies to a minimum and internalize dependencies outside of the entry point. It’s important to be able to test functions locally using your favorite IDE, test frameworks, and tools. Writing functions and testing them locally enables a fast inner loop—a short edit, test, and debug cycle.

Keep your functions secure

Keep secrets out of source. Additionally, developers may be tempted to use a single permission model for all functions, granting functions access to components of the application not necessary for it to perform its task. Consider giving each function permission to only access what is necessary for it to execute its task to avoid major catastrophe in the event of a security breach. 

Future-proof your setup

Create your functions outside of an app for an easier migration or so that you can more easily refactor a monolithic application if needed. Remember, some architectures are a more natural fit for microservices than others, so if your application logic contains multiple sequential steps that all depend on one another, abstracting each of them into individual microservices may not be the best solution.

Connect with us

DigitalOcean acquired Nimbella to offer a simple and robust serverless solution for builders. Interested in exploring serverless? Learn more about DigitalOcean’s upcoming serverless offering.

About the author

Brittany King
Brittany King
Author

Share

  • Cloud Education

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.
Sign up

Related Articles

Introducing langchain-gradient: Seamless LangChain Integration with DigitalOcean
Cloud education

Introducing langchain-gradient: Seamless LangChain Integration with DigitalOcean

Narasimha Badrinath

  • August 19, 2025
  • 2 min read

Read more

Agentic Cloud: Reinventing the Cloud with AI Agents
Cloud education

Agentic Cloud: Reinventing the Cloud with AI Agents

Bratin Saha, Chief Product & Technology Officer

  • May 19, 2025
  • 5 min read

Read more

How to optimize your cloud architecture for business growth
Cloud education

How to optimize your cloud architecture for business growth

Anantha Ramachandran
  • May 9, 2025
  • 5 min read

Read more