Sunday, May 3, 2009

The per page-view cost of hosting a resonably efficient GAE/J application

The new CPU and bandwidth free quota levels that will be put in place on May 25, 2009 will be:
  • Bandwidth: 1 GB of data transferred in per day, and 1 GB out per day.
  • CPU time: 6.5 hours of CPU time per day (measured in 1.2 GHz Intel x86 CPU time)
According to calculations done by the Google App Engine team the new free quota levels will serve around 5M page-views per month for a "reasonably efficient application".

What's the per page-view assumptions behind these calculations?

Let's start with the bandwidth:

It is safe to assume that the amount of consumed outgoing bandwidth is much larger than the amount of incoming bandwidth consumed (average size of HTTP-request < average size of HTTP-response). 1 GB per day should serve at least 5M page-views per month. Assuming 30 days per month:
  • (30 days * 1 073 741 824 bytes/day) / 5 000 000 page-views = 6442 bytes of outgoing bandwidth per page-view
And the CPU time:

6.5 CPU-hours per day should be enough to serve at least 5M page-views per month. Again assuming 30 days per month:th:
  • (30 days * 6.5 CPU-hours/day * 3600 CPU-seconds/CPU-hour) / 5 000 000 page-views = 0.1404 CPU-seconds per page-view
When doing back-of-the-envelope calculations for estimating the resource usage for a "normal" GAE/J application, use the following numbers:
  • Outgoing bandwidth: 6442 bytes per page-view
  • CPU time: 0.1404 CPU-seconds per page-view
Using the same assumptions - what's the per page-view cost of hosting an application using Google App Engine?

The current per unit price of billable Google App Engine resources:
  • Outgoing bandwidth: 0.12 USD per gigabyte
  • Incoming bandwidth: 0.10 USD per gigabyte
  • CPU time: 0.10 USD per CPU-hour
    (measured in 1.2 GHz Intel x86 CPU time)
  • Stored data: 0.15 USD per GB and month
  • E-mail recipients: 0.0001 USD per recipient
The per page-view cost can be estimated as:
  • Bandwidth cost for 6442 bytes: 6442 bytes * 0.12 USD per GB / 1073741824 bytes per GB = 0.0000007199 USD per page-view
  • CPU cost for 0.1404 CPU-seconds: 0.1404 CPU-seconds * 0.10 USD per CPU-hour / 3600 CPU-seconds per CPU-hour = 0.0000039000 USD per page-view
Which gives a total of 0.0000046199 USD per page-view.

So in summary - the per page-view cost of hosting a resonably efficient GAE/J application is roughly 0.0000046199 USD per page-view. This is equivalent to 4.62 USD per million page-views.

2 comments:

yo said...

Great series of posts, really enjoying this blog.

Could you investigate gzip compression? There is a trade-off between bandwidth and cpu usage when gzip compression is used for dynamic pages.

Paul Buchheit (GMail creator) says that this trade-off favours using cpu for gzip over bandwidth:

http://paulbuchheit.blogspot.com/2009/04/make-your-site-faster-and-cheaper-to.html

However, for Appengine/Python, although static resources like css and javascript are automatically served compressed, dynamic pages aren't, and you cannot do it manually as Content-Encoding response headers are stripped by the server.

The Appengine/J docs don't make the distinction between compressing dynamic/static content, but they imply that dynamic content is compressed.

Is this the case? Does Appengine/J compress dynamic content and how does that change the budget for cpu/bandwidth allowance and price per request?

yo said...

140ms (1.2GHZ CPU) per request.

But what can you do with 140cpums? How many cpums for a simple servlet which returns 6,400 bytes. How many cpums for a single datastore call which finds a single entity?

If the datastore is busy then your process spin/waits and you are charged for the cpu time.

What I am wondering is, what can a 'reasonably efficient' web app achieve in 140cpu-ms, and is that reasonable?

Post a Comment