Getting started with Django on Amazon Web Services

Edan Maor picture Edan Maor · Dec 20, 2010 · Viewed 11k times · Source

I'm starting to migrate a few applications to Amazon Web Services. My applications are Python/Django apps, running over MySQL.

I plan on using EC2 and EBS for starters.

I'm looking for a few things:

  1. A good step-by-step tutorial explaining how to deploy Django on AWS. I've looked around, but most tutorials are from 2 years ago, so I'm worried they're outdated.

  2. I'm trying to understand, with which AMI should I start? I know there's a BitNami AMI that comes preconfigured with Django goodiness, but I've seen a lot of other sources say you should start with a basic (clean) linux box and install everything yourself. Why?

  3. Are there any other important things I should be thinking about? I have very little sysadmining experience (the apps are currently on WebFaction), so I'm not sure what I should be thinking about.

A few extra points:

  • I plan on running several applications on the same EC2 instance, I assume that's possible?
  • I'm using virtualenv to separate between the various apps right now, I assume I can continue doing the same on the EC2 instance?

Thanks!

Answer

cezio picture cezio · Dec 20, 2010

There is nothing "special" with EC2 here. It just provides bare (or generally preconfigured from custom AMI) system instance - you have access to whole virtualized system, so you can safely break things on your own. Think about it as a specific VPS.

You have to prepare deployment by yourself, which is not so difficult - just follow the documentation. I'd advice to run with basic linux distro and add needed stuff than to rely on some preconfigured image. As for you questions:

  1. You need to do two things: setup your instance (accounts, needed software, other custom setup, so some linux administration guide should be handy) and prepare django app deployment (deploy python code, hook up to web server). For the latter, general deployment instructions for django can be applied here ( http://docs.djangoproject.com/en/dev/howto/deployment/ ).

  2. Start with AMI with your favorite linux distro, and then add necessary software from it's repository.

  3. Mount and use EBS as soon as possible for all your data. When rebooted, EC2 instance will wipe out all it's data, so be prepared for this. Do system snapshots to AMI to have quick recovery on failure.

Yes, you can deploy several applications on one instance, but mind that EC2 instance is virtualized (with quite high "virtualization tax" imo, especially for smaller instances), so you might run into general performance problems. Assume that you'd need migrate to bigger instance/multiple instances after some time.

Virtualenv should be your default deployment tool. Yes, you can use it here too.