Use queues to buffer requests and smooth workloads – Sustainability in Serverless

Amazon DynamoDB pricing AWS Certification Exam Microsoft Exams Serverless Cost Estimation

Use queues to buffer requests and smooth workloads

If your application experiences unpredictable traffic spikes, planning and provision‐ ing the required extra resources can be challenging. For example, if you set the Lambda provisioned concurrency level too high, you’ll end up wasting resources and incurring unnecessary costs. In such situations, you must identify and separate synchronous and asynchronous operations.

To deal with a spike in an asynchronous operation, you can buffer the extra requests into an SQS queue or Kinesis data stream and process them with the resources already provisioned without demanding more from AWS. As AWS optimizes the use of resources in a sustainable way, you are making your workload promote the sustainability of the cloud.

Employ throttling with usage quotas to control traffic flow

In a synchronous request flow scenario, you can control the handling of unexpected spikes by configuring the request quota and throttling limits to maintain a steady rate of request flow.

With Amazon API Gateway, you can configure usage plans and quotas for each API consumer. In addition to the sustainability benefits, this protects your application from DoS attacks.

Before you set a throttling limit on an API, ensure the API clients can resubmit the throttled requests to prevent losing critical data. Alternatively, you can buffer the API requests into a queue and process them steadily.

Delete unused services and resources

There are two main reasons why neglect of unused resources is common. First, as many managed services are pay-per-use and cost you nothing when idle, you do not see them impacting your monthly cloud bill. The second reason is the speed of high-performing teams. As teams keep delivering new features, they don’t set aside time to audit their serverless stack and cloud resources and weed out resources that are no longer needed.

You may have more abandoned resources in your non-production environment than in your production environment. Say you have a DynamoDB table created for a PoC. As the table contains no data and is unused, it costs you nothing. However, the DynamoDB service still maintains the details of your table and the disk space. Multiply that by millions of such abandoned tables across different AWS Regions, and you can gauge the scale and sustainability impact.

The use of serverless services such as Lambda functions makes your non-production environments more sustainable when compared to running containers. These envi‐ ronments are mostly active only during the engineers’ working hours.

Leave a Reply

Your email address will not be published. Required fields are marked *