going node at netflix
DESCRIPTION
Slides from my talk "Going Node at Netflix" talk where I talk a bit about how we built a Node.js application at Netflix.TRANSCRIPT
![Page 1: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/1.jpg)
Going
at
![Page 2: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/2.jpg)
About Me
Senior UI Engineer At Netflix!
@bittersweetryan
![Page 3: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/3.jpg)
![Page 4: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/4.jpg)
![Page 5: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/5.jpg)
![Page 6: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/6.jpg)
The Rest!44%
FacebookBitTorrent
iTunes
YouTube!13%
Netflix!34%
Peak Downstream Traffic 1H 2014
https://www.sandvine.com/downloads/general/global-internet-phenomena/2014/1h-2014-global-internet-phenomena-report.pdf
![Page 7: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/7.jpg)
"MS Freedom of the Seas in its maiden voyage" by Andres Manuel Rodriguez -
We have this
Stable
![Page 8: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/8.jpg)
"MS Freedom of the Seas in its maiden voyage" by Andres Manuel Rodriguez -
We have this
Full Featured
![Page 9: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/9.jpg)
"MS Freedom of the Seas in its maiden voyage" by Andres Manuel Rodriguez -
We have this
Needs a diverse crew
![Page 10: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/10.jpg)
"MS Freedom of the Seas in its maiden voyage" by Andres Manuel Rodriguez -
We have this
Not very agile
![Page 11: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/11.jpg)
"Lewis Hamilton 2014 China Race" by emperornie
We want this
![Page 12: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/12.jpg)
…but not for the reason you think
Modular
![Page 13: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/13.jpg)
…but not for the reason you think
Lightweight
![Page 14: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/14.jpg)
…but not for the reason you think
Very Agile
![Page 15: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/15.jpg)
Shakti
![Page 16: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/16.jpg)
Why Node?
![Page 17: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/17.jpg)
UI Engineers Write the JavaScript They Love
![Page 18: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/18.jpg)
Node is the New UI Layer
Client
Node Request Time HTML
Post Request HTML
Service Calls
Client JS
Services
Build Process
![Page 19: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/19.jpg)
The event loop fits our needs well
![Page 20: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/20.jpg)
The Node Event Loop
http://blog.carbonfive.com/2013/10/27/the-javascript-event-loop-explained/
function contextMiddleware( req, res, next ){ var movieId = req.params.movieId || 0; movie.fetch( movieId, function( movieData ){ res.set( { movieData : movieData } ) next(); } ); }
![Page 21: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/21.jpg)
The Node Event Loop
http://blog.carbonfive.com/2013/10/27/the-javascript-event-loop-explained/
function contextMiddleware( req, res, next ){ var movieId = req.params.movieId || 0; movie.fetch( movieId, function( movieData ){ res.set( { movieData : movieData } ) next(); } ); }
![Page 22: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/22.jpg)
The Node Event Loop
http://blog.carbonfive.com/2013/10/27/the-javascript-event-loop-explained/
function contextMiddleware( req, res, next ){ var movieId = req.params.movieId || 0; movie.fetch( movieId, function( movieData ){ res.set( { movieData : movieData } ) next(); } ); }
![Page 23: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/23.jpg)
The Node Event Loop
http://blog.carbonfive.com/2013/10/27/the-javascript-event-loop-explained/
function contextMiddleware( req, res, next ){ var movieId = req.params.movieId || 0; movie.fetch( movieId, function( movieData ){ res.set( { movieData : movieData } ) next(); } ); }
![Page 24: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/24.jpg)
Allowed us to remove many runtime dependencies
![Page 25: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/25.jpg)
Shakti was built with a few core principals
![Page 26: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/26.jpg)
Embrace the JavaScript Ecosystem.
![Page 27: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/27.jpg)
Embrace the JavaScript Ecosystem.
express web application framework for node
![Page 28: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/28.jpg)
Embrace the JavaScript Ecosystem.
![Page 29: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/29.jpg)
Embrace the JavaScript Ecosystem.
{dust}
![Page 30: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/30.jpg)
Embrace the JavaScript Ecosystem.
![Page 31: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/31.jpg)
Use Existing Infrastructure
Jasori Lewis
![Page 32: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/32.jpg)
Simple API, Reduce Depencencies
http://www.launchphotography.com/Discovery_Flight_Deck.html
![Page 33: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/33.jpg)
http://www.launchphotography.com/Discovery_Flight_Deck.html
Simplify By Removing Dependencies
![Page 34: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/34.jpg)
We do have a few unique challenges
http://sjmagazine.net/wp-content/uploads/2014/07/NUP_163855_0336.jpg
![Page 35: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/35.jpg)
Assets
http://www.wired.com/wp-content/uploads/blogs/wiredenterprise/wp-content/uploads/2012/10/ff_googleinfrastructure_large.jpg
![Page 36: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/36.jpg)
Templating / i18n
http://2.bp.blogspot.com/-4KCTn2jSdU0/TlZFNNwofPI/AAAAAAAAFc0/K0ogqSByYlY/s1600/IMG_5947.JPG
![Page 37: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/37.jpg)
Middle Tier Services
![Page 38: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/38.jpg)
Build Process
http://3.bp.blogspot.com/-o-LcrSq_w1o/T1ywq9G57gI/AAAAAAAACQU/sRYxh6A6fBA/s1600/P1120378.jpg
![Page 39: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/39.jpg)
Modules
http://www.launchphotography.com/Discovery_Flight_Deck.html
commonjs
![Page 40: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/40.jpg)
Modules
http://www.launchphotography.com/Discovery_Flight_Deck.html
es6
![Page 41: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/41.jpg)
Modules
http://www.launchphotography.com/Discovery_Flight_Deck.html
NPM
![Page 42: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/42.jpg)
We Learned A Few Things On Our Journey
http://i.huffpost.com/gen/951056/thumbs/o-CANADA-LIGHT-BULB-BAN-facebook.jpg
![Page 43: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/43.jpg)
Nothing Is Ever Done
![Page 44: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/44.jpg)
Engineers are opinionated creative.
![Page 45: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/45.jpg)
Automate as many things is you can
![Page 46: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/46.jpg)
Allow for diverse inputs, always have predictable outputs
![Page 47: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/47.jpg)
function getLocalizedStrings( arrayOrBundle, key, callback ){ if( arrayOrBundle.isArray() ){ return new Promise( function( resolve, reject ){ //return localized object } ); } else if( typeof arrayOrBundle === ‘string’ ){ return new Promise( function( resolve, reject ){ //return localized object } ); } }
![Page 48: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/48.jpg)
Keep async API’s async
![Page 49: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/49.jpg)
function getLocalizedString( package, key, callback ){ if( this.cache[ package ] && this.cache[ package ][ key ] ){ callback( this.cache[ package ][ key ] ); //not async } else{ this.getString( package, key, callback ); //async call } }
![Page 50: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/50.jpg)
function getLocalizedString( package, key, callback ){ if( this.cache[ package ] && this.cache[ package ][ key ] ){ setTimeout( function( ){ callback( this.cache[ package ][ key ] ); }, 0 ); } else{ this.getString( package, key, callback ); } }
![Page 51: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/51.jpg)
Questions
http://eugenebrandt.files.wordpress.com/2013/09/hands-voting.jpg
![Page 52: Going Node At Netflix](https://reader034.vdocuments.us/reader034/viewer/2022051411/547de6a8b379596f2b8b5360/html5/thumbnails/52.jpg)
Thank You!
Please stop me in the halls and talk to me about all the cool things Netflix is doing with JavaScript! I love to talk about this stuff!