37
Developing & Deploying Cloud Applications with Python on Amazon EC2 Presented by: Diane Mueller, Director, Enterprise Product Management at ActiveState Raymond Hettinger, Python core developer and Python Software Foundation

Developing & deploying cloud applications with python on amazon ec2

Embed Size (px)

DESCRIPTION

With ActiveState’s new ActivePython Amazon Machine Image (AMI), Python developers can now develop and deploy cloud-based applications to Amazon EC2. The Python-centric AMI is a complete LAMP stack, with all the components and Python packages required for you to have your own enterprise-ready AMI instance. One of the challenges of getting started in cloud computing is starting with an empty instance, learning the Amazon cloud services API, making scalable architectural decisions, and building a complete web stack from scratch. The ActivePython Amazon EC2 AMI provides prebuilt Python-centric Amazon Machine Image (AMI) with a working web stack which is an excellent starting point for those just beginning to explore the Cloud and is available now.

Citation preview

Page 1: Developing & deploying cloud applications with python on amazon ec2

Developing & Deploying Cloud Applications

with Python on Amazon EC2

Presented by:

Diane Mueller, Director, Enterprise Product Management at ActiveState

Raymond Hettinger, Python core developer and Python Software Foundation

Page 2: Developing & deploying cloud applications with python on amazon ec2

Diane MuellerDirector, Enterprise Product Management at [email protected]

Raymond Hettinger

Python core developer and Python Software Foundation

[email protected]

Page 3: Developing & deploying cloud applications with python on amazon ec2

About ActiveState

Why Python on the Cloud?

What is an AMI?

What do you get on the ActivePython AMI

Getting Started

Two Ways to Get Started

5 Steps to an AMI

Summary

Q&A

Page 4: Developing & deploying cloud applications with python on amazon ec2

Founded 1997

2 million developers, 97% of Fortune 1000 rely on ActiveState

Development, management, distribution solutions for dynamic languages

Core languages: Python, Perl, Tcl

Other: PHP, Ruby, Javascript

Amazon Solution Partner:

Page 5: Developing & deploying cloud applications with python on amazon ec2
Page 6: Developing & deploying cloud applications with python on amazon ec2

Dynamic Languages

Platform independence

Python & Web Frameworks

Python & Databases

Rise of the Cloud Proto-typing to Production

Web Applications

Enterprise Workflow

Enterprise Testing & Development

Page 7: Developing & deploying cloud applications with python on amazon ec2

Steep Learning Curve for AWS

Quick On-Ramp

Best Practices for Complete Web Stack

Toolkit for Customization & Deployment

Page 8: Developing & deploying cloud applications with python on amazon ec2

Designed to provide smooth on-ramps at various stages of adoption

Newcomers

Developers

Existing Django deployments

Enterprise IT departments

Page 9: Developing & deploying cloud applications with python on amazon ec2

Loosely coupled stack, so that developers can easily use alternatives

databases like MySQL or PostgreSQL,

web-frameworks such as Django or Pylons,

templating systems such as Mako or Cheetah,

web servers such as Apache or Gunicorn

The build can also be targeted to various Linux distributions such as Ubuntu or RedHat.

Page 10: Developing & deploying cloud applications with python on amazon ec2

Ubuntu 64-bit Ubuntu operating system (version 10.04).

Nginx

serves static content and routes web-traffic to multiple worker instances.

Apache (version 2.2.16)

running mod_wsgi (version 3.3.7).

ActivePython (version 2.6.6 CE upgradable to 2.6.6 BE)

includes PyPM packaging manager.

virtualenv (1.5.1) & virtualenvwrapper.

Django (1.2.3)

SQLite3 (included in the Python distribution)

MySQL (version 5.1).

Memcached

Page 11: Developing & deploying cloud applications with python on amazon ec2

Direct Access

Script Driven Development

Page 12: Developing & deploying cloud applications with python on amazon ec2

The fastest way to get a running web server

When doing production work by directly modifying the instance, be sure to periodically save backup copies of the instance

Page 13: Developing & deploying cloud applications with python on amazon ec2

Register:https://aws-portal.amazon.com/gp/aws/developer/registration/index.html

Read Amazon’s Getting Started Guide:http://docs.amazonwebservices.com/AWSEC2/latest/GettingStartedGuide

Page 14: Developing & deploying cloud applications with python on amazon ec2

More Flexibility

Reproducible Builds

Version Control

Re-targeting

Command-line Control

Adding, Removing or Updating Components

Migrating to Alternative Hosts

Page 15: Developing & deploying cloud applications with python on amazon ec2

Runs on your local machine

Requirements:ActivePython 2.6

boto for accessing AWS services

fabric for remote deployment.

Download the ActiveState cloud development toolkit to your desktophttp://www.activestate.com/activepython/request-activepython-ami-scripts

Page 16: Developing & deploying cloud applications with python on amazon ec2

Ensure that you have Python 2.6 installed on your desktop

If you don’t have Python 2.6 installed, go get it!http://www.activestate.com/activepython/downloads

It is a good idea to work in a virtual environment although it is not a requirement of this tutorial.

Page 17: Developing & deploying cloud applications with python on amazon ec2

Type these commands to install the only two dependencies for the toolkit:

(env)$ pypm install boto

(env)$ pypm install fabric

Page 18: Developing & deploying cloud applications with python on amazon ec2

fabfile.py

a thin wrapper around nimbus/fablib.py which has most of the deployment code -- this is where you will put build customizations.

settings.py

where you specify your configuration options. The toolkit is run from the command-line.

Page 19: Developing & deploying cloud applications with python on amazon ec2

A short sequence of steps serves to build, deploy, and manage your AMI:

Edit the settings.py

Run fab make_master

Run fab deploy

Run fab status

Fab browse

Page 20: Developing & deploying cloud applications with python on amazon ec2

include your AWS key and ID

Screenshot?

Page 21: Developing & deploying cloud applications with python on amazon ec2

Screenshot??.

Page 22: Developing & deploying cloud applications with python on amazon ec2

Now the instance is populated with the whole web stack

but does not have the demonstration application uploaded, deployed, and activated.

Page 23: Developing & deploying cloud applications with python on amazon ec2

To see the status at any time, run fab status which shows which instances are running or stopped, their DNS names, and Amazon instance identifiers.

Page 24: Developing & deploying cloud applications with python on amazon ec2

To see the live website, either type the DNS name in a web browser or run fab browse.

Now, the application is running and world-visible.

Page 25: Developing & deploying cloud applications with python on amazon ec2

Make worker instances!Manage scaling with fab distribute_load which will clone the running instance to make worker instances.

The master instance directs traffic among the workers using Nginix.The master instance’s own webserver is still available as a fail-over, but the workers will get the first chance to handle load.

The database and memcache continue to run on the master instance.

Page 26: Developing & deploying cloud applications with python on amazon ec2

Learn more about Fabric

Make the AMI yours

Security on the AMI

Page 27: Developing & deploying cloud applications with python on amazon ec2

browse

Open the master instance in the default browser

deploy

Install the application specified in settings.py to the...

distribute_load

Distribute load between as many workers as specified by...

fix_names

Reconfigure instances with

the current domain names

make_master

Create a pre-configured instance

restart

Restart an instance

start

Start an instance

status

Lists instances

stop

Stop an instance

update

Update the installed application

Page 28: Developing & deploying cloud applications with python on amazon ec2

Make edits to the sample web pages in demosite directory and upload them to a running instance with fab update.

http://cloud.activestate.com

Page 29: Developing & deploying cloud applications with python on amazon ec2

The security is provided by the ssh2 key stored in nimbus.pem.

For example:

ssh -i nimbus.pem ec2-50-16-18-225.compute-1.amazonaws.com

Page 30: Developing & deploying cloud applications with python on amazon ec2

Whether cloned from ActiveState’s prebuilt instance or built with a script

a running instance can be directly accessed

using ssh (or putty on Windows).

The default username is “ubuntu”

but this can be changed in setting.py

as long as you create a corresponding Amazon user account.

Page 31: Developing & deploying cloud applications with python on amazon ec2

Environment provides a Python setup that is fully independent of the one that ships with the operating system

Provides great flexibility in upgrading Python versions and controlling exactly which packages are installed.

Activating the virtual environment makes all of the installed python packages visible to the command line interpreter.

Page 32: Developing & deploying cloud applications with python on amazon ec2

Django configuration and control scripts are located in the /var/www/demosite directory

Quick start tutorials can be found at

http://code.djangoproject.com/wiki/Tutorials.

Page 33: Developing & deploying cloud applications with python on amazon ec2

Apache server log files are stored in the /var/log directory.

If you’re new to Apache and need to modify the set-up, take a look at the Apache how-to guides at http://httpd.apache.org/docs/2.0/howto/.

Page 34: Developing & deploying cloud applications with python on amazon ec2

You now have a running web server and all the tools needed to customize and manage the site…

Page 35: Developing & deploying cloud applications with python on amazon ec2

Check out the Tutorial: http://cloud.activestate.com

Download the Toolkit:http://www.activestate.com/activepython/request-activepython-ami-scripts

Page 36: Developing & deploying cloud applications with python on amazon ec2

Questions?

Next Steps:Get started using the ActivePython AMI:

activestate.com/activepython/amazon-machine-image

Find out more about ActivePython Business Edition:

activestate.com/activepython

Request Information:[email protected]

1-866-510-2914

Page 37: Developing & deploying cloud applications with python on amazon ec2