Slide 1

Slide 1 text

SECRETS OF A NODE TEAM The highs and lows a node.js agency

Slide 2

Slide 2 text

PAUL SERBY CTO of Clock @serby

Slide 3

Slide 3 text

IDEAS + CRAFT

Slide 4

Slide 4 text

we make websites

Slide 5

Slide 5 text

do you code?

Slide 6

Slide 6 text

WHY NODE

Slide 7

Slide 7 text

WHY NODE ‣ 10 years doing PHP

Slide 8

Slide 8 text

WHY NODE ‣ 10 years doing PHP ‣ Waited 3 years for PHP 6

Slide 9

Slide 9 text

WHY NODE ‣ 10 years doing PHP ‣ Waited 3 years for PHP 6 ‣ Frameworks V2.0 starting to appear

Slide 10

Slide 10 text

WHY NODE ‣ 10 years doing PHP ‣ Waited 3 years for PHP 6 ‣ Frameworks V2.0 starting to appear ‣ Blocking IO was consistently our main bottleneck at scale

Slide 11

Slide 11 text

WHY NODE ‣ 10 years doing PHP ‣ Waited 3 years for PHP 6 ‣ Frameworks V2.0 starting to appear ‣ Blocking IO was consistently our main bottleneck at scale ‣ Bored of PHP

Slide 12

Slide 12 text

2011

Slide 13

Slide 13 text

SUN PERKS 154,359 Registrations Ran for 3 months Peaking at 250 entries per second

Slide 14

Slide 14 text

SUN PERKS - PROFIT 40%

Slide 15

Slide 15 text

PAIN NPM version mis-match

Slide 16

Slide 16 text

PAIN NPM version mis-match SOLUTION

Slide 17

Slide 17 text

PAIN NPM version mis-match Check node_modules packages into GIT http://www.futurealoof.com/posts/nodemodules-in-git.html SOLUTION

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

npm rebuild

Slide 20

Slide 20 text

PROPER SOLUTION

Slide 21

Slide 21 text

PROPER SOLUTION npm shrinkwrap

Slide 22

Slide 22 text

PROPER SOLUTION npm shrinkwrap npm install --save

Slide 23

Slide 23 text

PROPER SOLUTION npm shrinkwrap npm install --save npm install --save && npm shrinkwrap

Slide 24

Slide 24 text

Semantic Versioning 2.0.0

Slide 25

Slide 25 text

Semantic Versioning 2.0.0 MAJOR . MINOR . PATCH

Slide 26

Slide 26 text

Semantic Versioning 2.0.0 MAJOR . MINOR . PATCH MAJOR version when you make incompatible API changes

Slide 27

Slide 27 text

Semantic Versioning 2.0.0 MAJOR . MINOR . PATCH MAJOR version when you make incompatible API changes MINOR version when you add backwards-compatible functionality

Slide 28

Slide 28 text

Semantic Versioning 2.0.0 MAJOR . MINOR . PATCH MAJOR version when you make incompatible API changes MINOR version when you add backwards-compatible functionality PATCH version when you make backwards-compatible bug fixes

Slide 29

Slide 29 text

Semantic Versioning 2.0.0 MAJOR . MINOR . PATCH MAJOR version when you make incompatible API changes MINOR version when you add backwards-compatible functionality PATCH version when you make backwards-compatible bug fixes http://semver.org

Slide 30

Slide 30 text

PAIN

Slide 31

Slide 31 text

PAIN I don’t know how to build big applications

Slide 32

Slide 32 text

Most modules should have exactly 1 export. Module systems should be designed around that use case first, not for dozens of exports. substack if your module exposes more than one function, you might be doing it wrong :) mikeal

Slide 33

Slide 33 text

Coincidental Logical Temporal Procedural Communicational Sequential Functional COHESION WORST BEST

Slide 34

Slide 34 text

IDEs vs Text Editors 2010 2013 95% 10% 5% 90% IDEs Editors

Slide 35

Slide 35 text

SEPARATION

Slide 36

Slide 36 text

SEPARATION ‣ Craft your application by combining modules

Slide 37

Slide 37 text

SEPARATION ‣ Craft your application by combining modules ‣ Build as many applications as you need

Slide 38

Slide 38 text

SEPARATION ‣ Craft your application by combining modules ‣ Build as many applications as you need ‣ Your web server is a web server it’s not a: CSS compiler, JavaScript compiler, Message queue, Email dispatcher, Certainly not cron!

Slide 39

Slide 39 text

SEPARATION ‣ Craft your application by combining modules ‣ Build as many applications as you need ‣ Your web server is a web server it’s not a: CSS compiler, JavaScript compiler, Message queue, Email dispatcher, Certainly not cron! ‣ Ensure your applications and processes can talk to each other

Slide 40

Slide 40 text

two years later

Slide 41

Slide 41 text

LOAD BALANCER CDN WEB SITE REST API TEMPORAL AGENTS (CRON) CMS ADMIN REST API WORKERS NPM APPS DOMAIN SERVICES 3rd PARTY MODULES PROJECT MODULES

Slide 42

Slide 42 text

LOAD BALANCER CDN WEB SITE REST API TEMPORAL AGENTS (CRON) CMS ADMIN REST API WORKERS APPS MESSAGE BUS (0MQ)

Slide 43

Slide 43 text

MAY 2013

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

JUNE 2013

Slide 46

Slide 46 text

AUGUST 2013

Slide 47

Slide 47 text

SUN PERKS - PROFIT 33%

Slide 48

Slide 48 text

PAIN

Slide 49

Slide 49 text

PAIN ‣ NPM isn’t always available

Slide 50

Slide 50 text

PAIN ‣ NPM isn’t always available ‣ NPM can be slow

Slide 51

Slide 51 text

PAIN ‣ NPM isn’t always available ‣ NPM can be slow ‣ No SLA

Slide 52

Slide 52 text

PAIN ‣ NPM isn’t always available ‣ NPM can be slow ‣ No SLA ‣ Deployments depend on NPM

Slide 53

Slide 53 text

PAIN ‣ NPM isn’t always available ‣ NPM can be slow ‣ No SLA ‣ Deployments depend on NPM ‣ Some of our code needs to be private

Slide 54

Slide 54 text

PAIN ‣ NPM isn’t always available ‣ NPM can be slow ‣ No SLA ‣ Deployments depend on NPM ‣ Some of our code needs to be private ‣ ‘npm update’ doesn’t work with git URLs

Slide 55

Slide 55 text

SOLUTION

Slide 56

Slide 56 text

SOLUTION Private NPM Repo

Slide 57

Slide 57 text

SOLUTION Private NPM Repo http://clock.co.uk/tech-blogs/how-to-create-a-private-npmjs-repository

Slide 58

Slide 58 text

JOY

Slide 59

Slide 59 text

JOY browserify

Slide 60

Slide 60 text

PAIN

Slide 61

Slide 61 text

PAIN MEMORY LEAKS

Slide 62

Slide 62 text

SOLUTION

Slide 63

Slide 63 text

SOLUTION ‣ Learn the tools

Slide 64

Slide 64 text

SOLUTION ‣ Learn the tools ‣ dtrace / Manta

Slide 65

Slide 65 text

SOLUTION ‣ Learn the tools ‣ dtrace / Manta ‣ heap-dump - https://github.com/bnoordhuis/node-heapdump

Slide 66

Slide 66 text

SOLUTION ‣ Learn the tools ‣ dtrace / Manta ‣ heap-dump - https://github.com/bnoordhuis/node-heapdump ‣ Assume there are always memory leaks

Slide 67

Slide 67 text

SOLUTION ‣ Learn the tools ‣ dtrace / Manta ‣ heap-dump - https://github.com/bnoordhuis/node-heapdump ‣ Assume there are always memory leaks ‣ Monitor memory

Slide 68

Slide 68 text

SOLUTION ‣ Learn the tools ‣ dtrace / Manta ‣ heap-dump - https://github.com/bnoordhuis/node-heapdump ‣ Assume there are always memory leaks ‣ Monitor memory ‣ Make sure your application restarts quickly

Slide 69

Slide 69 text

SOLUTION ‣ Learn the tools ‣ dtrace / Manta ‣ heap-dump - https://github.com/bnoordhuis/node-heapdump ‣ Assume there are always memory leaks ‣ Monitor memory ‣ Make sure your application restarts quickly ‣ Restart your application nightly

Slide 70

Slide 70 text

is node.js any good?

Slide 71

Slide 71 text

thanks