Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Prototyping in the cloud

3,079 views

Published on

Slides for presentation on prototyping in the cloud from OSCON 2013

Published in: Technology
  • Be the first to comment

Prototyping in the cloud

  1. 1. PROTOTYPING IN THE CLOUD Kirsten Jones @synedra on twitter http://www.princesspolymath.com Wednesday, July 24, 13
  2. 2. THE PRINCESS Many years of experience with APIs/REST Developer support, helping people be successful Love hacking, creating prototypes (check my blog, lots of code samples) Wednesday, July 24, 13
  3. 3. THIS TALK How to prototype in the cloud Deploy full application stack Basic example in PHP (Drupal) More extensive examples in Node and Python Most code available on Github Wednesday, July 24, 13
  4. 4. PAAS PROVIDERS Many providers Examples here feature free payment tier, portability, maturity Heroku Appfog Others: Engineyard, Joyent, etc. Wednesday, July 24, 13
  5. 5. APPFOG / PHP Originally PHPFog Now supports Java, .NET, Node, Ruby, Python, PHP Moderate level of configuration available Many frameworks supported Easy quick-start Ruby-based toolkit Wednesday, July 24, 13
  6. 6. APPFOG: CREATE NEW APPLICATION Wednesday, July 24, 13
  7. 7. APPFOG: SUPPORTED FRAMEWORKS Wednesday, July 24, 13
  8. 8. APPFOG: INFRASTRUCTURE Wednesday, July 24, 13
  9. 9. APPFOG: BUILDING APP Wednesday, July 24, 13
  10. 10. APPFOG: DEFAULT DRUPAL INSTALL Wednesday, July 24, 13
  11. 11. APPFOG: TOOLBELT sudo gem install af af login af pull appfogdemo Wednesday, July 24, 13
  12. 12. HEROKU Polyglot system Started with Ruby on Rails Ruby, Node.js, Clojure, Java, Python, and Scala. Quick deployment, fine control of processes Examples: Django, LinkedIn Today SMS, IODocs Wednesday, July 24, 13
  13. 13. HEROKU: DJANGO PREREQUISITES Heroku Toolbelt (Ruby) Python PIP for package management % easy_install pip Virtualenv % pip install virtualenv Heroku User Account Postgres (needed for Django) Wednesday, July 24, 13
  14. 14. HEROKU: CREATE DJANGO APP Following the Heroku Django tutorial % mkdir herokudjango % cd herokudjango % virtualenv venv --distribute % source venv/bin/activate % pip install django-toolbelt % django-admin.py startproject herokudjango . Wednesday, July 24, 13
  15. 15. HEROKU: START LOCAL DJANGO APP foreman start 15:29:49 web.1 | started with pid 14308 15:29:49 web.1 | 2013-07-13 15:29:49 [14308] [INFO] Starting gunicorn 17.5 15:29:49 web.1 | 2013-07-13 15:29:49 [14308] [INFO] Listening at: http:// 0.0.0.0:5000 (14308) 15:29:49 web.1 | 2013-07-13 15:29:49 [14308] [INFO] Using worker: sync 15:29:49 web.1 | 2013-07-13 15:29:49 [14311] [INFO] Booting worker with pid: 14311 Wednesday, July 24, 13
  16. 16. HEROKU: CONFIGURE REQUIREMENTS pip freeze > requirements.txt Wednesday, July 24, 13
  17. 17. HEROKU: INITIALIZE GIT REPOSITORY (venv)kirsten-mac:herokudjango kirsten$ git init Initialized empty Git repository in /Users/kirsten/oscon/ herokudjango/.git/ (venv)kirsten-mac:herokudjango kirsten$ git add . (venv)kirsten-mac:herokudjango kirsten$ git commit -m "heroku django app” [master (root-commit) 39cb46c] heroku django app … Wednesday, July 24, 13
  18. 18. HEROKU: DEFAULT SETUP Still need to push the actual application to the server… Wednesday, July 24, 13
  19. 19. HEROKU: PUSH TO THE CLOUD (venv)kirsten-mac:herokudjango kirsten$ git push heroku master Counting objects: 11, done. Delta compression using up to 8 threads. Compressing objects: 100% (8/8), done. Writing objects: 100% (11/11), 4.15 KiB, done. Total 11 (delta 0), reused 0 (delta 0) -----> Python app detected -----> No runtime.txt provided; assuming python-2.7.4. -----> Preparing Python runtime (python-2.7.4) -----> Installing Distribute (0.6.36) -----> Installing Pip (1.3.1) -----> Installing dependencies using Pip (1.3.1) … -----> Discovering process types Procfile declares types -> web -----> Compiled slug size: 30.0MB -----> Launching... done, v5 http://peaceful-depths-8963.herokuapp.com deployed to Heroku To git@heroku.com:peaceful-depths-8963.git * [new branch] master -> master Wednesday, July 24, 13
  20. 20. HEROKU: DJANGO APP IN THE CLOUD Wednesday, July 24, 13
  21. 21. HEROKU: ADMIN COMMANDS (venv)kirsten-mac:herokudjango kirsten$ heroku ps Process State Command ------- --------- -------------------------- web.1 up for 2m gunicorn herokudjango.wsgi (venv)kirsten-mac:herokudjango kirsten$ heroku logs 2013-07-13T22:40:28.697577+00:00 heroku[api]: Release v2 created by synedra@gmail.com 2013-07-13T22:40:28.662735+00:00 heroku[api]: Enable Logplex by synedra@gmail.com 2013-07-13T22:42:03.033821+00:00 heroku[router]: at=info code= desc="Blank app" method=GET path=/ host=peaceful- depths-8963.herokuapp.com fwd="10.21.72.132, 173.36.196.8" dyno= connect= service= status=502 bytes= 2013-07-13T22:42:03.762626+00:00 heroku[router]: at=info code= desc="Blank app" method=GET path=/favicon.ico host=peaceful- depths-8963.herokuapp.com fwd="10.21.72.132, 173.36.196.8" dyno= connect= service= status=502 bytes= 2013-07-13T22:42:03.925807+00:00 heroku[router]: at=info code= desc="Blank app" method=GET path=/favicon.ico host=peaceful- depths-8963.herokuapp.com fwd="10.21.72.132, 173.36.196.8" dyno= connect= service= status=502 bytes= 2013-07-13T22:42:03.186189+00:00 heroku[router]: at=info code= desc="Blank app" method=GET path=/ host=peaceful- depths-8963.herokuapp.com fwd="10.21.72.132, 173.36.196.8" dyno= connect= service= status=502 bytes= 2013-07-13T22:42:09.403312+00:00 heroku[router]: at=info code= desc="Blank app" method=GET path=/ host=peaceful- depths-8963.herokuapp.com fwd="10.21.72.132, 173.36.196.8" dyno= connect= service= status=502 bytes= 2013-07-13T22:42:09.556041+00:00 heroku[router]: at=info code= desc="Blank app" method=GET path=/ host=peaceful- depths-8963.herokuapp.com fwd="10.21.72.132, 173.36.196.8" dyno= connect= service= status=502 bytes= 2013-07-14T00:59:16+00:00 heroku[slug-compiler]: Slug compilation started 2013-07-14T01:00:42.243676+00:00 heroku[api]: Scale to web=1 by synedra@gmail.com … 2013-07-14T01:00:43+00:00 heroku[slug-compiler]: Slug compilation finished 2013-07-14T01:00:46.595118+00:00 heroku[web.1]: Starting process with command `gunicorn herokudjango.wsgi` 2013-07-14T01:00:47.265537+00:00 app[web.1]: 2013-07-14 01:00:47 [2] [INFO] Starting gunicorn 17.5 2013-07-14T01:00:47.272266+00:00 app[web.1]: 2013-07-14 01:00:47 [7] [INFO] Booting worker with pid: 7 2013-07-14T01:00:47.266249+00:00 app[web.1]: 2013-07-14 01:00:47 [2] [INFO] Using worker: sync 2013-07-14T01:00:47.266163+00:00 app[web.1]: 2013-07-14 01:00:47 [2] [INFO] Listening at: http://0.0.0.0:54065 (2) 2013-07-14T01:00:47.783995+00:00 heroku[web.1]: State changed from starting to up 2013-07-14T01:00:55.028851+00:00 heroku[router]: at=info method=GET path=/ host=peaceful-depths-8963.herokuapp.com fwd="10.21.72.132, 173.36.196.8" dyno=web.1 connect=1ms service=102ms status=200 bytes=1975 Wednesday, July 24, 13
  22. 22. HEROKU: WEB DASHBOARD Wednesday, July 24, 13
  23. 23. HEROKU: APPLICATION MANAGEMENT Wednesday, July 24, 13
  24. 24. HEROKU: DEPLOY EXISTING DJANGO APP Django/LinkedIn/Twilio Integration https://github.com/synedra/django-linkedin- simple GET/POST Stores Auth from LinkedIn Copy this code into the new application Procfile: web: python todaynag/manage.py runserver Check the local server http://127.0.0.1:8000 Wednesday, July 24, 13
  25. 25. HEROKU: DEPLOYED APPLICATION Wednesday, July 24, 13
  26. 26. HEROKU: NODE.JS Take an existing app and deploy to Heroku IODocs: https://github.com/mashery/iodocs HowTo on PrincessPolymath.com Wednesday, July 24, 13
  27. 27. HEROKU: QUICK SETUP % git clone http://github.com/mashery/iodocs.git % cd iodocs/ % npm install % echo "web: node app.js" > Procfile % cp config.json.sample config.json % git add –f config.json % heroku create % heroku addons: add redistogo % git push heroku master Wednesday, July 24, 13
  28. 28. HEROKU: IODOCS DEPLOYED Wednesday, July 24, 13
  29. 29. SUM UP Many cloud providers to choose from Develop locally, deploy to public facing cloud Major languages supported Hackdays Quick web apps Experiments Wednesday, July 24, 13
  30. 30. QUESTIONS? Wednesday, July 24, 13

×