Slide 1

Slide 1 text

NYC 18 July 2012 Beyond Toys Deploying a Production Node.js App to the Cloud Friday, July 20, 12

Slide 2

Slide 2 text

Beyond Toys I. Who the hell am I? II. The Five Stages of Grief III. The General Solution IV. Questions Friday, July 20, 12

Slide 3

Slide 3 text

Who the hell am I? Friday, July 20, 12

Slide 4

Slide 4 text

Hunter Loftis Director of Technology, Skookum Digital Works Charlotte, NC HTML5 mobile web JavaScript node.js 2 large, multi-server deployments 3 more in staging @hunterloftis [email protected] Friday, July 20, 12

Slide 5

Slide 5 text

Friday, July 20, 12

Slide 6

Slide 6 text

...In our experience (YMMV - Windows Azure, nodester, and a million more aren’t covered here) Flexible Abstract Affordable Friday, July 20, 12

Slide 7

Slide 7 text

The Five Stages of (node.js) Grief Friday, July 20, 12

Slide 8

Slide 8 text

1. Denial You’re happily writing node apps, pretending you have some idea how to publish them. Friday, July 20, 12

Slide 9

Slide 9 text

2. Anger You try to publish, only to discover that nobody else understands this any better. Friday, July 20, 12

Slide 10

Slide 10 text

3. Bargaining If your Macguyver-ed server just stays up, you promise to do better next time! Friday, July 20, 12

Slide 11

Slide 11 text

4. Depression You realize you’re building a house of cards. There’s no way this is sustainable. Friday, July 20, 12

Slide 12

Slide 12 text

5. Acceptance You’re ready to give cloud architecture and 12-Factor a try. Friday, July 20, 12

Slide 13

Slide 13 text

The General Solution Friday, July 20, 12

Slide 14

Slide 14 text

Friday, July 20, 12

Slide 15

Slide 15 text

12-Factor TL;DR An app should have a single, version-controlled codebase, decoupled from declarative configuration and services, which is built by a developer and run by a machine as stateless, crash-only processes. Services should emerge from port binding, concurrency from processes, and logs from standard streams. Dev and prod environments should be as similar as possible, and admin tasks should be one-off processes. Friday, July 20, 12

Slide 16

Slide 16 text

I. A Single Codebase git + git push (or pull) Friday, July 20, 12

Slide 17

Slide 17 text

II. Dependencies $ package.json / shrinkwrap.json -- also, use node_modules/.bin/* Friday, July 20, 12

Slide 18

Slide 18 text

III. Config JSON outside of the git repository (a departure from the suggestion of ENV variables) Friday, July 20, 12

Slide 19

Slide 19 text

IV. Backing Services No distinction between local and 3rd-party services - mongodb, redis, amazon aws, etc Friday, July 20, 12

Slide 20

Slide 20 text

V. Build, release run make build, git push (/pull), npm start Friday, July 20, 12

Slide 21

Slide 21 text

VI. Processes stateless (no memory store!) and share-nothing (no message passing!) Friday, July 20, 12

Slide 22

Slide 22 text

VII. Port Binding node handles this by default with its built-in http server (vs PHP/apache, Java/Tomcat) Friday, July 20, 12

Slide 23

Slide 23 text

VIII. Concurrency foreman + upstart + one .js file per process type Friday, July 20, 12

Slide 24

Slide 24 text

IX. Disposability require(‘cluster’). Store nothing in the process. Start up quickly. Crash-only design. Friday, July 20, 12

Slide 25

Slide 25 text

X. Dev/Prod Parity Knock off the knockoffs! Use the real deal. Mirror backing services in dev and prod. Friday, July 20, 12

Slide 26

Slide 26 text

XI. Logs Be lazy with logs. Use stdout (console.log). Friday, July 20, 12

Slide 27

Slide 27 text

XII. Admin Processes Script outside of your app process. SSH -- #!/usr/bin/env bash -- #!/usr/bin/env node Friday, July 20, 12

Slide 28

Slide 28 text

Thank you! Questions? • http://12factor.net • https://github.com/Skookum/cloudChat • https://github.com/skookum/base12 • https://github.com/skookum/nimbus • https://github.com/skookum/mason • @hunterloftis @skookum • [email protected] Friday, July 20, 12