š¤ Serverless services like AWS Lambda, DynamoDB, and SQS are often praised for being cost-effective ā you pay only for what you use, and thereās no infrastructure to manage. But in practice, Iāve seen teams misuse these tools and end up surprised by unexpectedly high bills. Letās walk through common mistakes Iāve seen on projects I worked with, and how to avoid them.
ā Choosing Serverless when it doesnāt fit
It can be the case that you shouldnāt choose Serverless in the first place. Serverless can become expensive ā especially under high-throughput workloads with frequent invocations. Itās ideal for bursty, spiky, or event-driven traffic ā but for constant high-volume systems, it may not be the best fit.
Letās imagine workload where Lambda function polls messages from SQS queue. It reads the message, do some simple transformations and writes data to a DynamoDB table.
Even modest SQS throughput becomes expensive at scale ā and combined with Lambda and DynamoDB, the bill can reach thousands per month. Thatās why you should be really careful while choosing serverless for high-throughput workloads.
ā Tip: If you use ECS for such workloads, your cost may drop by 70ā80%, depending on configuration.
ā Over-provisioning
Over-provisioning happens when you assign more resources than needed, not because the system demands it ā but because defaults werenāt evaluated. This can silently increase cost across your entire architecture.
Let's imagine you have 100 DynamoDB tables and prefer to use provisioned capacity. In practice each workload has approximately 1 read and 1 write per minute.
The same applies to other Serverless services as well, in majority of them you are responsible for resources configuration and therefore should be careful with over provisioning.
ā Excessive logging
CloudWatch logging seems cheap until you scale. Logging at DEBUG level for every request, across dozens of services, can balloon your bill ā and you may not even notice it.
Imagine a microservices application hosted as 25 ECS containers, each generating 2KB/sec, because you set logging on DEBUG
level. Your services are working 24/7, so logs are generated all the time.
Monthly cost = 2KB/sec Ć 3600 sec Ć 720 hours Ć 25 tasks Ć $0.50 per GB = $64.80
Now scale that across environments and services ā it adds up quickly.
ā Tip: Use INFO or WARN in production, and set log retention policies to auto-delete old logs.
ā Synchronous invocation
Serverless isnāt free when you're paying for idle time. A common mistake I see is using Lambda functions that wait synchronously for other operations to complete ā sometimes for several seconds or even minutes. It waits for other Lambda function, or for some other service to complete.
Letās imagine one Lambda function calls another and waits for it to complete. It takes 5 seconds to respond and there are 10ā000 requests per hour.
Monthly cost = (10ā000 req/hr Ć 5 sec Ć 512MB / 1024) Ć 720 hrs Ć $0.00001667 ā $307
ā Tip: Use asynchronous patterns with SQS, SNS, or Step Functions to break dependencies and avoid paying for idle time.
Thank you for reading, letās chat š¬
š¬ Would you be interested in a post about when to choose serverless?
š¬ Do you use synchronous invocations in your workloads?
š¬ Do you use provisioned capacity for DynamoDB tables?
I love hearing from readers š«¶š» Please feel free to drop comments, questions, and opinions belowšš»
Some good advice Anna!