Node @ flipkart

47
Node @ Flipkart Abhinav Rastogi @_abhinavrastogi

description

The new node-based stack we are building at Flipkart and the challenges we faced in getting it in production! Plus the experience of a UI developer working in the systems domain :) Watch the accompanying talk at https://hasgeek.tv/jsfoo/2014-2/998-ui-flipkart-a-node-direction

Transcript of Node @ flipkart

Page 1: Node @ flipkart

Node @ Flipkart

Abhinav Rastogi@_abhinavrastogi

Page 2: Node @ flipkart

!jQueryIf you think jQuery is the answer,

you lose a cookie and get an F grade!

Page 3: Node @ flipkart
Page 4: Node @ flipkart
Page 5: Node @ flipkart

Picking one is difficult!Plus its never exactly what you need

Page 6: Node @ flipkart

How we built a web stack in Node...

It’s really not that difficult

Page 7: Node @ flipkart

Node in ProductionNow this is a different story altogether

Page 8: Node @ flipkart

PhilosophyA web stack to build rich UIs for the next generation,

embracing progressive enhancement.

Page 9: Node @ flipkart

Request

Session API

JSON

Rendering

Templates

Response

Product API

Search API

Cart APIPromises

HTML

Page 10: Node @ flipkart

Why Node?And that too in production? :O

Page 11: Node @ flipkart

Parallel, AsyncHuge benefit right there over conventional stacks

Page 12: Node @ flipkart

Light weightBest available JS execution env

Page 13: Node @ flipkart

Good communityBuzzing like a beehive

Page 14: Node @ flipkart

“There’s a module for that”No, there really is.

Page 15: Node @ flipkart

Challenges we faced(So many of them!)

Page 16: Node @ flipkart

Code MaintainabilityWhat does it really mean?

Page 17: Node @ flipkart

Klass, LodashFor classy code B-)

Page 18: Node @ flipkart

High AvailabilityAs they say, 99.99% uptime guaranteed!

But is it really?

Page 19: Node @ flipkart

Keep that process runningForever

PM2

Shell Script!

Page 20: Node @ flipkart

TestabilityUgh… test cases :(

Page 21: Node @ flipkart

Test it!Mocha, Chai, Istanbul

Page 22: Node @ flipkart

PerformanceSo much to do… so little time

Page 23: Node @ flipkart

Profile it. Look, DTrace, Event Loop

Page 24: Node @ flipkart

Code ReusabilityNot just modules, but so much more now

Page 25: Node @ flipkart

ComponentsCommonJS

Page 26: Node @ flipkart

TemplatingJade, Handlebars, Underscore

Page 27: Node @ flipkart

ReactJSDoes all that, and more

Page 28: Node @ flipkart

Write once, run anywhere!Sh*t... that sounds like Java

Page 29: Node @ flipkart

Rendering on Server

Cacheable

Reliable

SEO friendly

Optimised First Paint

Page 30: Node @ flipkart

Rendering on Client

Less load on server

Perceived Performance

Rich UIs

Page 31: Node @ flipkart

Whoa.. easy thereLogging

Env specific code

External HTTP requests

Page 32: Node @ flipkart

ResponsivenessUseful? Needed? Required?

Or just a fancy fad?

Page 33: Node @ flipkart

Cross-device/browserIE? Android 2.3? Cloud browsers?

K.I.S.S!

Page 34: Node @ flipkart

Fanboyism?Close, but no :P

Page 35: Node @ flipkart

Why not Node?The other side of the story

Page 36: Node @ flipkart

Relatively newMany unsolved problems

Page 37: Node @ flipkart

“There’s a module for that”

Its an Android Play Store…Not an Apple App Store

Page 38: Node @ flipkart

</3Not for the weak-hearted

Page 39: Node @ flipkart

Productionizing NodeScrew best practices. Whatever works is best.

Page 40: Node @ flipkart

Monitor and Alert!Nagios, Monit

Page 41: Node @ flipkart
Page 42: Node @ flipkart

Log it.Bunyan, Winston

Page 43: Node @ flipkart

Server Health and Rotation Status

Keep the difference in mind!

Page 44: Node @ flipkart

QPS vs ConcurrencyWait, aren’t they the same?

Page 45: Node @ flipkart

Recap

Page 46: Node @ flipkart

Node in Production

Isomorphism

Useful tools and modules

Page 47: Node @ flipkart

Thank you@_abhinavrastogi