Search code examples
djangoamazon-web-servicesamazon-ec2load-balancingamazon-cloudfront

Advice on Amazon Web Services Setup for Django Back end & iOS Front end


I've done a lot of research over the past few weeks regarding the appropriate Amazon Web Services setup for a Django back end with a PostgreSQL database and an iOS front end. I'm quite the newbie and I feel like I may be asking a dumb question here but do any of you have any advice on how I can go about this? Currently my set up involves two instances.

One EC2 instance is for my django backend (large instance) running Ubuntu 11.04 and the other instance is for my postgresql instance (large instance) running Ubuntu 11.04.

For months I have been using this setup for development and beta testing with 60 users and it has been rock solid. Just recently I have completed the back end and I have finished the front end and I am in the process of submitting my app into the app store.

During the approval process, I would like to be production ready and beef up my AWS setup. My app is centered around social photo sharing. User's can take pictures of things they want on a wish list and share it with their followers. The pictures are all stored in S3.

Any advice would be extremely appreciated. Thank you in advance.


Solution

  • The answer largely depends on your tolerance for downtime vs your monthly budget for AWS. A few points:

    • Never run anything important on a single instance. For your app tier, you should be using a minimum of two instances, each in separate AZ, with load distributed by an Elastic Load Balancer.

    • For Postgres, set up two instances (also in separate AZ's) and configure replication. I'd also highly recommend that you use provisioned IOPS EBS volumes and provisioned IOPS-optimized instances.

    • Definately look into Elastic Beanstalk. This will greatly simplify setting an autoscaling app tier and make it a snap to deploy code to it. This will also make it easy to set up separate staging and production environments so you can Q&A your code before rolling it to users.

    • Consider setting a VPC for increased security and more control over your network resources. There's a bit of an initial learning curve, but it's worth it, especially when you plan to set up DB replication.

    • Set up SNS alerts via CloudWatch alarms so you get notified when things break.

    • Scale out before you scale up. Meaning, use a greater number of smaller instances before you move up to larger instances. This minimizes the impact of a single instance failure in your autoscaling group. It also allows more granular autoscaling. Don't use large instances until you've benchmarked your application and discovered that you need them.

    • Once you know what size instances you actually need, purchase reserved instances to save yourself at least 40% over 12 months.

    I go into more detail about some of these items (and provide a few other tips) on my blog.