Serving Map Tiles in Realtime from Edge Locations through Amazon CloudFront

Yesterday Amazon released one new and very interesting feature on their CloudFront service (one of the Amazon Web Services). This service has been providing a way to serve static content from their edge locations, so you could deliver your content anywhere at very low latencies. The downside was that you first had to upload your content to Amazon S3. That worked quite well, but the problem was that you had to create and store your data in advance and then make it available over Amazon S3 and CloudFront.

Amazon CloudFront Support for Custom Origins

You can now create a CloudFront distribution using a custom origin. Each distribution can point to an S3 or to a custom origin. This could be another storage service, or it could be something more interesting and more dynamic, such as real time map tiles! You can even put as origin any web address, it is not requirement to be hosted by Amazon.

Amazon CloudFront with GIS Cloud as a Custom Origin

As we wrote in a post while ago, GIS Cloud can produce map tiles in real time very fast and efficient. Now with CloudFront those tiles can be served anywhere in realtime and very quickly with CloudFront catching and serving all content from the edge locations.

Setting up CloudFront with custom origins is very straight forward. We used a tool called Bucket Explorer (more information how to use can be found here). It is just necessary to point CloudFront distribution to any web domain, we pointed ours to www.giscloud.com. Also CloudFront provides you a way to use CNAMEs so you can have a nice subdomain like cft1.giscloud.com.

The Test

When tiles are being served from CloudFront the service will try to serve them first from local cache. If there is no such tile then CloudFront gets that tile from GIS Cloud which produces it in real-time. Next time when that tile is being accessed it is served directly from CloudFront!

This method of serving tiles can save allot of time. Most raster map engines out there are just too slow in real-time tile rendering so all map tiles needs to be rendered first. GIS Cloud eliminates this problem because it can produce tiles dynamically in real-time and deliver them very quickly so there is no more need to generate huge amounts of map tiles and serve them as static content.

Map tile structure of GIS Cloud is very straight forward:
https://www.giscloud.com/t/<timestamp>/<map_id>/<layer_id>/<level>/<x>/<y>.swf

e.g. https://www.giscloud.com/t/1283442148/map9399/layer43159/1/0/0.swf

or now through Amazon CloudFront: http://cft1.giscloud.com/t/1283442148/map9399/layer43159/1/0/0.swf

Bellow we embedded two maps. First one is being served directly from GIS Cloud Europe and the other from Amazon CloudFront. If you are from Europe you will probably not notice a big difference, but if you are from Americas or Asia you should.

 

Map Tiles from GIS Cloud (data center in Europe):

 

 

Map Tiles from Amazon CloudFront with origin set to GIS Cloud: