How Much Does It Cost To Run A Serverless API on AWS?

Spread the love

Serving 2.1 million API requests for $11

Folks tend to be curious about how much real projects cost to run on
AWS, so here’s a real example with breakdowns by AWS service and

This article walks through the AWS invoice for charges accrued in
November 2016 by the API service which
runs in the us-east-1 (Northern Virginia) region and uses the following
AWS services:

  • API Gateway
  • AWS Lambda
  • DynamoDB
  • Route 53
  • CloudFront
  • SNS (Simple Notification Service)
  • CloudWatch Logs
  • CloudWatch Metrics
  • CloudTrail
  • S3
  • Network data transfer
  • CloudWatch Alarms

During this month, service processed over 2 million API
requests. Every request ran an AWS Lambda function that read from
and/or wrote to a DynamoDB table.

This AWS account is older than 12 months, so any first year free tier
specials are no longer applicable.

Total Cost Overview

At the very top of the AWS invoice, we can see that the total AWS
charges for the month of November add up to $11.12. This is the total
bill for processing the 2.1 million API requests and all of the
infrastructure necessary to support them.

Invoice: Summary

Service Overview

The next part of the invoice lists the top level services and charges
for each. You can see that two thirds of the month’s cost was in API
Gateway at $7.47, with a few other services coming together to make up
the other third.

Invoice: Service Overview

API Gateway

Current API Gateway pricing is $3.50 per million
requests, plus data transfer. As you can see from the breakdown below,
the requests are the bulk of the expense at $7.41. The responses from probably average in the hundreds of bytes, so there’s
only $0.06 in data transfer cost.

You currently get a million requests at no charge for the first 12
months, which was not applicable to this invoice, but does end up
making API Gateway free for the development of many small projects.

Invoice: API Gateway


I don’t remember enabling CloudTrail on this
account, but at some point I must have done the right thing, as this
is something that should be active for every AWS account. There were
are almost 400,000 events recorded by CloudTrail, but since the first
trail is free, there is no charge listed here.

Note that there are some charges associated with the storage of the
CloudTrail event logs in S3. See below.

Invoice: CloudTrail


The CloudWatch costs for this service come from
logs being sent to CloudWatch Logs and the storage of those
logs. These logs are being generated by AWS Lambda function execution
and by API Gateway execution, so you can consider them as additional
costs of running those services. You can control some of the logs
generated by your AWS Lambda function, so a portion of these costs are
under your control.

There are also charges for CloudWatch Alarms, but for some reason,
those are listed under EC2 (below) instead of here under CloudWatch.

Invoice: CloudWatch

Data Transfer

Data transfer costs can be complex as they depend on where the data is
coming from and going to. Fortunately for, there is very
little network traffic and most of it falls into the free tiers. What
little we are being charged for here amounts to a measly $0.04 for 4
GB of data transferred between availability zones. I presume this is
related to AWS services talking to each other (e.g., AWS Lambda to
DynamoDB) because there are no EC2 instances in this stack.

Note that this is not the entirety of the data transfer charges, as
some other services break out their own network costs.

Invoice: Data Transfer


The DynamoDB pricing includes a permanent free tier
of up to 25 write capacity units and 25 read capacity units. The has a single DynamoDB table that is set to a capacity of
25 write and 25 read so there are no charges for capacity.

The DynamoDB database size falls well under the 25 GB
free tier, so that has no charge either.

Invoice: DynamoDB

Elastic Compute Cloud

The service does not use EC2 and yet there is a section
in the invoice for EC2. For some reason this section lists the
CloudWatch Alarm charges.

Each CloudWatch Alarm costs $0.10 per month and this account has eight
for a total of $0.80/month. But, for some reason, I was only billed
$0.73. *shrug*

Invoice: EC2

This AWS account has four AWS billing alarms that will email
me whenever the cumulative charges for the month pass
$10, $20, $30, and $40.

There is one CloudWatch alarm that emails me if the AWS Lambda
function invocations are being throttled (more than 100 concurrent
functions being executed).

There are two CloudWatch alarms that email me if the consumed read and
write capacity units are trending so high that I should look at
increasing the capacity settings of the DynamoDB table. We are nowhere
near that at current usage volume.

Yes, that leaves one CloudWatch alarm, which was a duplicate. I have
since removed it.

AWS Lambda

Since most of the development of the API service focuses
on writing the 60 lines of code for the AWS Lambda function, this is
where I was expecting the bulk of the charges to be. However, the AWS
Lambda costs only amount to $0.22 for the month.

There were 2.1 million AWS Lambda function invocations, one per
external consumer API request, same as the API Gateway. The first
million AWS Lambda function calls are free. The rest are charged at
$0.20 per million.

The permanent free tier also includes 400,000 GB-seconds of compute
time per month. At an average of 0.15 GB-seconds per function call, we
stayed within the free tier at a total of 320,000 GB-seconds.

Invoice: AWS Lambda

I have the AWS Lambda function configuration cranked up to the max
1536 GB memory so that it will run as fast as
possible. Since the charges are rounded up in units of
100ms, we could probably save GB-seconds by scaling down the memory
once we exceed the free tier. Most of the time is probably spent in
DynamoDB calls anyway, so this should not affect API performance much.

Route 53

Route 53 charges $0.50 per hosted zone (domain). I
have two domains hosted in Route 53, the expected plus
the extra The domain was supposed to
redirect to, but I apparently haven’t gotten around to
tossing in that feature yet. These two hosted zones account for $1 in

There were 1.1 million DNS queries to and, but since those resolve to aliases for the API
Gateway, there is no charge.

The other $0.09 comes from the 226,000 DNS queries to random and hostnames. These would include, which is a page displaying
the uptime of as reported by StatusCake.

Invoice: Route 53

Simple Notification Service

During the month of November, there was one post to an
SNS topic and one email delivery from an SNS
topic. These were both for the CloudWatch alert notifying me that the
charges on the account had exceeded $10 for the month. There were no
charges for this.

Invoice: SNS

Simple Storage Service

The S3 costs in this account are entirely for storing the
CloudTrail events. There were 222 GET requests ($0) and 13,000
requests of other types ($0.07). There was no charge for the 0.064
GB-Mo of actual data stored. Has Amazon started rounding fractional
pennies down instead of up in some services?

Invoice: SNS

External Costs

The domains and are registered through
other registrars. Those cost about $33 and $9 per year, respectively.

The SSL/TLS certificate for https support costs around $10-15 per
year, though this should drop to zero once CloudFront distributions
created with API Gateway support certificates with ACM (AWS
Certificate Manager) #awswishlist

Not directly obvious from the above is the fact that I have spent no
time or money maintaining the API service
post-launch. It’s been running for 1.5 years and I haven’t had to
upgrade software, apply security patches, replace failing hardware,
recover from disasters, or scale up and down with demand. By using AWS
services like API Gateway, AWS Lambda, and DynamoDB, Amazon takes care
of everything.


Your Mileage May Vary.

For entertainment use only.

This is just one example from one month for one service architected
one way. Your service running on AWS will not cost the same.

Though 2 million API requests in November cost about
$11, this does not mean that an additional million would cost another
$5.50. Some services would cost significantly more and some would
cost about the same, probably averaging out to significantly more.

If you are reading this after November 2016, then the prices for these
AWS services have certainly changed and you should not use any of the
above numbers in making decisions about running on AWS.


Amazon, please lower the cost of the API Gateway; or provide a
simpler, cheaper service that can trigger AWS Lambda functions with
https endpoints. Thank you!

Original article and comments:

Posted by News Monkey