How to View How Much Bandwidth Your AWS EC2 Instances Are Using

Amazon charges you when your EC2 instances broadcast content over the Internet or transfer data between regions. If you are running a web server on EC2, this can quickly become a major cost. Here’s how to track your bandwidth usage.

EC2 bandwidth costs money

Incoming data is free, but data leaving your instances is taxed. the the exact price depends on the region, but most of it is $ 0.09 per GB. You get 1 GB of use for free (even if your free level has expired) and the price is reduced after reaching 10 TB transferred.

Data transferred between regions costs $ 0.01 to transfer to the eastern United States and $ 0.02 for everything else. Data transferred between Availability Zones costs $ 0.01 in each direction. Transfers in Availability Zones are free, but if you use public IP addresses for transfers (rather than private addresses), you will have to pay the same two-way fee of $ 0.01. Make sure your machines are all in the same area and are using private addresses to communicate with each other.

If you have a lot of data, you can consider hosting your static assets in S3 and serving them through CloudFront. S3 storage is cheaper than the EBS volumes used for EC2, and CloudFront costs only $ 0.085 per GB, a minor cost reduction. But, CloudFront also has a free level of 50 GB, and S3 transfers to CloudFront are free.

How to view your bandwidth

AWS makes this much more difficult than necessary. Technically, you can view your bandwidth usage in CloudWatch, Amazon’s integrated analysis tool. Under Metrics> EC2, you can find the “NetworkOut” metric for the EC2 instance that you want to monitor. Make sure this graph is set to “Sum” rather than “Average”, which will display the total network off rather than the average speed. You can break it down by period and refine it by dragging to select points on the graph:

From CloudWatch, you can set up alarms that will notify you of any anomalies, such as bandwidth spikes that could cost you extra money.

Here’s the problem – there is nothing that shows the sum of all the points you are stuck with a line graph. None of the math expressions does anything to help; the only way to actually display the accumulated sum over a period in CloudWatch is to create a dynamic label that uses the SUM function:

This will show the SUM just below the graph, next to the measure name:

However, this is the total number of bytes. You will therefore have to divide your calculator and divide by 1024 to find KB, again to find MB, again to find GB, etc.

Dynamic labeling can be very misleading and difficult to use. If you select “Last 7 days” as the period, then select a region with your mouse to zoom in on a particular event, the dynamic label is not updated. You must manually specify a time period such as “2019-09-13 04:42 – 2019-09-13 05:42” to get an accurate measurement.

How to view the actual cost of EC2 bandwidth

If you want to see how much bandwidth actually costs you, you can do so in the Cost Explorer. In the “Cost and use” tab, you can add a filter by “Type of use” and a filter for “EC2” to limit the cost of bandwidth to your virtual machines only.

You can set the time range to display a more accurate graph, since the default is set to last six months.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.