Optimising application costs for a serverless architecture

A serverless architecture example with AWS Lambda - DigitalCloudAdvisor

When implemented correctly, a Well-Architected cloud solution can lead to immediate cost savings on monthly bills and long-term savings through better practices within your company. AWS offers a wide range of services for monitoring, compliance, security, pay-as-you-go computing, orchestration, and automation, allowing businesses of any size to optimize their costs and increase profits.

The serverless platform, which eliminates the need to manage the underlying infrastructure, amplifies these benefits by reducing both operational costs and time to market, leading to even lower overall costs.

In this article, we will see how DigitalCloudAdvisor operates granularly with every component of your architecture to achieve the most cost-effective configuration.

Let’s start with a simple front-end application that interacts with several back-end applications using one of the serverless platform’s core services.

AWS Lambda

Our team at DigitalCloudAdvisor utilizes the AWS Well-Architected Tool and the Serverless Lens to recommend best practices for each component of a customer’s solution. We aim to design, implement and optimise your application to maximize value.

In a serverless architecture, resource allocation is simpler compared to traditional architectures. The pay-per-value pricing model and scaling based on demand significantly reduce planning efforts. However, configuration options can still be utilized to further reduce costs.


AWS Lambda functions are billed based on the number of requests and execution duration. We can assist customers in monitoring the initialization time of their application code through AWS CloudWatch logs, which can lead to identifying opportunities for improving the overall execution time and maximizing value.

Also, using the Time To Leave (TTL) mechanism within the function handler code will prevent additional external calls and additional execution time.

Additionally, ensuring that the Lambda function only has access to the resources it needs when interacting with other services, such as Amazon S3 and Amazon DynamoDB, and regularly reviewing its usage pattern can help minimize costs associated with the services.

On the monitoring side, we can help customers review their logging level and ensure that logging output and retention are set appropriately for their operational needs. This will prevent unnecessary logging and data retention, which can result in extra costs. We aim to guarantee minimum log retention for investigating operational and performance inquiries when necessary.

Capturing and emitting business and operational events is also important for understanding functions, integration, and interactions, which can help optimize costs.


The memory capacity unit controls the performance and cost of a Lambda function, and it can be configured to range from 128MB to 10,240MB. The amount of memory also determines the amount of virtual CPU available for the function. Through benchmarking with different amounts of memory, we can determine if adding more memory and a proportional CPU can lower the duration and reduce the cost of each invocation.

Our team can automate the memory testing using tools like AWS Lambda Power Tuning and balance the performance and cost of the Lambda functions in your serverless architecture.

Avoid waiting

Avoid scenarios where Lambda functions wait for external activities to complete. Long polling or waiting can increase costs and reduce the function’s overall account concurrency.

Other services like AWS Step Functions help reduce code and coordinate asynchronous workloads. Step Functions orchestrate the booking microservice in the solution above: the state machine handles all the necessary steps to create bookings, including payment.

Compared to Amazon SQS, AWS Step Functions can be more cost-effective when orchestrating a series of AWS Lambda functions or other AWS services to complete a workflow. With Step Functions, you pay only for the number of state transitions, which can be more cost-effective than paying for individual requests to SQS. Additionally, AWS Step Functions allow for easy tracking and visualization of workflows, simplifying identifying and troubleshooting issues and resulting in cost savings on development and troubleshooting.

To sum up, cost optimization on AWS is closely tied to utilizing the vast array of monitoring services available. Our DigitalCloudAdvisor team can help you closely monitor your infrastructure and analyze its behaviour to identify opportunities for further cost optimization. We can also work with you to implement the most effective strategies to maximize the value of your application and minimize costs.


Please check the following links for more information about the AWS services mentioned in the article above:

AWS Well-Architected Tool

AWS Lambda

Amazon S3

Amazon DynamoDB

AWS Step Functions

Amazon SNS

Amazon SQS

Amazon CloudWatch

Article wrriten by:

Empowering Autism: A Unique Solution on AWS

Empowering Autism: An Innovative Solution on AWS

Autism Spectrum Disorder (ASD) is a complex neurodevelopmental condition that affects individuals in myriad ways, offering a distinctive lens[…]

Empowering ADHD people - A Smart AWS Communication Architecture

Empowering ADHD Users with AI: A Smart Architecture for Seamless Communication

Imagine a person with ADHD telling a story, constantly interrupted by their thoughts, struggling to concentrate and stay on[…]

Terraform as Code AWS DigitalCloudAdvisor

Leveraging Terraform for Infrastructure as Code: A Case Study

At DigitalCloudAdvisor, we harness the power of Terraform, an open-source infrastructure as code (IaC) tool, to assist our clients[…]