SlideShare a Scribd company logo
1 of 77
Node.js Web Apps
@ ebay scale
By Dmytro Semenov
Member of Technical Staff @ NodeJS, Cloud and Platform Services, eBay Inc.
dsemenov@ebay.com
Our Journey
1995 2004 2013 present2006
Perl
C++
XSL/XML
Java
Node
Scala
Java UI, JSP Extended
Python Go ???
future
Marko/Lasso(Tessa)
Polyglot initiative
OSGi
Programming Language History
● Perl/Apache (no layers)
○ Scalability limit of 50K active listings
● C/C++/IIS/XML/XSL (monolithic client/server architecture)
○ Compiler limit of methods per class, very long build times (2+ hours)
● Java/J2EE (3 tier architecture, split build into domain specific)
○ XML/XSL (MSXSL) as presentation layer hit native memory limit
○ Java UI components, proprietary technology, steep learning curve
○ Startup time up to 40 minutes
● Java Stack (embrace open-source, JSP, modular approach)
○ OSGi conflicts at startup, very hard to get everything working at the start
○ Slow startup time (2+ minutes)
● Polyglot initiative to support popular languages/technologies
Node.JS Introduction
● Started in 2013
○ CubeJS, first attempt was not so good,
○ Unified NodeJS, eBay and PayPal platform merge
○ Big projects decided to move to NodeJS
● Embedding into application teams
○ Accumulation of issue knowledge base
○ Build confidence and form local knowledge centers
○ Fast feedback
○ Fast project startup
○ Pick new ideas from application teams
Current State
● Node 4.x
● 200 applications and growing
● 80 million requests / day now 1 billion
● Platform team of 6 developers
● Very vibrant internal community
○ Local pool of knowledge among teams
○ Self sustaining support by internal community
○ PRs are welcome
○ 45 contributors to eBay NodeJS platform
● 80 platform modules
● 330 total modules
● More agile
○ Startup time <2s
○ Test coverage close to 90%-100%
○ Faster releases (every day) vs 2 weeks cycle
○ Automatic upgrades with semver
○ Modular UI architecture based on UI components
● Better tools
○ flame graphs, waterfall charts, pre-production testing
● Learnings Applied to Java Platform
○ Incorporate best practices from NodeJS
○ Startup time < 1 minute
○ Embrace modular approach and semver
○ Lighter Java stacks
Architecture
NPM: Private
Kappa
CouchDB
Primary
CouchDB
Backup
replicate
registry.npmjs.org
npmjs.ebay.com
fallback
LB
Kappa
Kappa
Multi-Screen World
mobile web
browser
native
App
Server
Domain
Experience
Service
services
API
Gateway
ajax
● Experience Service
○ Provides view models for UI modules
○ View model is specific to the device type (native, size, desktop, tablet)
● NodeJS Web App
○ Talk to experience service
○ Handles UI functionality
○ Renders desktop and mobile web pages
● Native Apps
○ Talk to experience service via API gateway
Module View
pm2
node.js
express (3 workers)
platform-ebay
analytics
logging
config
service client
lasso plugin
app
servicespages components
kraken-js lasso/tessamarko
Don’t Build Pages, Build Modules
The old directory
structure (bad)...
src/
pages/
component
s/
src/components/login-form/
index.js
style.css
template.marko
src/pages/login/
index.js
style.css
browser.json
UI Technologies
● Async + streaming
● Custom tags
● Browser + Node.js runtime
● Lightweight
● Extremely fast
● Compiles to CommonJS
markojs.com
github.com/marko-js/marko
github.com/marko-js/marko-widgets
Templating
UI components
● DOM diffing/patching
● Batched updates
● Stateful widgets
● Declarative event binding
● Efficient event delegation
● Lightweight runtime
UI components built using Marko Widgets
Uses Marko templates as the view. Plus:
github.com/marko-js/marko-widgets
● DOM diffing/patching
● Batched updates
● Stateful widgets
● Declarative event binding
● Efficient event delegation
● Lightweight runtime
Speed is king
Node is built on a streaming interface
HTTP is a streaming protocol
So why then do most templating and UI libraries render
as a single chunk?
● Faster perceived page load
● Better time, resource and traffic utilization
● Progressive rendering between browser, frontend and backend
○ Frontend<->Backend: Stream of server side events (SSE)
○ Browser<->Frontend: Module render and flush on arrival
● Marko helps:
○ Async fragments support by marko-async
○ Re-order on client side
Marko vs React: Server-side rendering
github.com/patrick-steele-idem/marko-vs-react
browser
Domain
Experience
Service
http/https http/https
chunked stream sse stream
App
Server
Service Invocation
Why not use middleware pattern on the
client?
logging
error handling
analytics
circuit breaker
retry
security/oauth
http/https/sse
serviceinvocationhandlers
service client
middlewares
service
web app
request
response
cookies
body-parser
analytics
● Generic Service Client with pluggable handlers
● Handler performs a single function
● The handler pipeline is configurable per client
Configuration based Code based
"my-service-client": {
"protocol": "http:",
"hostname": "myservice.com",
“path”: “/path/to/resource”,
"port": 8080,
"socketTimeout": 1000,
"pipeline": [
"logging/handler",
"circuit-breaker/handler",
"error/handler" ]
}
var serviceClient = require(‘service-client’);
serviceClient.use(require(‘logging/handler’));
serviceClient.use(require(‘circuit-breaker/handler’));
serviceClient.use(require(‘error/handler’));
serviceClient
.get(‘http://myservice.com/path/to/resource’)
.end((err, response) => {
console.log(response.body);
})
Resource Bundling and
Externalization
Why not deploy everything
at once?
Resource
Server
App
Server
1. GET
http://www.ebay.com
2. GET
http://rs/check/hp-24512.js
3. PUT
http://rs/upload/hp-24512.js
4. <script src=”hp-
24512.js”>
5. GET http://hp-
24512.js
6. GET http://hp-
24512.js
Akamai
browser
lasso.js/tessa
JavaScript module bundler + asset pipeline
github.com/lasso-js/lasso
● Supported resources
○ Defined by lasso plugins
○ CSS/JS/Images
○ Templates
○ I18n content
○ Bundle definition
● Lasso plugin
○ Adaptor between lasso and resource server
● Benefits
○ Single build and deployment
○ No synchronization problems between app and resource server deployments
○ Externalization at startup and during runtime on-the-fly
Configuration Management
app/config.json
/node_modules
/moduleA/config.json
/moduleB/config.json
CMS
app/1.0.1/config: {}
moduleA/1.1.1/config: {}
moduleB/1.0.0/config: {}
pull every minute
Config
Deployment
App
Deployment
App
Server
App
Server
App
Server
● Module configuration
○ Local, packaged with module
○ Remote, hot deployed
● Application configuration
○ Local
○ Remote, hot deployed
● Application can override any module configuration
● Configuration can be injected via Admin Console
● Future - Code and Config “separation”, but
○ Keep app and config together in git repo and separate at deployment.
○ Easier to manage
i18n
● Use krakenjs/spud module
○ Property file format
○ Marko tags/helpers
● Externalizable as resources
● 17 main languages
● Support multiple languages per country
● Application and modules can have localizable content
app/locales/
US/
en/
ProjectName/
xxx.properties
yyy.properties
ru/
ProjectName/
xxx.properties
yyy.properties
DE/
de/
ProjectName/
xxx.properties
yyy.properties
Folder Structure Example
Security
● Nsp tool
○ On-demand scan for every application project
○ Security badge for every platform module
● ScanJS
○ Source code scan
● CSRF tokens
● Redirect validation
● XSS
● Rate limiter
Logging & Monitoring
● Logging every transaction/subtransaction
○ Central Logging Repository (CAL) provides log aggregation per pool/box/datacenter
○ Use Domains to maintain context per request and avoid passing it around
● Explicit code instrumentation
○ Support DEBUG, INFO, WARN, ERROR, FATAL
○ Time span to record transaction (start and end)
○ Nested spans
● Health checks/stats monitoring and alerts
● Crash/OOM emails to the owner of the pool
● Early problem detection using traffic mirror
App Resiliency
● Proactive testing in pre-production
○ Traffic mirroring of read-only traffic to the box with new build
○ Easy upgrades
● Handling uncaught errors
○ Domains used to capture context
○ Send email to the owner with stack trace, group and box name, request info
○ Graceful restart
● Handling memory leaks
○ Email sent to the owner with group and box name, request info
○ Graceful restart when memory threshold is reached
● Too busy load shedding
○ 503 or connection reset to trigger browser DNS fallback
○ Filter bots traffic under heavy load
● Planning for failure
● Hystrix like service calls
○ Fail fast
○ Circuit breaker
Performance Optimization
● Fast startup/re-start
○ Cold cache to avoid service invocation
○ Pre-compiling template @ deployment
○ Pre-externalizing resources @ deployment
● Progressive rendering/streaming @ browser side
● Progressive chunking/streaming @ service side
● Performance tuning
○ Flame Graphs
○ Waterfall charts @ server side
Marko vs React: Server-side rendering
github.com/patrick-steele-idem/marko-vs-react
Tools > Flame Graphs
Flame Graphs
Why not use v8-profiler data?
● How to
○ Use v8-profiler to generate json data file
○ Aggregate stack frames into json
○ Render using d3-flame-graph
● No special environment
● No special steps
● Single button generation
● Can be used in production/dev/qa
● Exposes only javascript side of the code
Used For ...
● CPU profiling
● Troubleshooting in production the problem at hand
● Memory leak investigation
● Regular sampling
Practice Fire Safety
Flame Graphs:
Tools > Waterfall Charts
● Logs are hard to read
● Timestamps are hard to compare
● We need a faster tool?
Why not use the same method used by
developer tools in browser?
Waterfall Charts
● Requires code instrumentation
● Easy and quick to assess what is going on
● Easy to spot synchronous events
● Analyze for possible task parallelization
Lessons Learned
● Latency, TCP_NODELAY=true
● Handling request close, finish, error events is important
● No dns cache out of the box
○ Use OS level caching to allow restarts
● Avoid modules with a state
● Embedding within App teams to bootstrap works great
● Use cold cache to keep restarts fast
Challenges
● Version control
○ npm shrinkwrap does not guarantee versions
○ switched to Uber shrinkwrap
● App and platform coupling in one build
○ It is still monolithic, platform coupled to app
● Upgrading to major versions
○ Need to keep backwards compatible
○ Teams go at their own pace
● Memory leak analysis
● Debugging
○ Not stable, gets broken frequently
So Far So Good
What’s next?
● 1 billion requests / day
● Decoupling platform from application
○ Moving platform components into separate processes
○ Independent platform deployments
○ More resilient apps
○ Problem isolation (easier memory leak detection)
● Platform microservices
● Docker
● Kubernetes
● SenecaJS
● NodeJS services
References
• Progressive rendering: http://www.ebaytechblog.com/2014/12/08/async-fragments-
rediscovering-progressive-html-rendering-with-marko
• AMP: http://www.ebaytechblog.com/2016/06/30/browse-ebay-with-style-and-speed/ - sse
between frontend and backend - streaming
• http://www.ebaytechblog.com/2016/06/15/igniting-node-js-flames/
• http://www.ebaytechblog.com/2016/07/14/mastering-the-fire/
• http://www.slideshare.net/tcng3716/ebay-architecture
• Cloud http://www.computerweekly.com/news/2240222899/Case-study-How-eBay-uses-its-
own-OpenStack-private-cloud
• http://www.ebaytechblog.com/2014/10/02/dont-build-pages-build-modules/
• history: http://www.addsimplicity.com/downloads/eBaySDForum2006-11-29.pdf
• lasso: https://www.npmjs.com/package/lasso
• marko: http://markojs.com/
• https://github.com/spiermar/d3-flame-graph
Questions ?
Back slides

More Related Content

What's hot

Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsRob O'Doherty
 
Basic Concept of Node.js & NPM
Basic Concept of Node.js & NPMBasic Concept of Node.js & NPM
Basic Concept of Node.js & NPMBhargav Anadkat
 
Node.js, toy or power tool?
Node.js, toy or power tool?Node.js, toy or power tool?
Node.js, toy or power tool?Ovidiu Dimulescu
 
NodeJS guide for beginners
NodeJS guide for beginnersNodeJS guide for beginners
NodeJS guide for beginnersEnoch Joshua
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.jsDinesh U
 
Node JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web AppNode JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web AppEdureka!
 
NodeJS ecosystem
NodeJS ecosystemNodeJS ecosystem
NodeJS ecosystemYukti Kaura
 
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, DhakaJavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, DhakaNurul Ferdous
 
Tech io nodejs_20130531_v0.6
Tech io nodejs_20130531_v0.6Tech io nodejs_20130531_v0.6
Tech io nodejs_20130531_v0.6Ganesh Kondal
 
Node.js Crash Course
Node.js Crash CourseNode.js Crash Course
Node.js Crash CourseDavid Neal
 
OSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialOSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialTom Croucher
 
Introduction to node.js by jiban
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jibanJibanananda Sana
 

What's hot (20)

Node js introduction
Node js introductionNode js introduction
Node js introduction
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Basic Concept of Node.js & NPM
Basic Concept of Node.js & NPMBasic Concept of Node.js & NPM
Basic Concept of Node.js & NPM
 
Node.js, toy or power tool?
Node.js, toy or power tool?Node.js, toy or power tool?
Node.js, toy or power tool?
 
NodeJS guide for beginners
NodeJS guide for beginnersNodeJS guide for beginners
NodeJS guide for beginners
 
Node.js architecture (EN)
Node.js architecture (EN)Node.js architecture (EN)
Node.js architecture (EN)
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
 
Node JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web AppNode JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web App
 
NodeJS ecosystem
NodeJS ecosystemNodeJS ecosystem
NodeJS ecosystem
 
Node js for enterprise
Node js for enterpriseNode js for enterprise
Node js for enterprise
 
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, DhakaJavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
 
Nodejs vatsal shah
Nodejs vatsal shahNodejs vatsal shah
Nodejs vatsal shah
 
Tech io nodejs_20130531_v0.6
Tech io nodejs_20130531_v0.6Tech io nodejs_20130531_v0.6
Tech io nodejs_20130531_v0.6
 
Best node js course
Best node js courseBest node js course
Best node js course
 
Introduction to NodeJS
Introduction to NodeJSIntroduction to NodeJS
Introduction to NodeJS
 
Introduction to Node js
Introduction to Node jsIntroduction to Node js
Introduction to Node js
 
Node.js Crash Course
Node.js Crash CourseNode.js Crash Course
Node.js Crash Course
 
OSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialOSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js Tutorial
 
Node js
Node jsNode js
Node js
 
Introduction to node.js by jiban
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jiban
 

Similar to Node.js Web Apps @ ebay scale

CON6423: Scalable JavaScript applications with Project Nashorn
CON6423: Scalable JavaScript applications with Project NashornCON6423: Scalable JavaScript applications with Project Nashorn
CON6423: Scalable JavaScript applications with Project NashornMichel Graciano
 
Netflix Open Source Meetup Season 4 Episode 2
Netflix Open Source Meetup Season 4 Episode 2Netflix Open Source Meetup Season 4 Episode 2
Netflix Open Source Meetup Season 4 Episode 2aspyker
 
Kubernetes Forum Seoul 2019: Re-architecting Data Platform with Kubernetes
Kubernetes Forum Seoul 2019: Re-architecting Data Platform with KubernetesKubernetes Forum Seoul 2019: Re-architecting Data Platform with Kubernetes
Kubernetes Forum Seoul 2019: Re-architecting Data Platform with KubernetesSeungYong Oh
 
Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)Per Henrik Lausten
 
Javascript Update May 2013
Javascript Update May 2013Javascript Update May 2013
Javascript Update May 2013Ramesh Nair
 
AWS Lambda and Serverless framework: lessons learned while building a serverl...
AWS Lambda and Serverless framework: lessons learned while building a serverl...AWS Lambda and Serverless framework: lessons learned while building a serverl...
AWS Lambda and Serverless framework: lessons learned while building a serverl...Luciano Mammino
 
Web App Prototypes with Google App Engine
Web App Prototypes with Google App EngineWeb App Prototypes with Google App Engine
Web App Prototypes with Google App EngineVlad Filippov
 
[scala.by] Launching new application fast
[scala.by] Launching new application fast[scala.by] Launching new application fast
[scala.by] Launching new application fastDenis Karpenko
 
PyConIE 2017 Writing and deploying serverless python applications
PyConIE 2017 Writing and deploying serverless python applicationsPyConIE 2017 Writing and deploying serverless python applications
PyConIE 2017 Writing and deploying serverless python applicationsCesar Cardenas Desales
 
Introduction to node.js aka NodeJS
Introduction to node.js aka NodeJSIntroduction to node.js aka NodeJS
Introduction to node.js aka NodeJSJITENDRA KUMAR PATEL
 
Normalizing x pages web development
Normalizing x pages web development Normalizing x pages web development
Normalizing x pages web development Shean McManus
 
NetflixOSS Meetup season 3 episode 1
NetflixOSS Meetup season 3 episode 1NetflixOSS Meetup season 3 episode 1
NetflixOSS Meetup season 3 episode 1Ruslan Meshenberg
 
Writing and deploying serverless python applications
Writing and deploying serverless python applicationsWriting and deploying serverless python applications
Writing and deploying serverless python applicationsCesar Cardenas Desales
 
Machine learning and big data @ uber a tale of two systems
Machine learning and big data @ uber a tale of two systemsMachine learning and big data @ uber a tale of two systems
Machine learning and big data @ uber a tale of two systemsZhenxiao Luo
 

Similar to Node.js Web Apps @ ebay scale (20)

CON6423: Scalable JavaScript applications with Project Nashorn
CON6423: Scalable JavaScript applications with Project NashornCON6423: Scalable JavaScript applications with Project Nashorn
CON6423: Scalable JavaScript applications with Project Nashorn
 
Netflix Open Source Meetup Season 4 Episode 2
Netflix Open Source Meetup Season 4 Episode 2Netflix Open Source Meetup Season 4 Episode 2
Netflix Open Source Meetup Season 4 Episode 2
 
Kubernetes Forum Seoul 2019: Re-architecting Data Platform with Kubernetes
Kubernetes Forum Seoul 2019: Re-architecting Data Platform with KubernetesKubernetes Forum Seoul 2019: Re-architecting Data Platform with Kubernetes
Kubernetes Forum Seoul 2019: Re-architecting Data Platform with Kubernetes
 
Flour
FlourFlour
Flour
 
Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)
 
Javascript Update May 2013
Javascript Update May 2013Javascript Update May 2013
Javascript Update May 2013
 
AWS Lambda and Serverless framework: lessons learned while building a serverl...
AWS Lambda and Serverless framework: lessons learned while building a serverl...AWS Lambda and Serverless framework: lessons learned while building a serverl...
AWS Lambda and Serverless framework: lessons learned while building a serverl...
 
Netty training
Netty trainingNetty training
Netty training
 
Web App Prototypes with Google App Engine
Web App Prototypes with Google App EngineWeb App Prototypes with Google App Engine
Web App Prototypes with Google App Engine
 
Full stack development
Full stack developmentFull stack development
Full stack development
 
Node.js an Exectutive View
Node.js an Exectutive ViewNode.js an Exectutive View
Node.js an Exectutive View
 
[scala.by] Launching new application fast
[scala.by] Launching new application fast[scala.by] Launching new application fast
[scala.by] Launching new application fast
 
PyConIE 2017 Writing and deploying serverless python applications
PyConIE 2017 Writing and deploying serverless python applicationsPyConIE 2017 Writing and deploying serverless python applications
PyConIE 2017 Writing and deploying serverless python applications
 
Netty training
Netty trainingNetty training
Netty training
 
Node.js Course 2 of 2 - Advanced techniques
Node.js Course 2 of 2 - Advanced techniquesNode.js Course 2 of 2 - Advanced techniques
Node.js Course 2 of 2 - Advanced techniques
 
Introduction to node.js aka NodeJS
Introduction to node.js aka NodeJSIntroduction to node.js aka NodeJS
Introduction to node.js aka NodeJS
 
Normalizing x pages web development
Normalizing x pages web development Normalizing x pages web development
Normalizing x pages web development
 
NetflixOSS Meetup season 3 episode 1
NetflixOSS Meetup season 3 episode 1NetflixOSS Meetup season 3 episode 1
NetflixOSS Meetup season 3 episode 1
 
Writing and deploying serverless python applications
Writing and deploying serverless python applicationsWriting and deploying serverless python applications
Writing and deploying serverless python applications
 
Machine learning and big data @ uber a tale of two systems
Machine learning and big data @ uber a tale of two systemsMachine learning and big data @ uber a tale of two systems
Machine learning and big data @ uber a tale of two systems
 

Recently uploaded

Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...SofiyaSharma5
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girladitipandeya
 
VIP Kolkata Call Girls Salt Lake 8250192130 Available With Room
VIP Kolkata Call Girls Salt Lake 8250192130 Available With RoomVIP Kolkata Call Girls Salt Lake 8250192130 Available With Room
VIP Kolkata Call Girls Salt Lake 8250192130 Available With Roomgirls4nights
 
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsThierry TROUIN ☁
 
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts servicevipmodelshub1
 
On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024APNIC
 
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Roomdivyansh0kumar0
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...APNIC
 
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersMoving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersDamian Radcliffe
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.soniya singh
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts servicesonalikaur4
 

Recently uploaded (20)

Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
 
VIP Kolkata Call Girls Salt Lake 8250192130 Available With Room
VIP Kolkata Call Girls Salt Lake 8250192130 Available With RoomVIP Kolkata Call Girls Salt Lake 8250192130 Available With Room
VIP Kolkata Call Girls Salt Lake 8250192130 Available With Room
 
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with Flows
 
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
 
On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024
 
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
 
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersMoving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
 
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Saket Delhi 💯Call Us 🔝8264348440🔝
 
Call Girls In South Ex 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In South Ex 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICECall Girls In South Ex 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In South Ex 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
 
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
 
Model Call Girl in Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in  Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in  Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
 

Node.js Web Apps @ ebay scale

  • 1. Node.js Web Apps @ ebay scale
  • 2. By Dmytro Semenov Member of Technical Staff @ NodeJS, Cloud and Platform Services, eBay Inc. dsemenov@ebay.com
  • 4. 1995 2004 2013 present2006 Perl C++ XSL/XML Java Node Scala Java UI, JSP Extended Python Go ??? future Marko/Lasso(Tessa) Polyglot initiative OSGi Programming Language History
  • 5. ● Perl/Apache (no layers) ○ Scalability limit of 50K active listings ● C/C++/IIS/XML/XSL (monolithic client/server architecture) ○ Compiler limit of methods per class, very long build times (2+ hours) ● Java/J2EE (3 tier architecture, split build into domain specific) ○ XML/XSL (MSXSL) as presentation layer hit native memory limit ○ Java UI components, proprietary technology, steep learning curve ○ Startup time up to 40 minutes ● Java Stack (embrace open-source, JSP, modular approach) ○ OSGi conflicts at startup, very hard to get everything working at the start ○ Slow startup time (2+ minutes) ● Polyglot initiative to support popular languages/technologies
  • 7. ● Started in 2013 ○ CubeJS, first attempt was not so good, ○ Unified NodeJS, eBay and PayPal platform merge ○ Big projects decided to move to NodeJS ● Embedding into application teams ○ Accumulation of issue knowledge base ○ Build confidence and form local knowledge centers ○ Fast feedback ○ Fast project startup ○ Pick new ideas from application teams
  • 9. ● Node 4.x ● 200 applications and growing ● 80 million requests / day now 1 billion ● Platform team of 6 developers ● Very vibrant internal community ○ Local pool of knowledge among teams ○ Self sustaining support by internal community ○ PRs are welcome ○ 45 contributors to eBay NodeJS platform ● 80 platform modules ● 330 total modules
  • 10. ● More agile ○ Startup time <2s ○ Test coverage close to 90%-100% ○ Faster releases (every day) vs 2 weeks cycle ○ Automatic upgrades with semver ○ Modular UI architecture based on UI components ● Better tools ○ flame graphs, waterfall charts, pre-production testing ● Learnings Applied to Java Platform ○ Incorporate best practices from NodeJS ○ Startup time < 1 minute ○ Embrace modular approach and semver ○ Lighter Java stacks
  • 15. ● Experience Service ○ Provides view models for UI modules ○ View model is specific to the device type (native, size, desktop, tablet) ● NodeJS Web App ○ Talk to experience service ○ Handles UI functionality ○ Renders desktop and mobile web pages ● Native Apps ○ Talk to experience service via API gateway
  • 16. Module View pm2 node.js express (3 workers) platform-ebay analytics logging config service client lasso plugin app servicespages components kraken-js lasso/tessamarko
  • 17. Don’t Build Pages, Build Modules
  • 20.
  • 22. ● Async + streaming ● Custom tags ● Browser + Node.js runtime ● Lightweight ● Extremely fast ● Compiles to CommonJS markojs.com github.com/marko-js/marko github.com/marko-js/marko-widgets Templating UI components ● DOM diffing/patching ● Batched updates ● Stateful widgets ● Declarative event binding ● Efficient event delegation ● Lightweight runtime
  • 23. UI components built using Marko Widgets Uses Marko templates as the view. Plus: github.com/marko-js/marko-widgets ● DOM diffing/patching ● Batched updates ● Stateful widgets ● Declarative event binding ● Efficient event delegation ● Lightweight runtime
  • 25. Node is built on a streaming interface HTTP is a streaming protocol So why then do most templating and UI libraries render as a single chunk?
  • 26.
  • 27. ● Faster perceived page load ● Better time, resource and traffic utilization ● Progressive rendering between browser, frontend and backend ○ Frontend<->Backend: Stream of server side events (SSE) ○ Browser<->Frontend: Module render and flush on arrival ● Marko helps: ○ Async fragments support by marko-async ○ Re-order on client side
  • 28. Marko vs React: Server-side rendering github.com/patrick-steele-idem/marko-vs-react
  • 31. Why not use middleware pattern on the client?
  • 32. logging error handling analytics circuit breaker retry security/oauth http/https/sse serviceinvocationhandlers service client middlewares service web app request response cookies body-parser analytics
  • 33. ● Generic Service Client with pluggable handlers ● Handler performs a single function ● The handler pipeline is configurable per client
  • 34. Configuration based Code based "my-service-client": { "protocol": "http:", "hostname": "myservice.com", “path”: “/path/to/resource”, "port": 8080, "socketTimeout": 1000, "pipeline": [ "logging/handler", "circuit-breaker/handler", "error/handler" ] } var serviceClient = require(‘service-client’); serviceClient.use(require(‘logging/handler’)); serviceClient.use(require(‘circuit-breaker/handler’)); serviceClient.use(require(‘error/handler’)); serviceClient .get(‘http://myservice.com/path/to/resource’) .end((err, response) => { console.log(response.body); })
  • 36. Why not deploy everything at once?
  • 37. Resource Server App Server 1. GET http://www.ebay.com 2. GET http://rs/check/hp-24512.js 3. PUT http://rs/upload/hp-24512.js 4. <script src=”hp- 24512.js”> 5. GET http://hp- 24512.js 6. GET http://hp- 24512.js Akamai browser
  • 38. lasso.js/tessa JavaScript module bundler + asset pipeline github.com/lasso-js/lasso
  • 39. ● Supported resources ○ Defined by lasso plugins ○ CSS/JS/Images ○ Templates ○ I18n content ○ Bundle definition ● Lasso plugin ○ Adaptor between lasso and resource server ● Benefits ○ Single build and deployment ○ No synchronization problems between app and resource server deployments ○ Externalization at startup and during runtime on-the-fly
  • 42. ● Module configuration ○ Local, packaged with module ○ Remote, hot deployed ● Application configuration ○ Local ○ Remote, hot deployed ● Application can override any module configuration ● Configuration can be injected via Admin Console ● Future - Code and Config “separation”, but ○ Keep app and config together in git repo and separate at deployment. ○ Easier to manage
  • 43. i18n
  • 44. ● Use krakenjs/spud module ○ Property file format ○ Marko tags/helpers ● Externalizable as resources ● 17 main languages ● Support multiple languages per country ● Application and modules can have localizable content
  • 47. ● Nsp tool ○ On-demand scan for every application project ○ Security badge for every platform module ● ScanJS ○ Source code scan ● CSRF tokens ● Redirect validation ● XSS ● Rate limiter
  • 49. ● Logging every transaction/subtransaction ○ Central Logging Repository (CAL) provides log aggregation per pool/box/datacenter ○ Use Domains to maintain context per request and avoid passing it around ● Explicit code instrumentation ○ Support DEBUG, INFO, WARN, ERROR, FATAL ○ Time span to record transaction (start and end) ○ Nested spans ● Health checks/stats monitoring and alerts ● Crash/OOM emails to the owner of the pool ● Early problem detection using traffic mirror
  • 51. ● Proactive testing in pre-production ○ Traffic mirroring of read-only traffic to the box with new build ○ Easy upgrades ● Handling uncaught errors ○ Domains used to capture context ○ Send email to the owner with stack trace, group and box name, request info ○ Graceful restart ● Handling memory leaks ○ Email sent to the owner with group and box name, request info ○ Graceful restart when memory threshold is reached ● Too busy load shedding ○ 503 or connection reset to trigger browser DNS fallback ○ Filter bots traffic under heavy load ● Planning for failure ● Hystrix like service calls ○ Fail fast ○ Circuit breaker
  • 53. ● Fast startup/re-start ○ Cold cache to avoid service invocation ○ Pre-compiling template @ deployment ○ Pre-externalizing resources @ deployment ● Progressive rendering/streaming @ browser side ● Progressive chunking/streaming @ service side ● Performance tuning ○ Flame Graphs ○ Waterfall charts @ server side
  • 54. Marko vs React: Server-side rendering github.com/patrick-steele-idem/marko-vs-react
  • 55. Tools > Flame Graphs
  • 57. Why not use v8-profiler data?
  • 58. ● How to ○ Use v8-profiler to generate json data file ○ Aggregate stack frames into json ○ Render using d3-flame-graph ● No special environment ● No special steps ● Single button generation ● Can be used in production/dev/qa ● Exposes only javascript side of the code
  • 60. ● CPU profiling ● Troubleshooting in production the problem at hand ● Memory leak investigation ● Regular sampling
  • 64. ● Logs are hard to read ● Timestamps are hard to compare ● We need a faster tool?
  • 65. Why not use the same method used by developer tools in browser?
  • 67. ● Requires code instrumentation ● Easy and quick to assess what is going on ● Easy to spot synchronous events ● Analyze for possible task parallelization
  • 69. ● Latency, TCP_NODELAY=true ● Handling request close, finish, error events is important ● No dns cache out of the box ○ Use OS level caching to allow restarts ● Avoid modules with a state ● Embedding within App teams to bootstrap works great ● Use cold cache to keep restarts fast
  • 71. ● Version control ○ npm shrinkwrap does not guarantee versions ○ switched to Uber shrinkwrap ● App and platform coupling in one build ○ It is still monolithic, platform coupled to app ● Upgrading to major versions ○ Need to keep backwards compatible ○ Teams go at their own pace ● Memory leak analysis ● Debugging ○ Not stable, gets broken frequently
  • 72. So Far So Good
  • 74. ● 1 billion requests / day ● Decoupling platform from application ○ Moving platform components into separate processes ○ Independent platform deployments ○ More resilient apps ○ Problem isolation (easier memory leak detection) ● Platform microservices ● Docker ● Kubernetes ● SenecaJS ● NodeJS services
  • 75. References • Progressive rendering: http://www.ebaytechblog.com/2014/12/08/async-fragments- rediscovering-progressive-html-rendering-with-marko • AMP: http://www.ebaytechblog.com/2016/06/30/browse-ebay-with-style-and-speed/ - sse between frontend and backend - streaming • http://www.ebaytechblog.com/2016/06/15/igniting-node-js-flames/ • http://www.ebaytechblog.com/2016/07/14/mastering-the-fire/ • http://www.slideshare.net/tcng3716/ebay-architecture • Cloud http://www.computerweekly.com/news/2240222899/Case-study-How-eBay-uses-its- own-OpenStack-private-cloud • http://www.ebaytechblog.com/2014/10/02/dont-build-pages-build-modules/ • history: http://www.addsimplicity.com/downloads/eBaySDForum2006-11-29.pdf • lasso: https://www.npmjs.com/package/lasso • marko: http://markojs.com/ • https://github.com/spiermar/d3-flame-graph