Ephemeral cloud-based functions like AWS Lambda and GCE Functions are gaining traction quickly. If done right, they can be economically beneficial and enable infinite scalability™ without forcing you to wade into swarms of containers. If applied incorrectly, they can result in a much more expensive, over-engineered, and difficult to manage application. It’s important to understand that it isn’t all or nothing. Serverless is in our future, but it isn’t our exclusive future.

Functions as a service (FaaS) are functions configured in a cloud provider with a single entry point which lay dormant until triggered. Planning for FaaS is similar to the way you would approach learning about immutable objects, functional programming paradigms, or migrating from monolithic to distributed architectures. You break apart, simplify, and do an overall re-think of the application. However, it doesn’t mean you need to completely re-build the application.

Banana for scale

Say you have an existing monolithic application which acts as a tiling server — one similar to what Google or Mapbox uses to generate their beautiful jpg/png/json tiles.

The application’s core features are:

Allow authenticated users to submit new geographical data to be processed and ultimately translated to tiles via Mapnik. (Mapnik is common cartographic imaging software for processing things like Shape Files) Serve tiles via HTTP — /{tile}/{zoom}/{lat}/{lng}.png Allow for a special URL to generate a large map based on a bound box — /map/{north}/{south}/{east}/{west}/{zoom}.png

It takes a lot of CPU to generate tens of thousands of tiles. If you want a performant application, you’ll be putting a substantial amount of your budget in GCE or AWS for VMs. You also have to consider handling more requests than a typical application. Generally, one page load will result in six or more tile requests, or whatever it takes to fill the screen. Dragging the map around quickly results in a lot more. A lot of people doing the same thing… well, you get the idea. A lot of requests.

Your initial build or MVP may look something like this:

Monolithic Approach

This may work great at first. You could write background “tile warming” scripts which cache tiles before they get requested and other small enhancements to get a proof of concept out.