34
Node.js in Production - | Seattle Node.js May 8th, 2013 Ryan Roemer @ryan_roemer

Node.js in Production

Embed Size (px)

DESCRIPTION

The good, the bad, and the ugly technical details of running Node.js services for the world’s largest Spanish learning website, SpanishDict.com. Presented at the 5/8/2013 Seattle Node.js Meetup - http://www.meetup.com/Seattle-Node-js/events/115959992/

Citation preview

Page 1: Node.js in Production

Node.js inProduction

-

|

Seattle Node.js

May 8th, 2013

Ryan Roemer @ryan_roemer

Page 2: Node.js in Production

OverviewProduction!

Well, what our production looks like.

Five Node.js-related things we'velearned.

Some additional resources.

Page 3: Node.js in Production

What is"Production"?

Page 5: Node.js in Production

Brought to youby...

A team of three engineers

Who are full-time developers

Running everything in the cloud

With minimal time available for ops

Page 7: Node.js in Production

Demo

Page 8: Node.js in Production

A Spanish-EnglishDictionary

is the world’slargest Spanish-English dictionary,translation, and language learningwebsite. We develop and providereliable, accurate, easy-to-useresources for learning Spanish.

SpanishDict.com

Page 9: Node.js in Production

Our visitorsA into our data and usage:

6,000,000 Unique visitors every month

1,000,000 Translations

100,000 Questions and answers

25,000 Flashcards

5,000 Video pronunciations

90 Lessons

quick glance

Page 10: Node.js in Production

Our Services

Node Other

API server Web site

Auto-suggest server Data mining

Translation server Operations

Text-to-speech server

Page 11: Node.js in Production

Our TrafficVery low latency for our db-backed

services.

Service Reqs/min

API server 35K / min

Auto-suggest server 15K / min

Translation server 2.5K / min

Text-to-speech server 400 / min

Page 12: Node.js in Production

Five Node.jsproduction tips

1. Know when to Node2. Keep up with Node3. Design for failure4. Isolate services5. Analyze everything

Page 13: Node.js in Production

1. Know when toNode

Should you use Node.js?

Page 14: Node.js in Production

YesSmall apps (think JSON APIs)

"Glue" for services or data

Proxies

Concurrent data

Use the module

Lots of connections

stream

Page 15: Node.js in Production

Maybe notComputation

Legacy applications

"Solved" problems (fuzzy search, NLP,etc.)

Page 16: Node.js in Production

2. Keep up withNode

Bleeding edge, lots of breakage.Stay up to date with Node.js and libraries.

Page 18: Node.js in Production

Node.jsdeployments

PAAS: Often, the easier way.

, , , etc.

IAAS: Expect some DIY

Build custom Node.js versions

Install modules from scratch

Get ready to roll back

Joyent Heroku Nodejitsu

Page 19: Node.js in Production

3. Design for failureFail and recover at multiple levels.

Page 20: Node.js in Production

App-levelErrors

Handle: uncaughtExceptionListen: foo.on("error")

Use the module

Workers: die early on errors

Master: monitor and kill workers

cluster

Page 21: Node.js in Production

Server-levelUse or alternatives

Restart the Node.js master

monit

Page 22: Node.js in Production

Service-levelHave lots of small apps

Stateless, fungible servers

Hot failover wherever possible

Page 23: Node.js in Production

4. Isolate servicesSeparate resource and failure classes.

Page 24: Node.js in Production

ResourcesCPU/Load: Run out of this and it's over.

Also, memory, I/O, etc.

... and combinations thereof

Page 25: Node.js in Production

Our painsNode.js apps aren't necessarily good

neighbors.

Suggest (DB) and translate (http)

Backend (DB) and web site (CPU/load,memory)

Read and write servers

Page 26: Node.js in Production

TakeawaysAlways preserve CPU

Monitor system stats for cross-pressure

Page 27: Node.js in Production

5. Analyzeeverything

How well are we addressing lessons 1-4?Data drives problem discovery and action.

Page 29: Node.js in Production

Things to look forSome metrics that affect Node.js apps

Type Metrics Uses

System CPU, I/O, memory,network

Alert

Server Throughput, latency Alert,Report

Traffic Peaks (weeks,months)

Report

Errors Quantitative,qualitative

Alert,Report

Page 30: Node.js in Production

Decisions, GoalsIdentify

Resource pressure

Bugs

Decide

Scale up, scale down?

Separate?

Page 31: Node.js in Production

Demo

Page 32: Node.js in Production

Recap1. Know when to Node2. Keep up with Node3. Design for failure4. Isolate services5. Analyze everything

Page 34: Node.js in Production

Thanks! | Ryan Roemer @ryan_roemer

@SeattleNode

Ryan Roemer
Ryan Roemer