Let's segue straight into the next benefit: when the batch processing jobs from the preceding example have completed, there is no extra compute cost. With a server, you always pay for when it is running, but with AWS Lambda, you only pay for the amount of time the code is executing. The pricing model is actually a little more complex than that. Let's explore this further. With each Lambda function, you are charged per-request based on a combination of the following:
- How long the function executes (rounded up to the nearest 100 ms)
- The allocated memory that the function was configured with
AWS calls this combination gigabyte-seconds or GB-sec. You can find a pricing table showing the cost per 100 ms of execution here: https://aws.amazon.com/lambda/pricing/. Remember that there is still a storage charge to host the deployment artifacts in S3, as well as data charges for network ingress and egress.