Optimize AWS infrastructure deployment with StratusGrid's CodePipeline IaC Terraform module for efficient automated updates and resource management.
An Easier Way to Do Multi-Region AWS Serverless Framework Deployments
Discover the essentials of optimizing Serverless Framework applications for a global audience with multi-region deployments with StratusGrid’s enhancements.
The need for multi-region deployments
Until recently, deploying your Serverless Framework application in multiple regions was a somewhat difficult process involving a lot of custom CloudFormation. However, StratusGrid recently submitted changes to serverless-domain-manager that make it much simpler.
The following architecture can be created with simple configuration changes:
Why are multi-region deployments important?
Serverless Framework deployments are generally created in a single region in Amazon Web Services (AWS). This may work if you are only targeting a single part of the world, but if your application is intended for a global audience, your response time can be unacceptably long for users who are far away from your deployment region. A multi-region deployment with latency-based routing can reduce response times from multiple seconds to double-digit milliseconds!
Multi-region deployments are also great from a disaster recovery and redundancy perspective. Automated health checks and a failover policy can be configured to achieve an active-active setup that can fail over between regions in the event of any issue.
This is particularly useful for situations such as the us-east-1 outage on December 7, 2021 , where services were unavailable for nearly 8 hours in us-east-1, while other regions remained unaffected.
Lambdas in multi-region deployments
Lambdas are well suited for multi-region deployments because they can easily scale and adapt to varying traffic patterns without incurring unnecessary costs. Operating within the pay-as-you-go model makes them much more economically appealing than other computing options - they can result in wasted and idle resources.
Implementing multi-region deployments with serverless-domain-manager
At StratusGrid, we use the popular (and excellent) plug-in serverless-domain-manager to create the custom domain and Route 53 records. We recently submitted a change to the repository that makes it possible to perform multi-region deployments with minimal configuration changes.
To get started, add the serverless-domain-manager configuration to your `serverless.yaml` file as usual. The only difference is that you now add a `route53Params` structure with a `routingPolicy: latency` property.
Then update your deployment process to deploy to multiple regions:
Check out this github repository for an example of a multi-region project.
We can demonstrate latency reductions by creating a simple lambda from the demo repository and deploying it to a single region. In this case, I deployed it to ap-southeast-1, which is far away from my machine located in the eastern United States. Making 10 requests I get the following total response times in seconds:
Deploying the same project again in us-east-1, I get these response times with the exact same domain:
StratusGrid’s can help with multi-region deployments
Deploying your Serverless Framework applications in multiple regions is a cost-effective and easy way to improve your users’ experience while increasing your application’s resiliency. We encourage you to consider this pattern for all of your Serverless deployments. If you need help, reach out to us today !