4 ms·
EC2 instance costs the same whether I use its RAM or not (these resources are sold as spot instances). I pay for Lambda only when it executes and only exactly f
by emteycz 5y ago
EC2 instance costs the same whether I use its RAM or not (these resources are sold as spot instances). I pay for Lambda only when it executes and only exactly for what I used.
- mushyhammer 5y agoSometimes that works out in your favor, others it doesn’t. Lambda minutes are far more expensive than EC2’s
- drunkpotato 5y agoWhile true, it's not the whole story. lambda is also approximately 1000x more expensive than EC2. So if your lambda is only running 0.1% of the time or less (12 seconds per every 3 hours 20 minutes) you break even. If it runs more than that, lambda is more expensive. This is just price comparison. There are other reasons, convenience, visibility, integration with other services, to choose lambda sometimes and EC2 other times. It's important to profile and know what your use case is!
- vlovich123 5y agoSource on the price comparison? Or did you mean that Lambda is 1000x cheaper than EC2 [1][2]? It's obviously load dependent but functions-style code is going to typically be cheaper than even the smallest EC2 instance while handling more load (provided your RAM/CPU usage fits within the envelope it's optimized around). Disclaimer: I work at Cloudflare on R2 and Workers is even cheaper than Lambda@Edge (provided your workload fits within the compute envelope). Billing is based on CPU time not wall time [3]. Workers Bundled pricing can be more cost effective in some cases if you only need <= 50ms of compute. [1] https://lumigo.io/blog/aws-lambda-vs-ec2/ https://lumigo.io/blog/aws-lambda-vs-ec2/ [2] https://www.trek10.com/blog/lambda-cost https://www.trek10.com/blog/lambda-cost [3] https://blog.cloudflare.com/introducing-workers-unbound/ https://blog.cloudflare.com/introducing-workers-unbound/