AWS Pricing Lambda: How Much Does It Cost To Run An Application Without A Server?
Software architecture design on an abstraction like containers, orchestration, and more recently serverless increases development velocity and reduces complexity and cost. But the cost of running an application depends upon many factors such as the choice of database, application adoption, hosting, etc.
So the complexity of the cost of an application indicates that the organization cannot rely on its development teams for making the decision and requires a hands-on decision-maker. So even though AWSlambda pricing is pretty straightforward, the cost of running a serverless application is very complex and incorporates many challenges.
AWS Lambda pricing: An Overview
AWS Lambda is a classic example of a series of cloud technology products usually known as serverless or function as a service. AWS Lambda is a code that runs in a temporary container to determine after serving its purpose, namely single invocation tasks—based upon these invocations, and you will be paying only for what you are using. Let's elaborate on the general pricing model:
Memory size (GB)
It is the maximum memory size configuration you can Locate from the AWS to your function from the console. It isn't the actual memory used by the process. It indicates that even if you reduce your function memory usage, you shouldn't tweak this configuration.
Execution time (ms)
It is the time a function takes for executing its code logic. So, for example, if a process is making an outgoing call and waiting until the response comes, the time spent idle will also be counted in the function’s execution time. Therefore, the overall duration of executive functions will be calculated from when code begins executing until it returns forgotten terminated rounded up to the nearest 100ms.
Lambda pricing vs. EC2
We can now compare the charges between AWS Lambda and EC2 for two different use cases:
Low compute use case
The following situation for our application is considered in low calculations. For example, CRON scheduling works can be uploaded, read/write to DynamoDB, serverless authentication.
- Allocated memory: 512 MB
- No. of invocations: 20,000 times/month
- Execution duration: 1 sec
AWS Lambda Pricing Calculator
- GB-sec = 20,000 * 512/1024 = 10,000 GB-sec
- Compute charges = 10,000 * $0.00001667 = $0.1667
- Request charges = (20,000/1,000,000) * $0.2/Million = $0.004
- Total charges = $0.1667 + $0.004 = $0.1707
EC2 Pricing Calculation
The monthly cost would be 5,832 USD even if we choose the lowest on-demand instance available.
High compute use case
The following scenario for our application is considered for heavy computer uses such as ETL operations, real-time data processing, and video processing:
- Allocated memory: 2496 MB
- No. of invocations: 30,000,000 times/month
- Execution duration: 500 sec
AWS Lambda Pricing Calculator
- GB-sec = 30,000,000 * 0.5s * 2496/1024 = 36,562,500 GB-sec
- Compute charges = 36,562,500 * $0.00001667 = $609.5\sRequest charges = (30,000,000/1,000,000) * $0.2/Million = $6
- Total charges = $609.5 + $6 = $615.5
EC2 Pricing Calculation
Considering that this is a high-tech calculation, the monthly costs would be $138,2424, although we use m4.large with 8 GB of memory.
- On-demand instances aren’t a suitable option. Lambda is meant to perform tasks quickly after the events are triggered. You have to spin the container manually each time a function is called to gain the advantages of the EC2 instances on-demand.
Sadly, it would add a considerable amount of overhead processing and slow down. To use EC2, you need to have your instance in place and wait for the triggering event, which requires 100% instance utilization every month. It will add a substantial expense.
- Your functions won't be 100% functional, and that's a backbone underlying the price model of Lambda. However, Lambda works best at and below 3 million procedures a month (source) since you would like to work in the range where free executions with Lambda are still significantly impacted by your project.
- AWS Lambda and EC2 have significantly distinct consequences if we look entirely from the perspective of users. AWS Lambda is great for low-level usage cases like serverless authentication, scheduled CRON jobs, chatbots, Alexa skills, and more, as stated in the preceding paragraph.
Amazon API gateway pricing
You only charge Amazon API Gateway for APIs that are not used for upfront fees. However, the number of API requests you receive and the quantity of data sent and cached is paid for (if opted). Here is how:
- API Call Charges: $3.50 per million received API calls.
- Data transfer fee: 1 GB free first and $0.09/GB for an additional 9.99 TB.
For example, 5 million API calls were received a month in a regional API, and 3 KB per API came without caching.
- Amazon API Gateway API Calls charge: 5 million * $3.5/million = $17.50
- Data transfers in total: 3 KB * 5 million = 15 million KB = 14.3 GB
- Transfer fee: $0.09 = $1.29 * $14.3 GB
- The Gateway fee for the total Amazon API: $17.5 + $1.29 = $18.79.
The significance of API gateway in serverless apps
By simplifying normalizing system functions access points, including security and monitoring, APIs provide added value to serverless operations. In addition, because of the event-driven design, APIs enable bridge service modelling between systems through HTTP endpoints to activate your features.
API Gateway looks like a single API that meets the unique requirements of the application. API Gateway It consolidates in another language the path to all the typical characteristics of the system in the form of a service combined.
One thing is sure, the first step towards a serverless architecture is to map your requirements and how much it will cost to put your idea into practice. There's no size for everyone! For some firms, serverless helps lower expenses with an enormous margin, while others undoubtedly seek wider choices, given the hidden costs of serverless.
Although the remarkable thing about the AWS Lambda pricing calculator is that each serverless service offers free levels that might be enough for you if you have a modest workload. Ultimately, serverless provides enormous cost and time-saving possibilities when done correctly.