Performance talks about what you get per unit of a resource. Time, effort, space, energy, and money.
How much of X does it take to get N results?
We've touched on performance before. Mentioned scaling strategies in Pros and Cons of Serverless and Databases, talked about complexity in Lambda Pipelines, and mentioned flow in Robust Backend Design.
But what do you measure? What's achievable? Where do you optimize? How does serverless stack up?
The performance trifecta
Software systems care about time, money, and space. You have to balance all 3.
With metered pricing, serverless lets you pay directly for execution time, memory size, and storage space. No overhead. You don't use it, you don't pay it.
AWS Lambda charges for execution time with millisecond precision.
Faster code uses more memory to gain speed. Or you can beef up CPU. Both make your code more expensive to run.
Saving storage space costs CPU time to compress and clean data. Storage is cheap. Bandwidth to and from storage gets pricey.
You optimize memory with slower code. Memory is plentiful these days, but not in serverless. You want small functions.
Every optimization takes human time and effort. A metric that software organizations care about. How hard is the code to develop and maintain?
You can think of performance as a 4-dimensional optimization function. Speed vs. space vs. money vs. effort. Great question for a calculus exam.
Avoid doing the calculus with ye olde law of prioritization:
- Make it work
- Make it right
- Make it fast
You'll find that computers are fast & cheap and humans are slow & expensive. Stick to 1, add 2 for easier maintenance. 3 when necessary.
Where size matters
Bandwidth is where size gets you. AWS charges for taking data out of the system. Other providers are similar.
You pay to send data to users or between availability zones. Details depend on which services are involved. For example: S3 to CloudFront (the CDN) is free, then CloudFront charges $0.085/GB.
Minimize what you send over the wire.
Thinking about speed
2 metrics matter for "speed":
Best summarized with a metaphor from Andrew S. Tanenbaum:
Never underestimate the bandwidth of a station wagon full of tapes hurtling down the highway