cubejs: ebay’s node.js adoption journey

31
CUBEJS: EBAY’S NODE.JS ADOPTION JOURNEY @

Upload: patrick-steele-idem

Post on 17-May-2015

6.597 views

Category:

Technology


1 download

DESCRIPTION

CubeJS is a Node.js based application development platform at eBay. In this presentation, we will share our journey to build and launch this new platform at the eBay Marketplaces. We will discuss CubeJS’ overall architecture, versatile functionalities, robust operationalization, and streamlined development lifecycle process, as well as its customer adoption momentum in the company. We will also share a number of high-profile projects, powered on CubeJS, to be debuted by eBay Inc. ranging from Web to Mobile.

TRANSCRIPT

Page 1: CubeJS: eBay’s Node.js Adoption Journey

CUBEJS:EBAY’S NODE.JS ADOPTION JOURNEY

@

Page 2: CubeJS: eBay’s Node.js Adoption Journey

Patrick Steele-Idem

@psteeleidem

[email protected]

github.com/patrick-steele-idem

Senior Platform Architect @

Page 3: CubeJS: eBay’s Node.js Adoption Journey

EBAY HAS EMBRACED NODE.JS…SO HOW DID WE GET HERE?

Page 4: CubeJS: eBay’s Node.js Adoption Journey

BEFORE NODE.JS, JAVA WAS KING

BUT THINGS EVOLVED…

XML + XSLT JAVAPROPRIETARY OPEN SOURCEONE LANGUAGE POLYGLOTONE IDE ANY EDITOR/IDE

HEAVY FRONT-END LIGHTWEIGHT FRONT-ENDCLEARCASE GIT + GITHUB

SLOW DEVELOPMENT RAPID DEVELOPMENTJAVA APIS SERVICE APIS

Page 5: CubeJS: eBay’s Node.js Adoption Journey

“A DECLARATIVE, DATA-RETRIEVAL AND AGGREGATION GATEWAY FOR QUICKLY

CONSUMING HTTP APIS”…BUILT USING NODE.JS

WHY NODE.JS?• Non-blocking I/O

• Single-threaded

Page 6: CubeJS: eBay’s Node.js Adoption Journey

NODE.JS IS GREAT, BUT CAN EBAY USE IT TO

BUILD FRONT-ENDS AS WELL?

Page 7: CubeJS: eBay’s Node.js Adoption Journey

WHY NODE.JS FOR THE FRONT-END?DEVELOPER AGILITY, SCALABILITY

AND PERFORMANCE

“My advice: always bet on JavaScript”–Brendan Eich

Page 8: CubeJS: eBay’s Node.js Adoption Journey

WHAT IS REQUIRED TO SUPPORTNODE.JS AT EBAY?

MonitoringEncryption/Decryption

Resource Optimization

Tracking

Deployment

Look & Feel

Security

CSRF

Authentication

Personalization

Tools

Testing

Release Process

ConfigurationREST

SOAP

I18n

Logging App MetadataScalability

Page 9: CubeJS: eBay’s Node.js Adoption Journey

POLYGLOT CHALLENGE:HUGE INVESTMENT IN JAVA CODE

Possible Solutions Pros Cons

Port code to JavaScript

• Works for Node.js• Easy to debug

• Tedious• Error prone• What about Python, Ruby,

etc.?

Expose as a service • Polyglot friendly • Latency• Monitoring• Network Failures• Infrastructure

Port code to C/C++ • Fast• Bindings available

• Difficult to debug• Difficult to maintain

JVM ↔ JavaScript Bridge

• Polyglot friendly • Difficult to debug• Slower startup• Monitoring multiple VMs

Page 10: CubeJS: eBay’s Node.js Adoption Journey

1ST CHOICE: EXPOSE AS A SERVICEMAXIMIZE CODE REUSE

CALLS CAN BE MADE IN PARALLEL

2ND CHOICE: PORT CODE TO JAVASCRIPTPERFORMANCE CRITICALBEST HANDLED LOCALLY

Page 11: CubeJS: eBay’s Node.js Adoption Journey

DistributedLogging

ResourceServer

Application Layer Infrastructure Layer

Tracking

Client Layer

RUNTIME ARCHITECTURE

App Service Layer

Search

clus

ter2

Page 12: CubeJS: eBay’s Node.js Adoption Journey

DEVELOPMENT AND DEPLOYMENT INFRASTRUCTURE

an initiativeModule Packages

Private npm

Public npm

Source Code

Startup scripts

npm-delegate

powered by:

Page 13: CubeJS: eBay’s Node.js Adoption Journey

DESIGN GOAL:MAXIMIZE DEVELOPER PRODUCTIVITY

Page 14: CubeJS: eBay’s Node.js Adoption Journey

DESIGN GOAL: MAXIMIZE DEVELOPER PRODUCTIVITY

Small, bite-sized and easy-to-digest modules

Keep the documentation with the code.README files for the win

Encourage contributions

Page 15: CubeJS: eBay’s Node.js Adoption Journey

DESIGN GOAL: MAXIMIZE DEVELOPER PRODUCTIVITY

Avoid “magic”If developers cannot reason about a system

then they will not be happy or productive.

Do not be a restrictive frameworkDevelopers love options and being able to

use the latest and greatest.

Page 16: CubeJS: eBay’s Node.js Adoption Journey

DESIGN GOAL: MAXIMIZE DEVELOPER PRODUCTIVITY

+ File Watching+ Hot Reloading+ Web Sockets

Live CodingInstant Gratification

Web Development is Fun Again

CHECKOUT:• hot-reload https://github.com/philidem/node-hot-reload• socket.io http://socket.io/

Page 17: CubeJS: eBay’s Node.js Adoption Journey

NO BUILD STEP FOR RESOURCE OPTIMIZATION!

DESIGN GOAL: MAXIMIZE DEVELOPER PRODUCTIVITY

MORE INFO:• RaptorJS Optimizer: http://raptorjs.org/optimizer/

Resource bundling, minification, compilation, externalization—all at runtime.

Compile Raptor Templates, LESS, Dust, CoffeeScript, etc.

Page 18: CubeJS: eBay’s Node.js Adoption Journey

Command Line ToolsPowered by Rápido

DESIGN GOAL: MAXIMIZE DEVELOPER PRODUCTIVITY

CHECKOUT:Rápido: https://github.com/raptorjs/rapido

Features• Module and application lifecycle• Scaffolding• IDE/editor independence• PaaS integration• Jenkins CI integration• Command-line auto-completion• Colorized output

Example:ecube create appecube create pageecube registerecube create poolecube publishecube deploy

Page 19: CubeJS: eBay’s Node.js Adoption Journey

DESIGN GOAL:HIGH PERFORMANCE

Page 20: CubeJS: eBay’s Node.js Adoption Journey

PERFORMANCE IS GREAT*• Node.js provides a very low-level programming platform

• V8 is a powerful and fast JavaScript engine

• Node.js can be extended with C/C++ libraries

• Clustering based on OS-level socket sharing

• High performance evented I/O at its core (libuv)

• Single-threaded so no synchronization issues or locks

* The not-so-great:

• Garbage collection is slow

• Memory usage can easily get out of control

DESIGN GOAL: HIGH PERFORMANCE

Page 21: CubeJS: eBay’s Node.js Adoption Journey

STREAMING, ASYNCHRONOUS UI RENDERING

• Why?

• Start rendering the template immediately• Give the browser a head start• Let the template drive the data• Minimize idle time on the server

DESIGN GOAL: HIGH PERFORMANCE

Page 22: CubeJS: eBay’s Node.js Adoption Journey

HTMLTemplate

ASYNCHRONOUS UI RENDERINGDESIGN GOAL: HIGH PERFORMANCE

Tra

dit

ion

alC

ub

eJS

View Model

No Delay

Data Providers

1. Setup data providers2. Go straight to the

template!

ControllerInput

HTMLTemplateView Model

Long Delay

ControllerInput

1. Make service calls2. Wait for all data to come back3. Prepare view model

Page 23: CubeJS: eBay’s Node.js Adoption Journey

Raptor TemplatesExtensible, high performance, asynchronous

template rendering engine for JavaScript that works on both the server and the client

DESIGN GOAL: HIGH PERFORMANCE

MORE INFO:Raptor Templates: http://raptorjs.org/raptor-templates/

Page 24: CubeJS: eBay’s Node.js Adoption Journey

DESIGN GOAL:ROBUST

Page 25: CubeJS: eBay’s Node.js Adoption Journey

cluster2DESIGN GOAL: ROBUST

MORE INFO:https://github.com/cubejs/cluster2

• Multi-process cluster management• Live production debugging• Monitoring• Idle timeouts• Pause and resume (out-of-traffic GC!)• Process warm-up (coming soon)• Shared cache (coming soon)

Page 26: CubeJS: eBay’s Node.js Adoption Journey

Monitoring Infrastructure

DESIGN GOAL: ROBUST

Adapted to eBay Ops Monitoring Tools

Page 27: CubeJS: eBay’s Node.js Adoption Journey

Automated Testing

DESIGN GOAL: ROBUST

• Netmorphic

• Simulate network failures and slowness• Mocha

• Asynchronous tests• Code coverage reporting

• JSHint

• Flexible JavaScript static code analysis tool• Casper + PhantomJS (in-progress)

• Headless browser testing• Jenkins CI

Page 28: CubeJS: eBay’s Node.js Adoption Journey

Configuration Management

DESIGN GOAL: ROBUST

• Per-module configuration

• Real-time configuration updates

• Configuration repository based on MongoDB

Page 29: CubeJS: eBay’s Node.js Adoption Journey

ASYNCHRONOUS PROGRAMMING USING PROMISES

All CubeJS modules have standardized on promises for asynchronous programming.

Example:

Q()

.then(loadUserPreferences)

.then(performSearch)

.then(renderSearchResults)

.fail(function(error) {

res.end();

console.error("Something went wrong!")

})

Page 30: CubeJS: eBay’s Node.js Adoption Journey

ADOPTION:PULL RATHER THAN PUSH

• 10+ customers before CubeJS goes GA

• Several live CubeJS applications running in production

• Overwhelming attendance of CubeJS Tech Talks

• “Word of Mouth” spreading within eBay application teams

• No need to push

Page 31: CubeJS: eBay’s Node.js Adoption Journey

QUESTIONS?

[email protected]@psteeleidem

https://github.com/cubejshttp://raptorjs.org