• Part Two

PyCon 2011: Deploying Django web applications to the cloud

Python makes it easy to develop great web applications. Amazon Web Services (AWS) makes it easy to deploy scalable, fault tolerant applications. In this tutorial we will focus on taking a provided Django web application and deploying it to AWS through a series of hands on exercises using Amazon's load balancing, auto scaling, content delivery and relational database services.

Abstract

In this tutorial we will start with a demo Django application that we will use for the rest of the exercises. No previous experience with Django will be required.

Exercise 1: deploy the demo Django application to a single EC2 node using MySQL backed by an EBS (Elastic Bloc Storage) volume.

Exercise 2: move the database to RDS (Relational Database Service) and scale out reads using RDS read replicas.

Exercise 3: add a second node for the web application and place them into ELB (Elastic Load Balancer).

Exercise 4: move the static content into S3 and CloudFront.

Exercise 5: create an Auto Scaling group to automatically adjust the fleet of web servers based on load.

After these exercises the student will be left with a set of automated recipes for provisioning and deploying standard Django applications to AWS in a scalable, fault tolerant manner.

Students will be need to bring their own laptop and have a current AWS account including signing up for the following services: EC2, S3, CloudFront and RDS. Usage of AWS will be billed to the student by Amazon, but it should only be a few dollars for the 3 hour exercise. Students using Windows will need to have Putty installed for SSH access.

For more talks about python from PyCon 2011

Talk by Cosmin Stejerean at PyCon 2011

In this tutorial we will start with a demo Django application that we will use for the rest of the exercises. No previous experience with Django will be required.

  • bobbyuser

    Awesome tutorial!!

    I was initially getting 500′s from apache after running pycon-aws-django with the suggested flags and output from pycon-init-db as instructed.

    It turns out I needed to make a minor change to the install_project() function (line 260, specifically) of pycon-aws-django:

    was:

    line 260: sudo -u $LOCAL_USER tar xvf $LOCAL_DISTRIBUTION_PATH -C /home/$LOCAL_USER/
    line 261: sudo -u $LOCAL_USER pip -E /home/$LOCAL_USER/env install -r $PROJECT_ROOT/requirements/project.txt

    If the contents of the tar ball are extracted to /home/$LOCAL_USER, then PIP cannot find $PROJECT_ROOT/requirements/project.txt because it won’t exist at that path.

    changed to:

    line 260: sudo -u $LOCAL_USER tar xvf $LOCAL_DISTRIBUTION_PATH -C $PROJECT_ROOT
    line 261: sudo -u $LOCAL_USER pip -E /home/$LOCAL_USER/env install -r $PROJECT_ROOT/requirements/project.txt

    By changing tar’s destination directory to $PROJECT_ROOT, PIP can correctly find requirements/project.txt and setup the app correctly.

    Thanks Cosmin!!

  • http://profiles.google.com/scottfoubister Scott Foubister

    Great tutorial and scripts, I learned so much by watching!

    To deploy my own app I also had to change line 260 in the pycon-aws-django script as mentioned by bobbyuser.
    Thanks a lot!

  • Riegie

    Amazing tutorial! For the database script, what would I need to change in order to install postgresql instead of mysql?

  • Pingback: Django web application | simple2013