Rebuilt Final Project

One of my goals for the summer was to rebuild my Networked Media final project on AWS. I am interested in learning more about AWS and rebuilding this did a lot to further that goal.

You can view the completed website at its new location: quickdraw.ixora.io. The functionality is exactly the same as before. The big difference is how the website works.

Architecture

The key concept to understand here is serverless. Serverless means there is no longer a server. In Shawn's class we hosted our projects on linux servers provided by Digital Ocean. In its place I am using Amazon's API Gateway, Lambda, and DynamoDB services.

All of the website's static content is sitting in an S3 bucket and served with Cloudfront. Route 53 directs Internet web traffic from the domain quickdraw.ixora.io to the nearest Cloudfront edge location. This is identical to how the hosting works for my main site, ixora.io.

Client-side JavaScript sends Ajax requests to the domain api.ixora.io. Happily AWS supports CORS so running a website with two domains is possible. Route 53 routes those requests to the API Gateway which triggers the Lambda functions. The main piece of code is fairly simple and really just makes DynamoDB queries and returns the results.

There's also an admin screen for managing the flagged drawings. That page requires authentication and is managed with Cognito. It is fairly trivial as the user pool only has one administrator user. The login page is available here but of course you'll need the password to proceed.

The biggest technical challenge was designing the DynamoDB table structure. I had to read a lot documentation to understand how the database worked; happily Amazon's documentation is thorough. I made intelligent choices for the partition keys so the queries are all fast. The table has about 1.8 million items in it and would still be efficient for a much larger size. I'm not going to explain the table design here but I will point out something I've said many times before: taking the time to make the right data structure choices saves an enormous amount of time and frustration later.

The Lambda functions are coded in Python 3.6 and use Amazon's Chalice Python library. All of the code is available on github.

Benefits

There are many benefits to this new approach for making a website.

The first benefit is cost. The website is small enough that all of the services used are well within the free usage limits of the different AWS tools. But even if there weren't free levels, this would still be inexpensive. Look at the Lambda pricing: most likely I'll never surpass one million requests, but even if I did surpass it by an additional one million requests, I'd still only pay a few pennies a month. The only service that could potentially be expensive is DynamoDB. The estimated cost of my provisioned Read and Write capacity is $1.84/month. That's still pretty cheap and is less than the $5/month I was paying for a Digital Ocean server. I know there are other free options out there like Heroku but they require serious compromises of the other benefits mentioned below as well as to the application itself.

The second benefit is maintainability. If I was still using the Digital Ocean server I would have to constantly monitor the server to make sure that everything continues to run properly. For a website that receives very little volume that would quickly become a chore. With AWS I could monitor this with CloudWatch and set alarms so I get an email if there is a problem.

The combination of low cost and easy maintainability means I can keep this project up indefinitely. Unfortunately most if not all of my classmates in the Networked Media class probably shut down their servers after the class ended. That's what I did, and that's unfortunate, because I put a lot of work into this. I'd rather keep it running and have something show to people. With AWS, I can easily do that.

Another benefit is scalability. If by chance this became very popular I would just need to increase the provisioned DynamoDB capacity. I'm not currently using auto-scaling, but if I was, the provisioning would increase on its own. With Digital Ocean and a node.js server I would have to migrate to a different machine.

Still another benefit is high availability. With Digital Ocean the entire website was hosted on one machine and would collapse if anything went wrong on that machine. With AWS, Amazon's infrastructure takes care of failover for me. The previous design was not robust and couldn't handle a failure of any kind.

The last benefit I'll mention is knowledge. There were a bunch of technical hurdles for me to overcome building this, but now that I have finished, I know I can build a highly available, scalable and maintainable website for another project without a lot of stress. I think it would be great to build a full-featured website for a future class project. AWS can help me make that happen.

Comments