developing & deploying cloud applications with python on amazon ec2
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.TRANSCRIPT
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
Diane MuellerDirector, Enterprise Product Management at [email protected]
Raymond Hettinger
Python core developer and Python Software Foundation
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
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:
Dynamic Languages
Platform independence
Python & Web Frameworks
Python & Databases
Rise of the Cloud Proto-typing to Production
Web Applications
Enterprise Workflow
Enterprise Testing & Development
Steep Learning Curve for AWS
Quick On-Ramp
Best Practices for Complete Web Stack
Toolkit for Customization & Deployment
Designed to provide smooth on-ramps at various stages of adoption
Newcomers
Developers
Existing Django deployments
Enterprise IT departments
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.
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
Direct Access
Script Driven Development
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
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
More Flexibility
Reproducible Builds
Version Control
Re-targeting
Command-line Control
Adding, Removing or Updating Components
Migrating to Alternative Hosts
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
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.
Type these commands to install the only two dependencies for the toolkit:
(env)$ pypm install boto
(env)$ pypm install fabric
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.
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
include your AWS key and ID
Screenshot?
Screenshot??.
Now the instance is populated with the whole web stack
but does not have the demonstration application uploaded, deployed, and activated.
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.
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.
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.
Learn more about Fabric
Make the AMI yours
Security on the AMI
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
Make edits to the sample web pages in demosite directory and upload them to a running instance with fab update.
http://cloud.activestate.com
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
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.
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.
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.
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/.
You now have a running web server and all the tools needed to customize and manage the site…
Check out the Tutorial: http://cloud.activestate.com
Download the Toolkit:http://www.activestate.com/activepython/request-activepython-ami-scripts
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