Estimate your cloud costs
How much will my app cost if I migrate it to the AWS cloud? Is it an affordable solution? Will I save some money, or will it be much more pricey? If you have such questions in mind or wonder how much AWS can cost you, please stop wondering. Instead, grab a cup of coffee and sit comfortably.
In the next 10 minutes, I’ll explain to you how to estimate the costs of AWS. It’s not black magic or crystal-gazing. It is just the usage of a great tool provided by Amazon called “AWS Pricing Calculator.” With its usage, you can predict your costs with high accuracy. Of course, the better you know your app and your user’s traffic, the more accurate the predictions will be.
If your app is a greenfield app, it’s a little harder, but it’s not impossible. You just have to make some assumptions. But no more talking. Let’s see an example.
For this tutorial, let’s assume we’re developing the NodeJS app. We need a single middle-size EC2 instance, RDS (Postgres) database, and a few lambda functions for batch operations to handle our traffic.
To start the calculation, go to the calculator page:
There is a search bar at the top of the page for filtering desired services. Let’s type
configureon the first card.
At the top of Configure Amazon EC2 page, you have to pick the desired region — the price may differ based on region. Pick the nearest region to your end-users to avoid unnecessary latency. In my case, I’ll pick the London region, and I’ll pick the
quick estimate option shadows.
The next section contains information about the EC2 instance itself. You have to set the number of CPUs, amount of memory, pick the operating system, quantity (how many instances do you need), and utilization (how long in percent your app will be running during the month). So based on the data I provided, AWS proposed to me the
So far, so good. Let’s move to the two last sections. There, you have to set the pricing model. Based on your need, you may pick options like “On Demand” (the most pricey option, but you’re not tided with AWS with any saving contract), or you can pick some option(you will pay in advance for at least one year, but you will get a discount).
Finally, for EC2, you have to pick the type and size of the hard disk. For me, it’s enough to have a 20GB General purpose SSD. I will keep my data inside the Postgres database, but I will use the RDS service.
At the very bottom of the page, you can see the total estimation of costs of the EC2 instance. Click,
add to my estimate.
After clicking the add to my estimate button, you will see the summary page. The costs here are split into upfront, monthly, and yearly expenses. There is a list of estimated services as well. But currently, I have added only one. So, let’s add a few more. For that, click the
add service button in the top-right corner of the page.
You will be redirected to the picking service page. This time, we will add the Postgres database estimation. Search for the phrase
RDS for PostgreSQL and click
configure. Similarly to the EC2 instance, I’ll pick the
t4g.large instance type. I’ll leave the default 100% monthly utilization setting, deployment to Multi-AZ setting, and pricing model set as OnDemand.
I need 100 GB of storage per month, and the General Purpose SSD option is sufficient. So, my final calculation for PostgreSQL is as follows:
Again, click the add to estimate button, and next, on the “My estimate page,” click the add service button. Until now, things were simple. Now we will estimate the lambda usage, which is a little more complicated, but fear not. We’ll face it. You can pick from two options at the top of the page:
Lambda Function — Include Free Tier and
Lambda Function — Without Free Tier.
I highly recommend you pick the option
Lambda Function — Without Free Tier. It is always better to look at the worst scenario regarding prices predictions. If we overestimated our cost? No worries. Worse if we would underestimate. Besides that, if you are working in a big organization and estimating a new project, the chances are high that another of your projects has reached the free tier limits.
OK, but moving back to our estimation… If you are developing a serverless app with many o lambdas, I honestly don’t have good information for you. Because for lambda cost estimation, you have to provide the number of monthly requests. Yes, you heard that correctly. You have to know how many invocations there will be.
In a serverless API, it’s most likely guesstimate, not estimate. But in my case, I know the concrete number of the requests. I only use the lambda function to generate some reports. There are three lambdas; each invoked every hour, every day. So, I’ll have
3 * 24 * 31 lambdas invocations during the month. It’s
2232 invocations per month.
Next, you have to provide the average duration in milliseconds for the lambda function — another hard-to-tell parameter. Invocation times will differ for sure, but you should at least know if the time is in milliseconds, seconds, minutes, or hours.
My lambdas do a minor job. From start to end, it’s something about 600ms. The last parameter I have to fill in is the amount of memory allocated. I need only 512MB of memory.
Then I’ll leave the rest of the settings empty. I don’t need a provisioned concurrency, and I don’t have any lambda@edge. When we scroll to the bottom, we will see the total estimation. In my case, it is only 0.01 USD. Yes, 0.01 USD. It’s basically free 🙂 depending on the usage, Lambdas may be so cheap.
At the beginning of the article, I told you that the app, which we estimate, would take advantage of three AWS services: EC2, RDS PostgreSQL and AWS Lambda. So, that’s it, right? We did a whole calculation. But, in fact, not necessarily.
Two things will affect your final bill, and they are not so obvious at the glance. First, how users of the app will communicate with it? Of course, over the internet network. Aren’t we need some kind of NAT gateway for that? Yes, we need it, and unfortunately, it’s a paid solution. Next, does our app produce some logs? Yes, it does. So, we will highly likely use a cloud watch. Again, another charge we didn’t have in mind previously.
To not make this tutorial unnecessarily long, I’ll stop here. Now it’s time for your homework. Could you add an estimation of these two services? It’s simple, you can do it. You have to repeat what we did earlier. Go to the
Select service page and search for
Amazon Virtual Private Cloud (VPC) for setting the NAT estimation and
Amazon CloudWatch for logs.
The reason I’m not showing you how to make an estimation for those services is that Amazon provides us with over 200 services. It’s not doable to learn by heart how to estimate all of them. You have to be able to deal with new services.
My goal for this tutorial was to get you familiar with AWS’s pricing calculator. I’m pretty sure that after reading this text, you will know what to do.
Happy estimating, and see you next time!