Melpomene - Fotolia
Serverless computing platforms, such as AWS Lambda, Azure Functions and Google Cloud Functions, provide new opportunities to deploy cloud apps efficiently and quickly. For these cloud apps to reach their fullest potential, enterprises need to optimize serverless function performance.
Serverless functions enable rapid deployment of code, which runs on demand and has access to virtually unlimited amounts of compute resources. However, serverless environments don't automatically improve function code or deployment configuration.
Implement the following five strategies to ensure high levels of serverless function performance.
1. Minimize dependencies
Enterprises should avoid unnecessary dependencies to improve all app performance, not just serverless apps. Unneeded dependencies -- such as generic libraries -- can significantly delay deployment time, so strip them out to improve serverless performance.
Write functions to include only the required modules for the application. A highly modular language, such as Python, can help developers achieve this goal.
2. Maintain environment data between sessions
Another way to reduce serverless deployment time is to keep as much data as possible alive between function sessions.
When the serverless function executes, it's generally beneficial to keep environment data in local storage, as well as keep any network connections that the function uses open. It ensures that, when it executes again, the function won't have to recreate environment data and connections from scratch. This practice shortens deployment time.
3. Increase memory allocation
Serverless function types are not all created equal -- some might benefit from more memory than others.
Serverless platforms don't always make it clear that, when you increase memory allocation, you also create more CPU resources for the serverless functions. So, when you add memory, you also add compute, and more compute almost always leads to better performance.
However, increased serverless memory allocation will also increase the costs. If the budget allows for it, more memory is an easy way to improve serverless function performance.
If you have a multi-cloud model, design serverless functions in ways that maximize their portability between serverless platforms. Make sure that the programming languages used for the functions are supported by multiple platforms and that they are not dependent on one vendor's cloud services -- unless you can easily change those dependencies when you move the functions to a different cloud platform.
4. Make functions' code short
When it comes to serverless, smaller is better. Unnecessary code can bloat a function with logic and increase the amount of data that the function needs to load before deployment. From a code perspective, developers should write functions that are as short and sweet as possible.
The ultimate goal is to write a function with as few lines of code as possible and have it still provide the required outcome.
5. Shop around for a different serverless provider
All of the major cloud computing providers, such as AWS, Microsoft and Google, have a flavor of serverless. But this does not mean that a given cloud app's performance on all serverless platforms stays the same. For example, users might find a function runs faster on Azure Functions than on AWS Lambda, or vice versa.
If you're unhappy with current serverless function performance or want to optimize it, test the function on multiple public clouds, and measure performance levels.