deploy python apps in 5 min with a paas

55
Deploy Python apps in 5 minutes with a PaaS Nate Aune PyCon on the Charles, part 1 Feb. 25, 2013

Upload: appsembler

Post on 07-Nov-2014

4.520 views

Category:

Technology


0 download

DESCRIPTION

How can you avoid servers and get back to coding? Platform-as-a-service (PaaS) makes deployment easy. But which PaaS do you choose and how do you get started? This talk will examine several of the leading PaaS providers and discuss their pros/cons. We'll also give examples for how to deploy the same app to each of them to see the differences.

TRANSCRIPT

Page 1: Deploy Python apps in 5 min with a PaaS

Deploy  Python  apps  in  5  minuteswith  a  PaaS

Nate  AunePyCon  on  the  Charles,  part  1

Feb.  25,  2013

Page 2: Deploy Python apps in 5 min with a PaaS

Jazkarta  (2004-­‐current)

Page 3: Deploy Python apps in 5 min with a PaaS

2010-­‐2011

• Nothing  equivalent  to  Heroku  for  Django  developers

• Built  my  own  PaaS  (“How  hard  can  it  be?”)

• Shut  down  last  year.  Increased  compeTTon  from  big  corps  meant  a  race  to  the  boUom

Page 4: Deploy Python apps in 5 min with a PaaS

Appsembler  (2012-­‐current)

Page 5: Deploy Python apps in 5 min with a PaaS

Agenda

•Why  should  I  care?  

•What  is  a  PaaS?  What  are  the  advantages?

•Which  PaaS  should  I  use?

•When  might  I  not  want  to  use  a  PaaS?

Page 6: Deploy Python apps in 5 min with a PaaS

Where  are  you  deploying/hosTng  today?

• Shared  hosTng  (i.e.  WebfacTon)

• Running  your  own  servers  (co-­‐located)?

• Using  an  IaaS  provider  (i.e.  AWS  or  Rackspace)

• Already  using  a  plaZorm-­‐as-­‐a-­‐service  (PaaS)

Page 7: Deploy Python apps in 5 min with a PaaS

Meet  Dave

Page 8: Deploy Python apps in 5 min with a PaaS
Page 9: Deploy Python apps in 5 min with a PaaS

Configuring  a  server

• deciding  what  size  to  get  (memory,  disk)

• ge]ng  all  the  dependencies  installed  on  it

• SSHing  into  the  machine  to  deploy  stuff  (feels  dirty,  but  he’s  under  Tme  pressure)

1  day1  day

Page 10: Deploy Python apps in 5 min with a PaaS

Maintaining  the  server

1  day1  day 1  day

Page 11: Deploy Python apps in 5 min with a PaaS

Security

1  day1  day 1  day 1  day

Page 12: Deploy Python apps in 5 min with a PaaS

Scaling

1  day1  day 1  day 1  day 1  day

Page 13: Deploy Python apps in 5 min with a PaaS

Oh  sh*t  moment.

Page 14: Deploy Python apps in 5 min with a PaaS

How many people focus on your platform?

Could you innovate faster if they focused on your apps?

Where do you invest?!

6

Example Headcount Costs

Sysadmin $80k

DBA $90kTrain new guy

Page 15: Deploy Python apps in 5 min with a PaaS

Why  touch  servers  if  you  don’t  have  to?

Page 16: Deploy Python apps in 5 min with a PaaS

PaaSIs  it  the  promised  land?

Page 17: Deploy Python apps in 5 min with a PaaS

What is a PaaS?Platform-as-a-service enables developers to create

innovative applications without operational overhead around configuration, deployment and management.

Page 18: Deploy Python apps in 5 min with a PaaS

Layers of infrastructure

Source: EngineYard “PaaS - State of the Market Survey” May 2012 - http://venturebeat.com/2012/07/05/engine-yard-paas-infographic/

Page 19: Deploy Python apps in 5 min with a PaaS

Source: EngineYard “PaaS - State of the Market Survey” May 2012 - http://venturebeat.com/2012/07/05/engine-yard-paas-infographic/

Page 20: Deploy Python apps in 5 min with a PaaS

Source: EngineYard “PaaS - State of the Market Survey” May 2012 - http://venturebeat.com/2012/07/05/engine-yard-paas-infographic/

Page 21: Deploy Python apps in 5 min with a PaaS

Source: EngineYard “PaaS - State of the Market Survey” May 2012 - http://venturebeat.com/2012/07/05/engine-yard-paas-infographic/

Page 22: Deploy Python apps in 5 min with a PaaS

Source: AppFog “Evolution of the Cloud: Toward a NoOps World” Jan 2012http://gigaom.com/cloud/why-2013-is-the-year-of-noops-for-programmers-infographic/

Page 23: Deploy Python apps in 5 min with a PaaS

Efficient, Elastic, Secure

• Lots of applications co-located on a few servers

• Drastically reduces resources

• Add/remove servers depending on load

• All secured using SELinux or LXC

Page 24: Deploy Python apps in 5 min with a PaaS

Let them do the boring stuff

• Patches and updates

• Migrating applications

• Backups / snapshots

• Configuring everything (web servers, load balancers, modules, databases)

Page 25: Deploy Python apps in 5 min with a PaaS

Define  OS  dependencies

www: type: python systempackages: - openoffice.org - mysql-client-5.1

5  min

Page 26: Deploy Python apps in 5 min with a PaaS

Backups

5m 5m

https://devcenter.heroku.com/articles/heroku-postgres-fork

Page 27: Deploy Python apps in 5 min with a PaaS

SSL

5m 5m 5m

Page 28: Deploy Python apps in 5 min with a PaaS

Scaling

5m 5m 5m 5m

https://openshift.redhat.com/community/developers/scaling

Page 29: Deploy Python apps in 5 min with a PaaS

Caching

5m 5m 5m 5m 5m

Page 30: Deploy Python apps in 5 min with a PaaS

IaaS  vs.  PaaS

IaaS  -­‐  days

PaaS  -­‐  minutes

Page 31: Deploy Python apps in 5 min with a PaaS

Which  PaaS?

• Hosted

• DIY

• Hybrid  (public  with  opTon  to  go  private)

Page 32: Deploy Python apps in 5 min with a PaaS

Who are the players?

• CloudFoundry (open source by VMWare)

• AppFog

• Stackato(ActiveState)

• Heroku(now Salesforce)

• Dotcloud

• Gondor(Python only)

• OpenShift(Redhat’s open source PaaS)

• App Engine(Google)

• Elastic Beanstalk(Amazon)

• Azure(Microsoft)

Page 33: Deploy Python apps in 5 min with a PaaS

Who are the players?

• CloudFoundry (open source by VMWare)

• AppFog

• Stackato(ActiveState)

• Heroku(now Salesforce)

•Dotcloud

• Gondor(Python only)

• OpenShift(Redhat’s open source PaaS)

• App Engine(Google)

• Elastic Beanstalk(Amazon)

• Azure(Microsoft)

We’ll look at these ones tonight.

Page 34: Deploy Python apps in 5 min with a PaaS

Dotcloudpolyglot from the start, very flexible, most Python centric

Page 35: Deploy Python apps in 5 min with a PaaS
Page 36: Deploy Python apps in 5 min with a PaaS
Page 37: Deploy Python apps in 5 min with a PaaS

Anatomy of a Django app

on Dotcloud

dotcloud.yml to store config info

nginx.conf to config URL rewriting

wsgi.py to serve using uWSGI

createdb.py to create the database

mkadmin.py to make the admin user

postinstall to run syncdb, collectstatic

customized settings.py for Dotcloud

Page 38: Deploy Python apps in 5 min with a PaaS

Heroku

Page 39: Deploy Python apps in 5 min with a PaaS
Page 40: Deploy Python apps in 5 min with a PaaS
Page 41: Deploy Python apps in 5 min with a PaaS

Anatomy of a Django app on Heroku

Procfile to configure process

requirements.txt to define dependencies

customized settings.py for Heroku

Page 42: Deploy Python apps in 5 min with a PaaS

Stackatoby ActiveState

Python 3, Run anywhere, New Relic integration

http://appsembler.com/blog/django-deployment-using-stackato/

Page 43: Deploy Python apps in 5 min with a PaaS
Page 44: Deploy Python apps in 5 min with a PaaS
Page 45: Deploy Python apps in 5 min with a PaaS

Anatomy of Django app on

Stackato

stackato.yml to define services

customized settings file

wsgi.py to serve using uWSGI

Page 46: Deploy Python apps in 5 min with a PaaS

OpenShiftby Redhat

Open source, Auto-scaling, Jenkins builds

http://appsembler.com/blog/django-deployment-using-openshift/

Page 47: Deploy Python apps in 5 min with a PaaS
Page 48: Deploy Python apps in 5 min with a PaaS

setup.py instead of requirements.txt

application inside of wsgi dir.htaccess to serve up static files

/data/ dir to store uploaded media files

Action hooks for running commands during build, deploy, post-deploy, etc.

Anatomy of an OpenShift repo

Page 49: Deploy Python apps in 5 min with a PaaS

Stackato OpenShift Dotcloud HerokuPython 2.7, 3.2

stackato runtimes2.6 (2.7) 2.6.5, 2.7.2,

3.1.2, 3.2.22.7.2

PostgreSQL 9.1 8.4 9.0 9.1.6MySQL 5.5 5.1 5.1 (Yes, via RDS)

Persisted FS Yes Yes Yes (Yes, via S3)

Redis Yes, 2.4 No Yes, 2.4.11 (Yes, via addon)

MongoDB Yes, 2.0 Yes, 2.2 Yes, 2.2.1 (Yes, via addon)

Memcached Yes, 1.4 No Yes (Yes, via addon)

RabbitMQ Yes, 2.4 No Yes, 2.8.5 (Yes, via addon)

Solr No No Yes, 3.4.0 (Yes, via Websolr)

Cron Yes Yes Yes Yes

Extensible Yes, apt-get install Yes, DIY cartridge Yes, custom service Yes, buildpacks

WebSockets Yes Yes Yes Yes, via Pusher add-on

Page 50: Deploy Python apps in 5 min with a PaaS

Stackato OpenShift Dotcloud Heroku

Memory Configurable 1.5GB RAM

Unlimited sandbox

Apps Configurable No Yes, 2.8.5 (Yes, via addon)

Solr No No Yes, 3.4.0 (Yes, via Websolr)

Cron Yes Yes Yes Yes

Extensible Yes, apt-get install Yes, DIY cartridge Yes, custom service Yes, buildpacks

WebSockets Yes ? Yes Yes, via Pusher add-on

Page 51: Deploy Python apps in 5 min with a PaaS

Why  not  PaaS?

• Already  invested  in  your  own  infrastructure.

• Need  to  run  on  servers  outside  U.S.

• Special  requirements  not  met  by  PaaS  services

Page 52: Deploy Python apps in 5 min with a PaaS

OpenShid  Pricing

Page 53: Deploy Python apps in 5 min with a PaaS

Dotcloud  pricing

Page 54: Deploy Python apps in 5 min with a PaaS

Heroku pricing

Page 55: Deploy Python apps in 5 min with a PaaS

Other resources

• Wrap-up from PaaS bake-offhttp://appsembler.com/blog/wrap-up-from-paas-bake-off/

• Django deployment using PaaShttp://appsembler.com/blog/django-deployment-using-paas/

• django-deployerhttps://github.com/natea/django-deployer

• paasbakeoff - code exampleshttps://github.com/appsembler/paasbakeoff/