SlideShare a Scribd company logo
1 of 19
Download to read offline
node.js in action
Learnings from Cisco
Karan & Sneha
ThoughtWorks
Saturday, 24 August 13
node.js ?
• JavaScript is not jQuery
• Created by Ryan Dahl utilizing the Google
V8 JavaScript engine
• Has evented I/O as part of its arsenal
Saturday, 24 August 13
Tech Stack
• Express (web framework)
• Sequelize (ORM)
• Gruntjs (task runner)
• coffee-resque (background jobs and queues)
• Q (callback sanity)
• Mocha/Sinon/Chai (TDD)
Saturday, 24 August 13
Callback Hell!
• Avoid like the plague
• Can suck all the fun out of writing
JavaScript (everywhere)
• Waiting for returns across logical
boundaries is almost impossible
• Senthil/Kuldeep cover this area in a lot
more detail right after this talk
Saturday, 24 August 13
Example
Saturday, 24 August 13
TDD in JS?!?
• With Q/promises, there is no reason not to
• We used Mocha/Sinon/Chai(and their -as-
promised brothers) to be able to assert on
methods returning promises
• This converts each of your tests into
promises which either resolve to success
or failure
Saturday, 24 August 13
Example
Saturday, 24 August 13
socket.io
• Library in a state of constant flux
• Was a major cause of performance slow down in
our application
• First we make a normal GET request to get a
handshake token
• The second request using the token then gets
upgraded to a full duplex conn
• Had to integrate with a (k,v) store like Redis to help
coordinate the creation of the handshake tokens
Saturday, 24 August 13
Performance
• Double-edged sword:
• node.js comes with a promise of speed
• the promised land is full of land mines
which can literally blow you away if you
don’t hit dead center the first time around
• Gatling proved a very capable companion in
figuring out the bottlenecks
Saturday, 24 August 13
Performance contd.
• The JS native MySQL driver turned out to be the
sore point
• Arriving at this conclusion took a lot of doing:
• newrelic didn’t help
• nodetime didn’t help
• running around wildly didn’t help
• Intuition strikes again: Performance was inversely
proportional to the number of round trips to MySQL
Saturday, 24 August 13
Background Jobs
• Anything which doesn’t belong in your web
flow, should be scaled separately
• A simple Resqueisque background jobs
queue solved the problem for us
• Redis again chimed in with its queue data
structure
Saturday, 24 August 13
Example
Saturday, 24 August 13
Clustering
• Utilizing all the available CPU resource
from within a single node.js application is
hard
• Eventually, you will need to fire up all the
cylinders
• The “cluster” module helps out grandly in
this regard; however it must be done right
to ensure a stable production environment
Saturday, 24 August 13
Example
Saturday, 24 August 13
Deployment
• Source based deployment is easy to do, but hard to get right
• “npm install” can bring in different versions of your
dependencies if you have sliding dependencies in your
package.json file
• Have to have a full compiler suite to handle native
extensions (e.g. libmysqlclient)
• Doing a node.js upgrade can silently fail if you do not “rm -
rf” node_modules first
• Doing a RPM (name your favorite packager) based setup
might not be such a bad idea afterall
Saturday, 24 August 13
Deployment contd.
• Things we take for granted in the Rails
world is not so simple here
• Had to write our own asset-combiner to
get around shoddy implementation in
connect-assetmanager
• A must if the site is going live with a CDN
Saturday, 24 August 13
Monitoring
• Clustering (which splits your application
into master/worker processes) makes it
difficult to keep the application up
• We finally ended up using “mon” (a highly
simplified cmd line based monit) as the
usual techniques (forever, etc.) were not
playing ball
Saturday, 24 August 13
Conclusion
• It was a rewarding experience
• Not a magic bullet
• Avoiding callback hell helped keep our
sanity
• Be prepared to spend sleepless nights
“when” the performance bugs hit
Saturday, 24 August 13
ThankYou
Questions???
Contact us at karanm@thoughtworks.com and snehakot@thoughtworks.com
Saturday, 24 August 13

More Related Content

What's hot

3 Gifts My Users Gave Me - Alexandra Draghici - WordCamp Europe 2017
3 Gifts My Users Gave Me - Alexandra Draghici - WordCamp Europe 20173 Gifts My Users Gave Me - Alexandra Draghici - WordCamp Europe 2017
3 Gifts My Users Gave Me - Alexandra Draghici - WordCamp Europe 2017Alexandra_CaptainForm
 
Building great spa’s with angular js, asp.net mvc and webapi
Building great spa’s with angular js, asp.net mvc and webapiBuilding great spa’s with angular js, asp.net mvc and webapi
Building great spa’s with angular js, asp.net mvc and webapiMaurice De Beijer [MVP]
 
Single page application and Framework
Single page application and FrameworkSingle page application and Framework
Single page application and FrameworkChandrasekar G
 
Introduction To JavaScript
Introduction To JavaScriptIntroduction To JavaScript
Introduction To JavaScriptKhadija Khalid
 
Build fast word press site in react in 30 mins with frontity
Build fast word press site in react in 30 mins   with frontityBuild fast word press site in react in 30 mins   with frontity
Build fast word press site in react in 30 mins with frontityImran Sayed
 
Single page applications
Single page applicationsSingle page applications
Single page applicationsDiego Cardozo
 
How to build a static website in two and a half days with Nuxt and Tailwind CSS
How to build a static website in two and a half days with Nuxt and Tailwind CSSHow to build a static website in two and a half days with Nuxt and Tailwind CSS
How to build a static website in two and a half days with Nuxt and Tailwind CSSVanessa Böhner
 
Web Based Development Introduction
Web Based Development IntroductionWeb Based Development Introduction
Web Based Development IntroductionEdy Segura
 
Building WordPress sites with AngularJS and the RESTful plugin JSON API
Building WordPress sites with AngularJS and the RESTful plugin JSON APIBuilding WordPress sites with AngularJS and the RESTful plugin JSON API
Building WordPress sites with AngularJS and the RESTful plugin JSON APIEric Greene
 
Building WordPress sites with AngularJS and the RESTful plugin JSON API @ Dev...
Building WordPress sites with AngularJS and the RESTful plugin JSON API @ Dev...Building WordPress sites with AngularJS and the RESTful plugin JSON API @ Dev...
Building WordPress sites with AngularJS and the RESTful plugin JSON API @ Dev...Eric Greene
 
Choosing a JavaScript Framework
Choosing a JavaScript FrameworkChoosing a JavaScript Framework
Choosing a JavaScript FrameworkTim Rayburn
 
Analizzare le performance di un'applicazione ASP.NET con Glimpse
Analizzare le performance di un'applicazione ASP.NET con GlimpseAnalizzare le performance di un'applicazione ASP.NET con Glimpse
Analizzare le performance di un'applicazione ASP.NET con GlimpseEmanuele Bartolesi
 
Tailwind CSS - KanpurJS
Tailwind CSS - KanpurJSTailwind CSS - KanpurJS
Tailwind CSS - KanpurJSNaveen Kharwar
 
DotNetCampus - Analizzare le performance di un'applicazione asp.net con Glimpse
DotNetCampus - Analizzare le performance di un'applicazione asp.net con GlimpseDotNetCampus - Analizzare le performance di un'applicazione asp.net con Glimpse
DotNetCampus - Analizzare le performance di un'applicazione asp.net con GlimpseEmanuele Bartolesi
 
JavaScript Framework Smackdown
JavaScript Framework SmackdownJavaScript Framework Smackdown
JavaScript Framework Smackdownmeghantaylor
 
Single Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJSSingle Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJSM R Rony
 

What's hot (20)

3 Gifts My Users Gave Me - Alexandra Draghici - WordCamp Europe 2017
3 Gifts My Users Gave Me - Alexandra Draghici - WordCamp Europe 20173 Gifts My Users Gave Me - Alexandra Draghici - WordCamp Europe 2017
3 Gifts My Users Gave Me - Alexandra Draghici - WordCamp Europe 2017
 
Building great spa’s with angular js, asp.net mvc and webapi
Building great spa’s with angular js, asp.net mvc and webapiBuilding great spa’s with angular js, asp.net mvc and webapi
Building great spa’s with angular js, asp.net mvc and webapi
 
Single page application and Framework
Single page application and FrameworkSingle page application and Framework
Single page application and Framework
 
Introduction To JavaScript
Introduction To JavaScriptIntroduction To JavaScript
Introduction To JavaScript
 
MEAN stack
MEAN stackMEAN stack
MEAN stack
 
Build fast word press site in react in 30 mins with frontity
Build fast word press site in react in 30 mins   with frontityBuild fast word press site in react in 30 mins   with frontity
Build fast word press site in react in 30 mins with frontity
 
Single page applications
Single page applicationsSingle page applications
Single page applications
 
MEAN Stack
MEAN Stack MEAN Stack
MEAN Stack
 
How to build a static website in two and a half days with Nuxt and Tailwind CSS
How to build a static website in two and a half days with Nuxt and Tailwind CSSHow to build a static website in two and a half days with Nuxt and Tailwind CSS
How to build a static website in two and a half days with Nuxt and Tailwind CSS
 
Web Based Development Introduction
Web Based Development IntroductionWeb Based Development Introduction
Web Based Development Introduction
 
Building WordPress sites with AngularJS and the RESTful plugin JSON API
Building WordPress sites with AngularJS and the RESTful plugin JSON APIBuilding WordPress sites with AngularJS and the RESTful plugin JSON API
Building WordPress sites with AngularJS and the RESTful plugin JSON API
 
SxSW 2015
SxSW 2015SxSW 2015
SxSW 2015
 
Building WordPress sites with AngularJS and the RESTful plugin JSON API @ Dev...
Building WordPress sites with AngularJS and the RESTful plugin JSON API @ Dev...Building WordPress sites with AngularJS and the RESTful plugin JSON API @ Dev...
Building WordPress sites with AngularJS and the RESTful plugin JSON API @ Dev...
 
Choosing a JavaScript Framework
Choosing a JavaScript FrameworkChoosing a JavaScript Framework
Choosing a JavaScript Framework
 
Analizzare le performance di un'applicazione ASP.NET con Glimpse
Analizzare le performance di un'applicazione ASP.NET con GlimpseAnalizzare le performance di un'applicazione ASP.NET con Glimpse
Analizzare le performance di un'applicazione ASP.NET con Glimpse
 
Mean stack
Mean stackMean stack
Mean stack
 
Tailwind CSS - KanpurJS
Tailwind CSS - KanpurJSTailwind CSS - KanpurJS
Tailwind CSS - KanpurJS
 
DotNetCampus - Analizzare le performance di un'applicazione asp.net con Glimpse
DotNetCampus - Analizzare le performance di un'applicazione asp.net con GlimpseDotNetCampus - Analizzare le performance di un'applicazione asp.net con Glimpse
DotNetCampus - Analizzare le performance di un'applicazione asp.net con Glimpse
 
JavaScript Framework Smackdown
JavaScript Framework SmackdownJavaScript Framework Smackdown
JavaScript Framework Smackdown
 
Single Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJSSingle Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJS
 

Viewers also liked

Secrets of the JavaScript Ninja - Chapter 12. DOM modification
Secrets of the JavaScript Ninja - Chapter 12. DOM modificationSecrets of the JavaScript Ninja - Chapter 12. DOM modification
Secrets of the JavaScript Ninja - Chapter 12. DOM modificationHyuncheol Jeon
 
#e-biznes festiwal 2013: idzie nowe!
#e-biznes festiwal 2013: idzie nowe!#e-biznes festiwal 2013: idzie nowe!
#e-biznes festiwal 2013: idzie nowe!#e-biznes festiwal
 
Natuuropnamen met fractie van seconde1
Natuuropnamen met fractie van seconde1Natuuropnamen met fractie van seconde1
Natuuropnamen met fractie van seconde1pvg666
 
Sense T - What happens when sensing happens?
Sense T - What happens when sensing happens? Sense T - What happens when sensing happens?
Sense T - What happens when sensing happens? progressive01
 
ილია წმინდის საჯარო სკოლა.მაია
ილია წმინდის საჯარო სკოლა.მაიაილია წმინდის საჯარო სკოლა.მაია
ილია წმინდის საჯარო სკოლა.მაიაmaiausufashvili
 
Ivan milushev-2015-1
Ivan milushev-2015-1Ivan milushev-2015-1
Ivan milushev-2015-1Sim Aleksiev
 
Start small business over internet
Start small business over internetStart small business over internet
Start small business over internetMd yeasin ul haider
 
The US Spanish Language Telenovela as a Globalized Genre
The US Spanish Language Telenovela as a Globalized GenreThe US Spanish Language Telenovela as a Globalized Genre
The US Spanish Language Telenovela as a Globalized GenreJuan Ramos
 
Poms the farmers view - David Barker
Poms the farmers view - David BarkerPoms the farmers view - David Barker
Poms the farmers view - David Barkerprogressive01
 
Nikolay karadjov-2013eng
Nikolay karadjov-2013engNikolay karadjov-2013eng
Nikolay karadjov-2013engSim Aleksiev
 
프로그랭및 구문 가이드
프로그랭및 구문 가이드프로그랭및 구문 가이드
프로그랭및 구문 가이드태환 엄
 
Update of the Tasmanian Pacific Oysters Health Surveillance Program & Biosecu...
Update of the Tasmanian Pacific Oysters Health Surveillance Program & Biosecu...Update of the Tasmanian Pacific Oysters Health Surveillance Program & Biosecu...
Update of the Tasmanian Pacific Oysters Health Surveillance Program & Biosecu...progressive01
 
1600 1620 siwanon jirawatnotai
1600 1620 siwanon jirawatnotai1600 1620 siwanon jirawatnotai
1600 1620 siwanon jirawatnotaispa718
 
Ognian nedkov-2015-1
Ognian nedkov-2015-1Ognian nedkov-2015-1
Ognian nedkov-2015-1Sim Aleksiev
 
Ivan milushev-2015.eng-1
Ivan milushev-2015.eng-1Ivan milushev-2015.eng-1
Ivan milushev-2015.eng-1Sim Aleksiev
 
Get unblocked drains
Get unblocked drainsGet unblocked drains
Get unblocked drainsAlen Clark
 

Viewers also liked (20)

Secrets of the JavaScript Ninja - Chapter 12. DOM modification
Secrets of the JavaScript Ninja - Chapter 12. DOM modificationSecrets of the JavaScript Ninja - Chapter 12. DOM modification
Secrets of the JavaScript Ninja - Chapter 12. DOM modification
 
#e-biznes festiwal 2013: idzie nowe!
#e-biznes festiwal 2013: idzie nowe!#e-biznes festiwal 2013: idzie nowe!
#e-biznes festiwal 2013: idzie nowe!
 
Natuuropnamen met fractie van seconde1
Natuuropnamen met fractie van seconde1Natuuropnamen met fractie van seconde1
Natuuropnamen met fractie van seconde1
 
Sense T - What happens when sensing happens?
Sense T - What happens when sensing happens? Sense T - What happens when sensing happens?
Sense T - What happens when sensing happens?
 
PROJETO DE RESOLUÇÃO Nº 560/XIII/2.ª
PROJETO DE RESOLUÇÃO Nº 560/XIII/2.ªPROJETO DE RESOLUÇÃO Nº 560/XIII/2.ª
PROJETO DE RESOLUÇÃO Nº 560/XIII/2.ª
 
ილია წმინდის საჯარო სკოლა.მაია
ილია წმინდის საჯარო სკოლა.მაიაილია წმინდის საჯარო სკოლა.მაია
ილია წმინდის საჯარო სკოლა.მაია
 
Ivan milushev-2015-1
Ivan milushev-2015-1Ivan milushev-2015-1
Ivan milushev-2015-1
 
Start small business over internet
Start small business over internetStart small business over internet
Start small business over internet
 
The US Spanish Language Telenovela as a Globalized Genre
The US Spanish Language Telenovela as a Globalized GenreThe US Spanish Language Telenovela as a Globalized Genre
The US Spanish Language Telenovela as a Globalized Genre
 
Presentation1
Presentation1Presentation1
Presentation1
 
Poms the farmers view - David Barker
Poms the farmers view - David BarkerPoms the farmers view - David Barker
Poms the farmers view - David Barker
 
Nikolay karadjov-2013eng
Nikolay karadjov-2013engNikolay karadjov-2013eng
Nikolay karadjov-2013eng
 
프로그랭및 구문 가이드
프로그랭및 구문 가이드프로그랭및 구문 가이드
프로그랭및 구문 가이드
 
Update of the Tasmanian Pacific Oysters Health Surveillance Program & Biosecu...
Update of the Tasmanian Pacific Oysters Health Surveillance Program & Biosecu...Update of the Tasmanian Pacific Oysters Health Surveillance Program & Biosecu...
Update of the Tasmanian Pacific Oysters Health Surveillance Program & Biosecu...
 
Ap 1 ubd 3rd quarter
Ap 1 ubd 3rd quarterAp 1 ubd 3rd quarter
Ap 1 ubd 3rd quarter
 
How planes fly
How planes flyHow planes fly
How planes fly
 
1600 1620 siwanon jirawatnotai
1600 1620 siwanon jirawatnotai1600 1620 siwanon jirawatnotai
1600 1620 siwanon jirawatnotai
 
Ognian nedkov-2015-1
Ognian nedkov-2015-1Ognian nedkov-2015-1
Ognian nedkov-2015-1
 
Ivan milushev-2015.eng-1
Ivan milushev-2015.eng-1Ivan milushev-2015.eng-1
Ivan milushev-2015.eng-1
 
Get unblocked drains
Get unblocked drainsGet unblocked drains
Get unblocked drains
 

Similar to node.js in action

Cloud stack design camp on jun 15
Cloud stack design camp on jun 15Cloud stack design camp on jun 15
Cloud stack design camp on jun 15Isaac Chiang
 
SSJS, NoSQL, GAE and AppengineJS
SSJS, NoSQL, GAE and AppengineJSSSJS, NoSQL, GAE and AppengineJS
SSJS, NoSQL, GAE and AppengineJSEugene Lazutkin
 
Scaling a High Traffic Web Application: Our Journey from Java to PHP
Scaling a High Traffic Web Application: Our Journey from Java to PHPScaling a High Traffic Web Application: Our Journey from Java to PHP
Scaling a High Traffic Web Application: Our Journey from Java to PHP120bi
 
Scaling High Traffic Web Applications
Scaling High Traffic Web ApplicationsScaling High Traffic Web Applications
Scaling High Traffic Web ApplicationsAchievers Tech
 
Adventures in Research
Adventures in ResearchAdventures in Research
Adventures in ResearchNETWAYS
 
OpenNebulaConf 2013 -Adventures in Research by Joel Merrick
OpenNebulaConf 2013 -Adventures in Research by Joel Merrick OpenNebulaConf 2013 -Adventures in Research by Joel Merrick
OpenNebulaConf 2013 -Adventures in Research by Joel Merrick OpenNebula Project
 
PHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentPHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentIrfan Maulana
 
Irfan maulana nodejs web development
Irfan maulana   nodejs web developmentIrfan maulana   nodejs web development
Irfan maulana nodejs web developmentPHP Indonesia
 
NDH2k12 Cloud Computing Security
NDH2k12 Cloud Computing SecurityNDH2k12 Cloud Computing Security
NDH2k12 Cloud Computing SecurityMatthieu Bouthors
 
Scalable server component using NodeJS & ExpressJS
Scalable server component using NodeJS & ExpressJSScalable server component using NodeJS & ExpressJS
Scalable server component using NodeJS & ExpressJSAndhy Koesnandar
 
Google App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and GaelykGoogle App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and GaelykGuillaume Laforge
 
Getting Started with Meteor
Getting Started with MeteorGetting Started with Meteor
Getting Started with MeteorMichael Redlich
 
NodeJS Concurrency
NodeJS ConcurrencyNodeJS Concurrency
NodeJS Concurrencypgriess
 
Functional Scala 2022 - scalajs Alexis.pdf
Functional Scala 2022 - scalajs Alexis.pdfFunctional Scala 2022 - scalajs Alexis.pdf
Functional Scala 2022 - scalajs Alexis.pdfssusercd195b
 
node.js in production: Reflections on three years of riding the unicorn
node.js in production: Reflections on three years of riding the unicornnode.js in production: Reflections on three years of riding the unicorn
node.js in production: Reflections on three years of riding the unicornbcantrill
 
Apereo OAE - Architectural overview
Apereo OAE - Architectural overviewApereo OAE - Architectural overview
Apereo OAE - Architectural overviewNicolaas Matthijs
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLBarry Jones
 
Webpack: What it is, What it does, Whether you need it
Webpack: What it is, What it does, Whether you need itWebpack: What it is, What it does, Whether you need it
Webpack: What it is, What it does, Whether you need itMike Wilcox
 

Similar to node.js in action (20)

Cloud stack design camp on jun 15
Cloud stack design camp on jun 15Cloud stack design camp on jun 15
Cloud stack design camp on jun 15
 
SSJS, NoSQL, GAE and AppengineJS
SSJS, NoSQL, GAE and AppengineJSSSJS, NoSQL, GAE and AppengineJS
SSJS, NoSQL, GAE and AppengineJS
 
Scaling a High Traffic Web Application: Our Journey from Java to PHP
Scaling a High Traffic Web Application: Our Journey from Java to PHPScaling a High Traffic Web Application: Our Journey from Java to PHP
Scaling a High Traffic Web Application: Our Journey from Java to PHP
 
Scaling High Traffic Web Applications
Scaling High Traffic Web ApplicationsScaling High Traffic Web Applications
Scaling High Traffic Web Applications
 
Adventures in Research
Adventures in ResearchAdventures in Research
Adventures in Research
 
OpenNebulaConf 2013 -Adventures in Research by Joel Merrick
OpenNebulaConf 2013 -Adventures in Research by Joel Merrick OpenNebulaConf 2013 -Adventures in Research by Joel Merrick
OpenNebulaConf 2013 -Adventures in Research by Joel Merrick
 
PHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentPHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web Development
 
Irfan maulana nodejs web development
Irfan maulana   nodejs web developmentIrfan maulana   nodejs web development
Irfan maulana nodejs web development
 
NDH2k12 Cloud Computing Security
NDH2k12 Cloud Computing SecurityNDH2k12 Cloud Computing Security
NDH2k12 Cloud Computing Security
 
Scalable server component using NodeJS & ExpressJS
Scalable server component using NodeJS & ExpressJSScalable server component using NodeJS & ExpressJS
Scalable server component using NodeJS & ExpressJS
 
re7olabini
re7olabinire7olabini
re7olabini
 
Google App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and GaelykGoogle App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and Gaelyk
 
Getting Started with Meteor
Getting Started with MeteorGetting Started with Meteor
Getting Started with Meteor
 
Node azure
Node azureNode azure
Node azure
 
NodeJS Concurrency
NodeJS ConcurrencyNodeJS Concurrency
NodeJS Concurrency
 
Functional Scala 2022 - scalajs Alexis.pdf
Functional Scala 2022 - scalajs Alexis.pdfFunctional Scala 2022 - scalajs Alexis.pdf
Functional Scala 2022 - scalajs Alexis.pdf
 
node.js in production: Reflections on three years of riding the unicorn
node.js in production: Reflections on three years of riding the unicornnode.js in production: Reflections on three years of riding the unicorn
node.js in production: Reflections on three years of riding the unicorn
 
Apereo OAE - Architectural overview
Apereo OAE - Architectural overviewApereo OAE - Architectural overview
Apereo OAE - Architectural overview
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQL
 
Webpack: What it is, What it does, Whether you need it
Webpack: What it is, What it does, Whether you need itWebpack: What it is, What it does, Whether you need it
Webpack: What it is, What it does, Whether you need it
 

Recently uploaded

Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 

Recently uploaded (20)

Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 

node.js in action

  • 1. node.js in action Learnings from Cisco Karan & Sneha ThoughtWorks Saturday, 24 August 13
  • 2. node.js ? • JavaScript is not jQuery • Created by Ryan Dahl utilizing the Google V8 JavaScript engine • Has evented I/O as part of its arsenal Saturday, 24 August 13
  • 3. Tech Stack • Express (web framework) • Sequelize (ORM) • Gruntjs (task runner) • coffee-resque (background jobs and queues) • Q (callback sanity) • Mocha/Sinon/Chai (TDD) Saturday, 24 August 13
  • 4. Callback Hell! • Avoid like the plague • Can suck all the fun out of writing JavaScript (everywhere) • Waiting for returns across logical boundaries is almost impossible • Senthil/Kuldeep cover this area in a lot more detail right after this talk Saturday, 24 August 13
  • 6. TDD in JS?!? • With Q/promises, there is no reason not to • We used Mocha/Sinon/Chai(and their -as- promised brothers) to be able to assert on methods returning promises • This converts each of your tests into promises which either resolve to success or failure Saturday, 24 August 13
  • 8. socket.io • Library in a state of constant flux • Was a major cause of performance slow down in our application • First we make a normal GET request to get a handshake token • The second request using the token then gets upgraded to a full duplex conn • Had to integrate with a (k,v) store like Redis to help coordinate the creation of the handshake tokens Saturday, 24 August 13
  • 9. Performance • Double-edged sword: • node.js comes with a promise of speed • the promised land is full of land mines which can literally blow you away if you don’t hit dead center the first time around • Gatling proved a very capable companion in figuring out the bottlenecks Saturday, 24 August 13
  • 10. Performance contd. • The JS native MySQL driver turned out to be the sore point • Arriving at this conclusion took a lot of doing: • newrelic didn’t help • nodetime didn’t help • running around wildly didn’t help • Intuition strikes again: Performance was inversely proportional to the number of round trips to MySQL Saturday, 24 August 13
  • 11. Background Jobs • Anything which doesn’t belong in your web flow, should be scaled separately • A simple Resqueisque background jobs queue solved the problem for us • Redis again chimed in with its queue data structure Saturday, 24 August 13
  • 13. Clustering • Utilizing all the available CPU resource from within a single node.js application is hard • Eventually, you will need to fire up all the cylinders • The “cluster” module helps out grandly in this regard; however it must be done right to ensure a stable production environment Saturday, 24 August 13
  • 15. Deployment • Source based deployment is easy to do, but hard to get right • “npm install” can bring in different versions of your dependencies if you have sliding dependencies in your package.json file • Have to have a full compiler suite to handle native extensions (e.g. libmysqlclient) • Doing a node.js upgrade can silently fail if you do not “rm - rf” node_modules first • Doing a RPM (name your favorite packager) based setup might not be such a bad idea afterall Saturday, 24 August 13
  • 16. Deployment contd. • Things we take for granted in the Rails world is not so simple here • Had to write our own asset-combiner to get around shoddy implementation in connect-assetmanager • A must if the site is going live with a CDN Saturday, 24 August 13
  • 17. Monitoring • Clustering (which splits your application into master/worker processes) makes it difficult to keep the application up • We finally ended up using “mon” (a highly simplified cmd line based monit) as the usual techniques (forever, etc.) were not playing ball Saturday, 24 August 13
  • 18. Conclusion • It was a rewarding experience • Not a magic bullet • Avoiding callback hell helped keep our sanity • Be prepared to spend sleepless nights “when” the performance bugs hit Saturday, 24 August 13
  • 19. ThankYou Questions??? Contact us at karanm@thoughtworks.com and snehakot@thoughtworks.com Saturday, 24 August 13