Originally published on the Cloud ex Machina engineering blog .
Every night, an AWS Lambda function works through about 34,000 queued messages, with a reserved concurrency of 100 copies. Whether 40 copies ran or 100, the batch finished a median of 4.7 runs per second, because the database behind it was saturated. The extra copies waited their turn, and serverless functions bill for the time they run, waiting included. Each run took 17 seconds instead of 2, the batch finished at the same time, and the function paid for the difference. The code and its tests had no way to show it. The fix is one number in the deploy configuration, a two-character change worth about $2,200 a year. This is the second post of Feedback loops from the FinOps trenches , after a streaming pipeline that turned a data lake bill into an API bill .
Throughput shows the ceiling
Run time is the first thing anyone sees in this function's metrics. When few copies run, the median run takes 2.1 seconds, and when about 100 run, it takes 17.…