|
Explanation of what a cold start is and how we can minimize cold start times when using it. sed Serverless Cold Start to Make Serverless Cold Starts 2x Faster. A slow cold start can give users a very bad experience and ultimately degrade their experience with the product. This is the problem. In addition to the cold start problem, the performance of the actual handler function is also very important. Serverless applications typically consist of many small independent functions that interact with each other through protocols such as event bus queues. The intercommunication between various functions creates a dependency chain for each request. If one of the functions is very slow it will affect the rest of the chain. So handler performance is the issue. Best practices for performance optimization come after we.
Spent several months digging into serverless environments and optimizing how we behave in them. Along the way we've discovered a number of best practices that you can adopt in your own applic photo editing servies ations to maintain the highest possible performance. For example you might do something like this in a serverless function. The handler function above calculates the th number in the Fibonacci sequence. After the calculation is complete your function will continue processing the request and eventually return a response. Moving it outside of the handler allows the calculation to be done when the environment has more resources available and makes it only run once instead of on every call. The updated code looks like below. Another thing to keep in mind is the support for top level await which allows you to run async code outside of handlers.

We've found that running a function explicitly outside of a handler can have a positive impact on the function's performance. Keep your functions as simple as possible. Serverless functions are very small, isolated pieces of code. If your function and dependency tree are large and complex or spread across many files you may find that the runtime takes longer to read and interpret it. Here are some things you can do to improve startup performance: Include only the code your function actually needs to do its job Don't use libraries and frameworks that load a lot of stuff you don't need The processing speed is faster. Don't do more work than needed. Any value calculations or expensive operations that may be reused each time the function is called should be.
|
|