how to deploy node to production

51
HOW TO DEPLOY NODE without getting fired

Upload: sean-hess

Post on 05-Dec-2014

14.250 views

Category:

Technology


2 download

DESCRIPTION

 

TRANSCRIPT

Page 1: How to deploy node to production

HOW TO DEPLOY NODEwithout getting fired

Page 2: How to deploy node to production

@seanhess

seanhess.github.com

Page 3: How to deploy node to production
Page 5: How to deploy node to production

WHOARE

YOU?

Page 6: How to deploy node to production

from FIRST STEPSto MISSTEPS

toSCALE

Page 7: How to deploy node to production

Ratinatorlywho RATES the RATE-MEN?

Page 8: How to deploy node to production

100,000

SALARY is for chumps

shares of sweat-equity

Page 9: How to deploy node to production

you decide to try

Page 10: How to deploy node to production

Your First Node“but my brother says that .NET is the best

language”

Page 11: How to deploy node to production

var express = require('express')var app = express.createServer()

app.get('/', function(req, res) { res.send("Hello World!")})

app.listen(3333)console.log("Listening on 3333")

Page 12: How to deploy node to production

your app is aLONG RUNNINGPROCESS

it handles all the requests...if it’s on

Page 13: How to deploy node to production

“Sequoia is going to LOVE this”

PROTOTYPEthemust be ONLINE

Page 14: How to deploy node to production

FAIL SHARED HOSTING

PROGRAMyou need to run a

*

Page 15: How to deploy node to production

WIN!VPSlike a cheap

DEDICATED SERVER

Page 16: How to deploy node to production

sudo make me a serverokay...

Page 17: How to deploy node to production
Page 18: How to deploy node to production
Page 19: How to deploy node to production
Page 20: How to deploy node to production
Page 21: How to deploy node to production

> ssh [email protected]@ratinatorly's password:Welcome to Ubuntu 11.04 (GNU/Linux 2.6.38-8-virtual

# adduser node# adduser node sudo

# sudo apt-get install python-software-properties# sudo apt-add-repository ppa:chris-lea/node.js# sudo apt-get update# sudo apt-get install nodejs npm

Page 22: How to deploy node to production

• copy our code

• node app.js

MAKE IT GO

Page 23: How to deploy node to production

“I didn’t do anything... Check Energy Saver”

DON’Tthe

CLOSELID!!

Page 24: How to deploy node to production

your BELONGSto your

ssh session

DIELOG OUT ==

app

Page 25: How to deploy node to production

LOGGED INkeeps you

SCREEN

Page 26: How to deploy node to production

Undo! Rollback!“I know enough HTML to be

dangerous”

your boss tries to deploy

Page 27: How to deploy node to production

let’s add

use GIT to deploy

VERSION CONTROL

Page 28: How to deploy node to production

package.jsonDEPENDENCIESmanage your

> npm install

Page 29: How to deploy node to production

a PROCESS emerges• git commit and push

• log in to server

• pull

• npm install

• restart

Page 30: How to deploy node to production

“I’ve got Techcrunch right where I want them”

LAUNCH!

Page 31: How to deploy node to production

port 80

•must run as root

Page 32: How to deploy node to production

This is where I stop trying to design my slides

Page 33: How to deploy node to production

It keeps DYING!

“Maybe we should try windows servers instead”

Page 34: How to deploy node to production

upstart

•OS will start on boot

•Respawn

Page 35: How to deploy node to production

monitoring

•know if it goes down

Page 36: How to deploy node to production

It works for me!or, when the cracks first

began to show...

Page 37: How to deploy node to production

logging

• keep your output

Page 38: How to deploy node to production

uncaughtExceptionprocess.on(“uncaughtException”, function(err) {

console.log(err.message)})

Page 39: How to deploy node to production

Don’t forget step 6!

“Will you put my changes up for me?”

Page 40: How to deploy node to production

complicated deploy

• it can get easy to miss a step

Page 41: How to deploy node to production

automated• keep the knowledge in your code

base

• put extra stuff in package.json “install”

Page 42: How to deploy node to production

Too Slow!“Let’s just throw more

money at this"

Page 43: How to deploy node to production

Multiple Processes

• cluster up to your cores

Page 44: How to deploy node to production

Varnish Cache

• avoid repeating work

• set headers and go

sudo apt-get install varnishsudo vim /etc/default/varnish # port 80sudo vim /etc/varnish/default.vcl # point to our app at port 3333sudo /etc/init.d/varnish start

Page 45: How to deploy node to production

Staging Box

Page 46: How to deploy node to production

cheat with Heroku

• it’s easy, but can be expensive

Page 47: How to deploy node to production

Scale“We should aim for... 100

million users”

Page 48: How to deploy node to production

Multiple Servers• more app servers

• varnish and db on separate box

• use node-control to deploy

• smart db = good for a long time

Page 49: How to deploy node to production

automateandUPSTART GIT

or CHEATwithHEROKU

rememberwith

Page 50: How to deploy node to production

@seanhessseanhess.github.com

Page 51: How to deploy node to production

> npm install express...> lsapp.js node_modules> node app.js Listening on 3333