AppEngine Applications - Doing the Math

How much does it cost to run a cloud app on AppEngine?

Comments Posted by Captain Codeman in web-development blogging on Apr 3, 2017

So for various reasons I decided to write my own blog engine and because I think AppEngine is such a fantastic platform (especially for hosting multi-tenanted apps) that is what the initial runtime implementation uses.

I now have a few blogs setup which demonstrate the multi-tenancy working so I thought it was a good point to do some back-of-the-envelope math to figure out how much it would cost to host or how many blogs I could host for any given price.

Remember - one of my motivations for doing this is that I’m too cheap to pay for someone else to host my blog and I also want to host blogs for friends and family without ending up on the endless treadmill of maintaining servers, database backups and WordPress plugins.

So how’s it looking so far?

Actually, not too bad!

I’m going to use this blog as the most representative example. Obviously the figures could be very different if it were maintained by someone who, ehem, blogged conscientiously rather than as sporadically as I do or if the content was heavily skewed toward photos for instance (more on handling images in a later post …)

This blog currently uses less than 1Mb of datastore storage for the posts and pages and about 30Mb of images many of which are not referenced and could be removed (leftovers from other blog-systems that pre-generated resized images). I’m guessing there are less than 10Mb worth of images that are really part of the site (and it’s a nice round number to use to help with the math).

This is an embarrassingly negligible volume of data for any “cloud” system and is well within the free-tier, but AppEngine and the cloud is all about starting small and scaling up to whatever, whenever. But what would it cost if or when that happens?

Lets imagine we have 1,000 such blogs, what would that work out to be?

  • 1,000 x 1Mb = 1Gb of datastore
  • 1,000 x 10Mb = 10Gb of cloud storage (blobs)

What does that cost? Well, 1Gb of datastore is still part of the free-tier limit and 10Gb of cloud storage is just $0.20 per month. Yeah, the cloud is cheap! (especially if you can avoid any of the “legacy technology” pieces such as RDBMS).

OK, let’s see what happens when we ramp things up to 100,000 blogs:

  • 100,000 x 1Mb = 100Gb
  • 100,000 x 10Mb = 1Tb

This works out using the cloud platform calculator to around $13 for the datastore and $20 for the cloud storage (per month), still very comfortable numbers and a fraction of what it would cost to have a monolithic system to host them.

Now obviously there are extra costs involved beyond just the storage prices - with both datastore and cloud storage you pay for reads and writes above a certain level but hopefully it demonstrates how choosing the right technology can make a difference. If I was looking to host 100k WordPress blogs I think I’d be looking at significantly higher costs to achieve the same level of uptime and performance and a lot more work.

Also, remember the internet is a giant cache and many things (like images) are immutable and can be set to cache for long periods to reduce read and writes.

There’s also server-side caching - the system stores the content authored in Markdown in the datastore but also stores the generated pages as well. Using memcache automatically reduces a large number of reads from the datastore as well as dramatically speeding up the system.

Because the requests are fast (often single-digit ms) each instance can process a lot of pages concurrently and this efficiency helps prevent new instances spinning up. AppEngine gives you 27 instance hours free each day so if you can stay within this it’s uncharged.

The other way to mitigate the number of requests is to avoid duplication where the same content can be accessed via different URLs. It seems crazy that many people take the same copy of a blog engine like WordPress, install identical themes and then serve many of the same files but with their own unique URLs.

While many technical bloggers want ultimate flexibility and might come up with their own theme layout, I think the vast majority of people just want something that looks good and beyond setting a few different colors and background images are perfectly happy with the out-the-box experience and one of the popular themes. So why not centralize all of them? Instead of the same theme CSS file being available from 1m different URLs, why not have 1m blogs all use a single central file? Kind of like a CDN for blog themes, making viewing blogs hosted on the same system faster and more cache friendly for visitors as well.

It turns out that working out all the factors that will affect the final hosting costs is really difficult. I can see the system works very efficiently for a handful of blogs and I hope these efficiencies still apply as the scale goes up. I expect that the pricing and scaling of AppEngine and Google Cloud will ensure that the math works - already I don’t need to pay for any VM to host a web-server and / or RDBMS instance and I win in terms of effort because everything is a fully-managed service.

Once I go beyond a certain level of use I expect that AppEngine might become relatively more expensive for some parts of the system. I have worked on another site that deals heavily with photographs and those were better handled by GCE instances (with load balancer + group-cache) and the CDN service helping out too.

Whether it ever ends up with 1m, 100k or even 10 blogs is another matter of course. Right now it’s doing what I wanted which is providing a blog platform for myself and friends and isn’t costing me a penny (thanks Google!).

Here are the blogs running on it so far:

  • http://www.captaincodeman.com/
  • http://www.offroaddiscovery.com
  • http://www.thread-bare.com/

Note the system supports custom-domains or blogserve.co hosted sites.

appengine paas blogserve

Pinterest
Reddit
LinkedIn
comments powered by Disqus