KEMBAR78
Deploy Python apps in 5 min with a PaaS | PDF
Deploy  Python  apps  
   in  5  minutes
    with  a  PaaS
             Nate  Aune
    PyCon  on  the  Charles,  part  1
           Feb.  25,  2013
Jazkarta  (2004-­‐current)
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
Appsembler  (2012-­‐current)
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?
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)
Meet  Dave
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  day      1  day
Maintaining  the  server




1  day   1  day   1  day
Security




1  day   1  day   1  day    1  day
Scaling




1  day   1  day   1  day   1  day   1  day
Oh  sh*t  moment.
Sysadmin $80k
te
sed


        DBA $90k
                       Train new guy

                   6
Why  touch  servers  if  
you  don’t  have  to?
PaaS
Is  it  the  promised  land?
What is a PaaS?
  Platform-as-a-service enables developers to create
innovative applications without operational overhead
 around configuration, deployment and management.
Layers of infrastructure




Source: EngineYard “PaaS - State of the Market Survey” May 2012 - http://venturebeat.com/2012/07/05/engine-yard-paas-infographic/
Source: EngineYard “PaaS - State of the Market Survey” May 2012 - http://venturebeat.com/2012/07/05/engine-yard-paas-infographic/
Source: EngineYard “PaaS - State of the Market Survey” May 2012 - http://venturebeat.com/2012/07/05/engine-yard-paas-infographic/
Source: EngineYard “PaaS - State of the Market Survey” May 2012 - http://venturebeat.com/2012/07/05/engine-yard-paas-infographic/
Source: AppFog “Evolution of the Cloud: Toward a NoOps World” Jan 2012
http://gigaom.com/cloud/why-2013-is-the-year-of-noops-for-programmers-infographic/
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
Let them do
    the boring stuff
• Patches and updates
• Migrating applications
• Backups / snapshots
• Configuring everything (web servers, load
  balancers, modules, databases)
Define  OS  dependencies

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


5  min
Backups




5m 5m




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




5m 5m 5m
Scaling




5m 5m 5m 5m




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




5m 5m 5m 5m 5m
IaaS  vs.  PaaS
   IaaS  -­‐  days



  PaaS  -­‐  minutes
Which  PaaS?

• Hosted
• DIY
• Hybrid  (public  with  opTon  to  go  private)
Who are the players?

• CloudFoundry • Heroku
  (open source by VMWare)   (now Salesforce)
                                               • OpenShift
                                                 (Redhat’s open source PaaS)


• AppFog       • Dotcloud                      • App Engine
                                                 (Google)

• Stackato
  (ActiveState)
               • Gondor     (Python only)      • Elastic Beanstalk
                                                 (Amazon)


                                               • Azure
                                                 (Microsoft)
Who are the players?
                  We’ll look at these ones tonight.


• CloudFoundry • Heroku • OpenShift
  (open source by VMWare)    (now Salesforce)   (Redhat’s open source PaaS)


• AppFog       • Dotcloud • App Engine          (Google)

• Stackato • Gondor
  (ActiveState)           • Elastic Beanstalk
                             (Python only)
                                                (Amazon)


                          • Azure               (Microsoft)
Dotcloud
polyglot from the start, very flexible, most Python centric
Anatomy of a
     Django app
    on Dotcloud
customized settings.py for Dotcloud

createdb.py to create the database
dotcloud.yml to store config info
mkadmin.py to make the admin user
nginx.conf to config URL rewriting
postinstall to run syncdb, collectstatic

wsgi.py to serve using uWSGI
Heroku
Anatomy of a
    Django app
    on Heroku

customized settings.py for Heroku


Procfile to configure process

requirements.txt to define dependencies
Stackato
                     by ActiveState
     Python 3, Run anywhere, New Relic integration




http://appsembler.com/blog/django-deployment-using-stackato/
Anatomy of
Django app on
   Stackato

customized settings file




stackato.yml to define services
wsgi.py to serve using uWSGI
OpenShift
                       by Redhat
         Open source, Auto-scaling, Jenkins builds




http://appsembler.com/blog/django-deployment-using-openshift/
Action hooks for running commands
   during build, deploy, post-deploy, etc.



/data/ dir to store uploaded media files

     Anatomy of an
     OpenShift repo
   .htaccess to serve up static files
  application inside of wsgi dir

 setup.py instead of requirements.txt
Stackato OpenShift Dotcloud                                      Heroku
Python           2.7, 3.2 2.6 (2.7) 2.6.5, 2.7.2,                                 2.7.2
                stackato runtimes
                                                       3.1.2, 3.2.2
PostgreSQL         9.1                 8.4                 9.0                     9.1.6
MySQL              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
Stackato OpenShift Dotcloud                                      Heroku
Memory       Configurable            1.5GB             Unlimited
                                    RAM               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
Why  not  PaaS?

• Already  invested  in  your  own  infrastructure.
• Need  to  run  on  servers  outside  U.S.
• Special  requirements  not  met  by  PaaS  services
OpenShid  Pricing
Dotcloud  pricing
Heroku pricing
Other resources
• Wrap-up from PaaS bake-off
  http://appsembler.com/blog/wrap-up-from-paas-bake-off/

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

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

• paasbakeoff - code examples
   https://github.com/appsembler/paasbakeoff/

Deploy Python apps in 5 min with a PaaS

  • 1.
    Deploy  Python  apps  in  5  minutes with  a  PaaS Nate  Aune PyCon  on  the  Charles,  part  1 Feb.  25,  2013
  • 2.
  • 3.
    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
  • 4.
  • 5.
    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?
  • 6.
    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)
  • 7.
  • 9.
    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  day 1  day
  • 10.
    Maintaining  the  server 1 day 1  day 1  day
  • 11.
    Security 1  day 1  day 1  day 1  day
  • 12.
    Scaling 1  day 1  day 1  day 1  day 1  day
  • 13.
  • 14.
    Sysadmin $80k te sed DBA $90k Train new guy 6
  • 15.
    Why  touch  servers if   you  don’t  have  to?
  • 16.
    PaaS Is  it  the promised  land?
  • 17.
    What is aPaaS? Platform-as-a-service enables developers to create innovative applications without operational overhead around configuration, deployment and management.
  • 18.
    Layers of infrastructure Source:EngineYard “PaaS - State of the Market Survey” May 2012 - http://venturebeat.com/2012/07/05/engine-yard-paas-infographic/
  • 19.
    Source: EngineYard “PaaS- State of the Market Survey” May 2012 - http://venturebeat.com/2012/07/05/engine-yard-paas-infographic/
  • 20.
    Source: EngineYard “PaaS- State of the Market Survey” May 2012 - http://venturebeat.com/2012/07/05/engine-yard-paas-infographic/
  • 21.
    Source: EngineYard “PaaS- State of the Market Survey” May 2012 - http://venturebeat.com/2012/07/05/engine-yard-paas-infographic/
  • 22.
    Source: AppFog “Evolutionof the Cloud: Toward a NoOps World” Jan 2012 http://gigaom.com/cloud/why-2013-is-the-year-of-noops-for-programmers-infographic/
  • 23.
    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
  • 24.
    Let them do the boring stuff • Patches and updates • Migrating applications • Backups / snapshots • Configuring everything (web servers, load balancers, modules, databases)
  • 25.
    Define  OS  dependencies www: type: python systempackages: - openoffice.org - mysql-client-5.1 5  min
  • 26.
    Backups 5m 5m https://devcenter.heroku.com/articles/heroku-postgres-fork
  • 27.
  • 28.
    Scaling 5m 5m 5m5m https://openshift.redhat.com/community/developers/scaling
  • 29.
  • 30.
    IaaS  vs.  PaaS IaaS  -­‐  days PaaS  -­‐  minutes
  • 31.
    Which  PaaS? • Hosted •DIY • Hybrid  (public  with  opTon  to  go  private)
  • 32.
    Who are theplayers? • CloudFoundry • Heroku (open source by VMWare) (now Salesforce) • OpenShift (Redhat’s open source PaaS) • AppFog • Dotcloud • App Engine (Google) • Stackato (ActiveState) • Gondor (Python only) • Elastic Beanstalk (Amazon) • Azure (Microsoft)
  • 33.
    Who are theplayers? We’ll look at these ones tonight. • CloudFoundry • Heroku • OpenShift (open source by VMWare) (now Salesforce) (Redhat’s open source PaaS) • AppFog • Dotcloud • App Engine (Google) • Stackato • Gondor (ActiveState) • Elastic Beanstalk (Python only) (Amazon) • Azure (Microsoft)
  • 34.
    Dotcloud polyglot from thestart, very flexible, most Python centric
  • 37.
    Anatomy of a Django app on Dotcloud customized settings.py for Dotcloud createdb.py to create the database dotcloud.yml to store config info mkadmin.py to make the admin user nginx.conf to config URL rewriting postinstall to run syncdb, collectstatic wsgi.py to serve using uWSGI
  • 38.
  • 41.
    Anatomy of a Django app on Heroku customized settings.py for Heroku Procfile to configure process requirements.txt to define dependencies
  • 42.
    Stackato by ActiveState Python 3, Run anywhere, New Relic integration http://appsembler.com/blog/django-deployment-using-stackato/
  • 45.
    Anatomy of Django appon Stackato customized settings file stackato.yml to define services wsgi.py to serve using uWSGI
  • 46.
    OpenShift by Redhat Open source, Auto-scaling, Jenkins builds http://appsembler.com/blog/django-deployment-using-openshift/
  • 48.
    Action hooks forrunning commands during build, deploy, post-deploy, etc. /data/ dir to store uploaded media files Anatomy of an OpenShift repo .htaccess to serve up static files application inside of wsgi dir setup.py instead of requirements.txt
  • 49.
    Stackato OpenShift Dotcloud Heroku Python 2.7, 3.2 2.6 (2.7) 2.6.5, 2.7.2, 2.7.2 stackato runtimes 3.1.2, 3.2.2 PostgreSQL 9.1 8.4 9.0 9.1.6 MySQL 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
  • 50.
    Stackato OpenShift Dotcloud Heroku Memory Configurable 1.5GB Unlimited RAM 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
  • 51.
    Why  not  PaaS? •Already  invested  in  your  own  infrastructure. • Need  to  run  on  servers  outside  U.S. • Special  requirements  not  met  by  PaaS  services
  • 52.
  • 53.
  • 54.
  • 55.
    Other resources • Wrap-upfrom PaaS bake-off http://appsembler.com/blog/wrap-up-from-paas-bake-off/ • Django deployment using PaaS http://appsembler.com/blog/django-deployment-using-paas/ • django-deployer https://github.com/natea/django-deployer • paasbakeoff - code examples https://github.com/appsembler/paasbakeoff/