Here at Super WordSearch we wanted to create our entire game to be able to run completely "ServerLess", and with todays latest technologies this is actually extremely achievable...
So our strategy was to make use of the following:
With our files stored neatly in our AWS CloudFront and S3 system, we can then safely take a sigh of relief knowing that we have an extremely robust cloud based system to serve our files from, no more worries that our old PHP Servers CPU is approaching 100%, crashes all the times or is in dire need of an update that is stuck because of an outdated extension that isn't playing ball!
The ServerLess framework allows us to define our Cloud Based system as IAC (Infrastructure as Code) and to easily setup and configure almost all of it via the CLI (Command line Interface)
This means that we can Administer our hosting environment directly from Visual Studio and takes any of the DevOps server management almost completely out of the equation - for us here at SuperWordsearch that meant we could focus all of our efforts into building the game, and to not have to spend more than a few days of investigating how to setup our hosting system!
To begin with we took at look at the Single Page App Via Cloudfront example on serverless.com which gave us the blueprints to start creating our own script, by the end of it we had our S3 Bucket, SSL Certificates and CloudFront CDN all setup and ready to populate.
Once our front end code was ready we could then simply upload it via aws --profile [YOUR_PROFILE] s3 sync ./your-folder/ s3://your-bucket/ and then because CloudFront will cache our files for up to 365 days (or the TTL we specified) then
if we edit any files, in order to see the changes come through we must invalidate our cache using the following command: aws --profile [YOUR_PROFILE] cloudfront create-invalidation --distribution-id XXXXXXXXXX --paths "/*" - where
[YOUR_PROFILE] is your IAM profile as per your ~/.aws/credentials file.
We used this same method to host the content for our https://www.superwordsearch.com website, the "Lite" web version of our Game: https://game.superwordsearch.com as well as our API files for our Application.
Although AWS CloudFront is a fantastic Cloud Based CDN, it's biggest downside is the cost in Data Transfer, and this is where we decided that we'd place an extra layer on top of our CDN system using https://www.cloudflare.com/ - this allows us to proxy the majority of our traffic through the CloudFlare servers saving on Tb's of data!
CloudFlares Global Network