• Blog
  • Docs
  • Careers
  • Get Support
  • Contact Sales
DigitalOcean
  • Featured AI Products

    Compute

    Build, deploy, and scale cloud compute resources

    Containers and Images

    Safely store and manage containers and backups

    Managed Databases

    Fully managed resources running popular database engines

    Management and Dev Tools

    Control infrastructure and gather insights

    Networking

    Secure and control traffic to apps

    Security

    Help protect your account and resources with these security features

    Storage

    Store and access any amount of data reliably in the cloud

    Browse all products

  • AI/ML

    CMS

    Data and IoT

    Developer Tools

    Gaming and Media

    Hosting

    Security and Networking

    Startups and SMBs

    Web and App Platforms

    See all solutions

  • Community

    Documentation

    Developer Tools

    Get Involved

    Utilities and Help

  • Become a Partner

    Marketplace

  • Pricing
  • Log in
  • Sign up
  • Log in
  • Sign up

Company

  • About
  • Leadership
  • Blog
  • Careers
  • Customers
  • Partners
  • Referral Program
  • Affiliate Program
  • Press
  • Legal
  • Privacy Policy
  • Security
  • Investor Relations

Products

  • Knowledge Bases
  • GPU Droplets
  • Bare Metal GPUs
  • Inference Engine
  • Data & Learning
  • Evaluations
  • Model Library
  • Droplets
  • Kubernetes
  • Functions
  • App Platform
  • Load Balancers
  • Managed Databases
  • Spaces
  • Block Storage
  • Network File Storage
  • API
  • Uptime
  • Cloud Security Posture Management (CSPM)
  • Identity and Access Management (IAM)
  • Cloudways
  • View all Products

Resources

  • Community Tutorials
  • Community Q&A
  • CSS-Tricks
  • Write for DOnations
  • Currents Research
  • DigitalOcean Startups
  • Wavemakers Program
  • Compass Council
  • Open Source
  • Newsletter Signup
  • Marketplace
  • Pricing
  • Pricing Calculator
  • Documentation
  • Release Notes
  • Code of Conduct
  • Shop Swag

Solutions

  • AI Training GPU
  • GPU Inference
  • VPS Hosting
  • Website Hosting
  • VPN
  • Docker Hosting
  • Node.js Hosting
  • Web Mobile Apps
  • WordPress Hosting
  • Virtual Machines
  • View all Solutions

Contact

  • Support
  • Sales
  • Report Abuse
  • System Status
  • Share your ideas

Company

  • About
  • Leadership
  • Blog
  • Careers
  • Customers
  • Partners
  • Referral Program
  • Affiliate Program
  • Press
  • Legal
  • Privacy Policy
  • Security
  • Investor Relations

Products

  • Knowledge Bases
  • GPU Droplets
  • Bare Metal GPUs
  • Inference Engine
  • Data & Learning
  • Evaluations
  • Model Library
  • Droplets
  • Kubernetes
  • Functions
  • App Platform
  • Load Balancers
  • Managed Databases
  • Spaces
  • Block Storage
  • Network File Storage
  • API
  • Uptime
  • Cloud Security Posture Management (CSPM)
  • Identity and Access Management (IAM)
  • Cloudways
  • View all Products

Resources

  • Community Tutorials
  • Community Q&A
  • CSS-Tricks
  • Write for DOnations
  • Currents Research
  • DigitalOcean Startups
  • Wavemakers Program
  • Compass Council
  • Open Source
  • Newsletter Signup
  • Marketplace
  • Pricing
  • Pricing Calculator
  • Documentation
  • Release Notes
  • Code of Conduct
  • Shop Swag

Solutions

  • AI Training GPU
  • GPU Inference
  • VPS Hosting
  • Website Hosting
  • VPN
  • Docker Hosting
  • Node.js Hosting
  • Web Mobile Apps
  • WordPress Hosting
  • Virtual Machines
  • View all Solutions

Contact

  • Support
  • Sales
  • Report Abuse
  • System Status
  • Share 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 Gradient™ AI Platform
Cloud education

Introducing langchain-gradient: Seamless LangChain Integration with DigitalOcean Gradient™ AI Platform

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