Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Django Apps to Services

Django Apps to Services

240da217b000604a2302dfc8b02a9cad?s=128

Craig Kerstiens

July 18, 2012
Tweet

Transcript

  1. Django Apps to Services

  2. Craig Kerstiens @craigkerstiens work at @heroku

  3. Project A collection of configuration and apps for a particular

    Website. (per Django Project) Django
  4. Project App A collection of configuration and apps for a

    particular Website. (per Django Project) Django
  5. Project App A collection of configuration and apps for a

    particular Website. A web application that does something. I.e. Weblog, Poll, Ticket system (per Django Project) Django
  6. Table Table Table Table Table Table Table Table Table Table

    Table Table Table Table Table Table Table Table Table Table Table
  7. Table Table Table Table Table Table Table Table Table Table

    Table Table Table Table Table Table Table Table Table Table Table
  8. Table Table Table Table Table Table Table Table Table Table

    Table Table Table Table Table Table Table Table Table Table Table App
  9. Within Django

  10. Project Within Django

  11. Project App App App Within Django

  12. Project App App App Tickets FAQ FaqCreator Within Django

  13. Project App App App Tickets FAQ FaqCreator Within Django cd

    myproject && find . manage.py requirements.txt settings.py urls.py ./faq/admin.py ./faq/forms.py ./faq/models.py ./faq/urls.py ./faq/views.py ./faqcreator/admin.py ./faqcreator/forms.py ./faqcreator/models.py ./faqcreator/urls.py ./faqcreator/views.py ./tickets/admin.py ./tickets/forms.py ./tickets/models.py ./tickets/urls.py ./tickets/views.py
  14. Reusability

  15. cd myproject && find . Reusability

  16. cd myproject && find . manage.py requirements.txt settings.py urls.py ./faq/admin.py

    ./faq/forms.py ./faq/models.py ./faq/urls.py ./faq/views.py ./faqcreator/admin.py ./faqcreator/forms.py ./faqcreator/models.py ./faqcreator/urls.py ./faqcreator/views.py ./tickets/admin.py ./tickets/forms.py ./tickets/models.py ./tickets/urls.py ./tickets/views.py Reusability
  17. cd myproject && find . cd myproject && find .

    manage.py requirements.txt settings.py urls.py ./faq/admin.py ./faq/forms.py ./faq/models.py ./faq/urls.py ./faq/views.py ./faqcreator/admin.py ./faqcreator/forms.py ./faqcreator/models.py ./faqcreator/urls.py ./faqcreator/views.py ./tickets/admin.py ./tickets/forms.py ./tickets/models.py ./tickets/urls.py ./tickets/views.py --> Reusability
  18. cd myproject && find . manage.py requirements.txt settings.py urls.py cd

    myproject && find . manage.py requirements.txt settings.py urls.py ./faq/admin.py ./faq/forms.py ./faq/models.py ./faq/urls.py ./faq/views.py ./faqcreator/admin.py ./faqcreator/forms.py ./faqcreator/models.py ./faqcreator/urls.py ./faqcreator/views.py ./tickets/admin.py ./tickets/forms.py ./tickets/models.py ./tickets/urls.py ./tickets/views.py --> Reusability
  19. cd myproject && find . manage.py requirements.txt settings.py urls.py cat

    myproject/requirements.txt cd myproject && find . manage.py requirements.txt settings.py urls.py ./faq/admin.py ./faq/forms.py ./faq/models.py ./faq/urls.py ./faq/views.py ./faqcreator/admin.py ./faqcreator/forms.py ./faqcreator/models.py ./faqcreator/urls.py ./faqcreator/views.py ./tickets/admin.py ./tickets/forms.py ./tickets/models.py ./tickets/urls.py ./tickets/views.py --> Reusability
  20. cd myproject && find . manage.py requirements.txt settings.py urls.py cat

    myproject/requirements.txt faq==0.1 faqcreator==0.1 tickets==0.1 cd myproject && find . manage.py requirements.txt settings.py urls.py ./faq/admin.py ./faq/forms.py ./faq/models.py ./faq/urls.py ./faq/views.py ./faqcreator/admin.py ./faqcreator/forms.py ./faqcreator/models.py ./faqcreator/urls.py ./faqcreator/views.py ./tickets/admin.py ./tickets/forms.py ./tickets/models.py ./tickets/urls.py ./tickets/views.py --> Reusability
  21. None
  22. REUSABILITY means faster features due to DRY (Don’t Repeat Yourself)

  23. REUSABILITY means faster features due to DRY (Don’t Repeat Yourself)

    REUSABILITY does not always mean SCALABILITY or MAINTAINABILITY
  24. REUSABILITY means faster features due to DRY (Don’t Repeat Yourself)

    REUSABILITY does not always mean SCALABILITY or MAINTAINABILITY
  25. Project App A collection of configuration and apps for a

    particular Website. A web application that does something. I.e. Weblog, Poll, Ticket system (per Django Project) Django
  26. Project App A collection of configuration and apps for a

    particular Website. A web application that does something. I.e. Weblog, Poll, Ticket system (per Django Project) Django
  27. Project App A collection of configuration and apps for a

    particular Website. A web application that does something. I.e. Weblog, Poll, Ticket system Django Service Method of communication over the web. Web APIs allow combination of multiple services
  28. None
  29. Tech imitate Teams Project App App App Tickets FAQ FaqCreator

    Company Support Knowledge Base
  30. Support Knowledge Base Teams

  31. App App Support Knowledge Base Teams Grow

  32. App App Support Knowledge Base Billing Teams Grow

  33. App App Support Knowledge Base Billing Marketing Teams Grow

  34. App App Support Knowledge Base Billing Marketing Analytics Mobile API

    Front End Social Teams Grow
  35. App App App Support Knowledge Base Billing Apps Grow Marketing

    Analytics Mobile API Front End Social 3 Apps
  36. App App App Support Knowledge Base Billing Apps Grow App

    App App Marketing Analytics Mobile App App App API Front End Social 9 Apps
  37. Support Knowledge Base Billing Apps Grow Marketing Analytics Mobile API

    Front End Social 9 Apps 1 Codebase
  38. SOA To the Rescue

  39. SOA To the Rescue

  40. SOA To the Rescue

  41. Defined contract for communicating Service

  42. Defined contract for communicating Service $ curl -O $FAQ_API/create/ -X

    “question=my\ question source=123”
  43. In Python

  44. In Python data = { ‘question’: “my question”, ‘source’: 123

    } requests.POST(os.environ[‘FAQ_API’] + ‘/create/’, data=data)
  45. Version Bump data = { ‘question’: “my question”, ‘source’: 123,

    ‘related’: [456, 789] } requests.POST(os.environ[‘FAQ_API’] + ‘/v2/create’, data=data)
  46. Version Bump data = { ‘question’: “my question”, ‘source’: 123,

    ‘related’: [456, 789] } requests.POST(os.environ[‘FAQ_API’] + ‘/v2/create’, data=data)
  47. Version Bump data = { ‘question’: “my question”, ‘source’: 123,

    ‘related’: [456, 789] } requests.POST(os.environ[‘FAQ_API’] + ‘/v2/create’, data=data) STILL VALID requests.POST(os.environ[‘FAQ_API’] + ‘/v1/create’, data=data)
  48. What’s a service Provider API_HOST= http://127.0.0.1

  49. What’s a service Provider Endpoint API_HOST= http://127.0.0.1 /v1/create/

  50. What’s a service Provider Endpoint API_HOST= http://127.0.0.1 /v1/create/ Contract {

    ‘question’: ‘foo bar’, ‘source’: 123 }
  51. Service App

  52. Service App Models Views URLs Provider Endpoint Contract

  53. A SERVICE means REUSABILITY and enables SCALABILITY and MAINTAINABILITY

  54. A SERVICE means REUSABILITY and enables SCALABILITY and MAINTAINABILITY

  55. In the real world

  56. In the real world

  57. In the real world Install Sentry

  58. In the real world Install Sentry Send lots of data

  59. In the real world Install Sentry Send lots of data

    ...........
  60. In the real world Install Sentry Send lots of data

    ........... Crash sentry
  61. In the real world Install Sentry Send lots of data

    ........... Crash sentry ...........
  62. In the real world Install Sentry Send lots of data

    ........... Crash sentry ........... Scale sentry
  63. In the real world Install Sentry Send lots of data

    ........... Crash sentry ........... Scale sentry ...........
  64. In the real world Install Sentry Send lots of data

    ........... Crash sentry ........... Scale sentry ........... Some time later, scale the app you build
  65. In the real world Install Sentry Send lots of data

    ........... Crash sentry ........... Scale sentry ........... Some time later, scale the app you build VS
  66. In the real world Install Sentry Send lots of data

    ........... Crash sentry ........... Scale sentry ........... Some time later, scale the app you build Install Sentry VS
  67. In the real world Install Sentry Send lots of data

    ........... Crash sentry ........... Scale sentry ........... Some time later, scale the app you build Install Sentry Send lots of data to Sentry Service VS
  68. In the real world Install Sentry Send lots of data

    ........... Crash sentry ........... Scale sentry ........... Some time later, scale the app you build Install Sentry Send lots of data to Sentry Service Let David Cramer scale Sentry VS
  69. App App App Support Knowledge Base Billing Where to Start

    App App App Marketing Analytics Mobile App App App API Front End Social
  70. App App Support Knowledge Base Billing Where to Start App

    Marketing Analytics Mobile App API Front End Social
  71. None
  72. None
  73. None
  74. None
  75. None
  76. None
  77. None
  78. None
  79. Service App

  80. Service App Models Views URLs Provider Endpoint Contract

  81. Take aways

  82. Take aways 1. Start non-critical (Cheat) 2. Create services where

    theres pain 3. Start small
  83. Fin. Resources http://www.craigkerstiens.com http://bit.ly/djangoappstoservices http://www.12factor.net