APIs in minutes with Node.js 
Shubhra Kar 
Product Manager 
Oct 2014
Some StrongLoop personalities 
Bert Belder Ben Noordhuis Al Tsang Jimmy Guerrero 
Issac Roth John Higgins 
Raymond Feng Miroslav Bajtos Sam Roberts Ritchie Martori 
Ryan Graham 
Krishna Raman
3 
Jason Pressman Kiran Prasad 
Neil Day 
Nick Sturiale 
Paul Ambrose 
Marten Mickos 
Fortune 10 
retailer
The Frontend is changing (Mobile First !)
API Economy 
5 
Transaction 
Volume 
1 Billion 5 Billion 50 Billion 
API Endpoints 
Mashups 
SaaS 
Mobile 
IoT
Why APIs 
6 
SaaS Mobile IoT 
SOA 
Web 
App Server 
Database Datacube 
API Server 
HTML JSON
What’s needed ? Legacy services need to fit too ! 
API centric Enterprise 
Thousands to Millions of devices connecting to business APIs 
creating the new user experience 
APIs for each device, each app, each screen. Optimized for bandwidth & battery, 
adjusting to each device’s capabilities
Why Node? 
8 
Node is FAST 
…and highly concurrent! 
Node is perfect for APIs 
Node is JavaScript
What is Node.js? 
• Asynchronous, event-driven, non-blocking I/O platform that is perfect for real-time, 
data-intensive applications. 
• Single thread of execution 
• Built on Chrome’s JavaScript runtime engine, V8 
• Uses Libuv, a high performance evented I/O library that works on Linux and 
Windows (faster than Libev) 
while there are still events to process: 
e = get the next event 
if there is a callback associated with e: 
call the callback
Threads 
Don’t Wait !
Behind the Curtain 
Node Standard Library (JavaScript) 
Node Bindings C/C++ 
(socket, http, etc.) 
V8 
Libuv 
Libeio 
(thread pool) 
Libev 
(event loop) 
IOCP 
(IO 
completion 
ports) 
epoll/kqueue/poll (event 
ports) 
Linux Kernel 
Windows 
Kernel 
Yes, it’s C back there
Why Node.js? 
• Lots of JavaScript programmers out there (>62K) 
• Very large and active developer community 
• Has the most modules (90K > Java)
Why Node.js? 
LinkedIn moved from Rails to Node.js 
– Cut down servers by 90% (30  3) 
– Lower memory overhead and up to 20X faster 
PayPal migrated to Node.js from Java: 
– Reduce development time by >50% 
– 2X speed of delivery with less than existing resources 
– 33% lesser lines of code 
– 40% fewer files 
Groupon displaced Ruby and Java with Node.js across the board: 
– 50% improvement in page response times 
– Agile builds and deploys
Nodies are not just silicon valley hipsters ! 
And most recently…. 
Fortune 10 
Retailer
Why do 2 million developers 
Download Node.js every month?
Node vs Java for REST routing 
16
Node.. 
Roadmap past v0.12 
Upgrade v8 and debugger interface 
Flow Control 
– Promises, Generators, Zones, etc 
Error Reporting 
– Zones 
– Async-Tracker 
Enterprise Ops Integration 
– Logs, Monitoring, Build, Deploy, CI 
Ecosystem 
Reference deployments 
Concurrency 
17 
Breaking C++ API Changes
Async-tracker 
18
Async-tracker: get involved 
19
Ops integration 
20
Error tracking/recovery 
var http = require('http'); 
var cache = {}; 
function curl(url, cb) { 
if (cache[url]) 
return cb(null, cache[url]); 
var data = ''; 
http.get(url, function(res) { 
res.setEncoding('utf8'); 
res.on('data', function(s) { 
data += s; 
}); 
res.on('end', function() { 
cache[url] = data; 
cb(null, data); 
}); 
res.on('error', function(err) { 
cb(err); 
}); 
}); 
} 
// Usage: 
curl('http://www.google.com', console.log); 21
Error tracking/recovery 
var http = require('http'); 
var cache = {}; 
function curl(url, cb) { 
if (cache[url]) 
// WRONG: Synchronous callback 
return cb(null, cache[url]); 
var data = ''; 
http.get(url, function(res) { 
res.setEncoding('utf8'); 
res.on('data', function(s) { 
data += s; 
}); 
res.on('end', function() { 
cache[url] = data; 
cb(null, data); 
}); 
// WRONG: are you sure that 'end' and 'error' are mutually exclusive? 
res.on('error', function(err) { 
cb(err); 
}); 
}); 
// WRONG: the request object may emit 'error' 
} 
22
Error tracking/recovery 
23
Error tracking/recovery 
24
Error tracking/recovery 
25
Zones for Error cleanup 
strongloop.com/zone 
26
What’s coming in Express 
27 
Docs in 
markdown! 
https://github.com/strongloop/expressjs.com/issues
Strongloop and Node.js 
29
Loopback: Open Source API Framework in Node.js 
PUSH 
REST 
API 
GEO 
OFF 
SYNC 
DEVICE 
USER FILE 
Storage 
In-Memory 
REST 
API 
GATEWAY 
Channel SDKs 
CONNECT 
ORM 
API ENGINE 
D 
A 
T 
A 
M 
O 
D 
E 
L 
A 
P 
I 
S 
D 
K 
s 
REST API 
API 
Explorer 
Dev 
Ops 
ON-PREMISES / PRIVATE CLOUD / PUBLIC CLOUD
Upcoming API Gateway
API Gateway (Throttling, Proxy, OAuth) 
API Orchestrator 
Router 
Client SDK 
Isomorphic 
One URL Space 
Push 
API Micro Services 
Store Cache 
SL API PaaS 
Log 
Console 
Perf. 
Console 
Analytics 
Console 
Cloud 
Services 
REST/JSON 
ESB 
Micro-services Architecture 
Connectors 
Enterprise 
Services 
Standalone RDBMS NoSQL SOAP ERP 
Model 
---------- 
---------- 
---------- 
Model 
---------- 
---------- 
---------- 
Model 
---------- 
---------- 
---------- 
REMOTING 
C 
O 
N 
N 
E 
C 
T 
O 
R 
C 
O 
N 
N 
E 
C 
T 
O 
R 
REST 
Endpoints 
Store Cache
Upcoming Distributed Provisioning and Routing 
Provision and Deploy App 
Service Container 
Service Container 
Service Container 
Nginx (LB / SSL) 
Store (State) 
Master 
Worker Worker 
Controller 
Agent 
API Gateway (Routing, Throttling, 
Proxy, OAuth) 
Service Container 
Service Container 
Service Container 
Nginx (LB / SSL) 
Store (State) 
Master 
Worker Worker 
Controller 
Agent 
Store (Groups, Routes and 
State) and Scheduler Server 
REST/JSON 
Service 
Mgr (Exec.) 
Service 
Mgr.
Marquee Features 
Mobile SDKs Pre-Built Services ORM – no SQL 
Auto API Engine Enterprise Connectors API Gateway
Some cool features in Open Source 
Offline Sync & Replication 
Model Auto-Discovery and Relationship 
Connector
Automatic modeling and REST API generated
What’s coming in LoopBack 
GUI 
API Rate limiting 
OAuth 2.0 
Swagger 2.0 
37
& helps realize a full-stack JavaScript solution 
Develop 
Create UI & styling Arch. & binding Access Native Integrate Existing Data and Services 
Create Scaffolding 
Define base CSS 
Define components 
Use JS widgets 
Create Scaffolding 
Define Models 
Define Controllers 
Define Views 
Define Filters 
User 
Device 
File 
GeoLocation 
Notification 
Define Directives 
Configure Routes 
Connect to Data-sources (Oracle, SOAP, Mongo) 
Model the Data 
Generate REST API 
Configure API Security 
Setup Services 
Mobile App Mgmt. 
BLE
Node.js Platform Support 
39 
① Multi-platform (Windows, Unix, Solaris, Mac) support 
② On-premises, private or public cloud support 
③ Certified Node.js curated modules and ecosystem 
④ Commercial Enterprise supported, security updates 
node-inspector 
Passport 
Node-heapdump 
Node.js Core 
Loopback Strong-mq 
strong-cluster-control 
SL-Config 
strong-module- 
loader 
strong-cluster-connect- 
store 
strong-task-emitter 
Engine.io 
Mongoose 
Strong-agent strong-cluster-socket. 
io-store 
Asynch 
strong-config-loader 
Request 
Strong-remoting 
Q 
Connect 
Express 
EJS 
Socket.IO 
Reggie Postgres 
Connector 
Oracle 
Connector 
SQL Server 
Connector 
MongoDB 
Connector 
REST 
Connector 
In-Memory 
connector 
LIBUV 
V8 Profiler
DevOps Tools – Debugging
DevOps Tools – Runtime Mgmt. & Dynamic Scaling
DevOps Tools - Profilers
DevOps Tools - Performance Monitoring
StrongLoop’s commercial business 
Support 
Security subscription 
Training 
Consulting 
API Gateway 
strong-agent – Monitoring 
Connectors to enterprise systems 
API Microservices Mesh Controller

StrongLoop Overview

  • 1.
    APIs in minuteswith Node.js Shubhra Kar Product Manager Oct 2014
  • 2.
    Some StrongLoop personalities Bert Belder Ben Noordhuis Al Tsang Jimmy Guerrero Issac Roth John Higgins Raymond Feng Miroslav Bajtos Sam Roberts Ritchie Martori Ryan Graham Krishna Raman
  • 3.
    3 Jason PressmanKiran Prasad Neil Day Nick Sturiale Paul Ambrose Marten Mickos Fortune 10 retailer
  • 4.
    The Frontend ischanging (Mobile First !)
  • 5.
    API Economy 5 Transaction Volume 1 Billion 5 Billion 50 Billion API Endpoints Mashups SaaS Mobile IoT
  • 6.
    Why APIs 6 SaaS Mobile IoT SOA Web App Server Database Datacube API Server HTML JSON
  • 7.
    What’s needed ?Legacy services need to fit too ! API centric Enterprise Thousands to Millions of devices connecting to business APIs creating the new user experience APIs for each device, each app, each screen. Optimized for bandwidth & battery, adjusting to each device’s capabilities
  • 8.
    Why Node? 8 Node is FAST …and highly concurrent! Node is perfect for APIs Node is JavaScript
  • 9.
    What is Node.js? • Asynchronous, event-driven, non-blocking I/O platform that is perfect for real-time, data-intensive applications. • Single thread of execution • Built on Chrome’s JavaScript runtime engine, V8 • Uses Libuv, a high performance evented I/O library that works on Linux and Windows (faster than Libev) while there are still events to process: e = get the next event if there is a callback associated with e: call the callback
  • 10.
  • 11.
    Behind the Curtain Node Standard Library (JavaScript) Node Bindings C/C++ (socket, http, etc.) V8 Libuv Libeio (thread pool) Libev (event loop) IOCP (IO completion ports) epoll/kqueue/poll (event ports) Linux Kernel Windows Kernel Yes, it’s C back there
  • 12.
    Why Node.js? •Lots of JavaScript programmers out there (>62K) • Very large and active developer community • Has the most modules (90K > Java)
  • 13.
    Why Node.js? LinkedInmoved from Rails to Node.js – Cut down servers by 90% (30  3) – Lower memory overhead and up to 20X faster PayPal migrated to Node.js from Java: – Reduce development time by >50% – 2X speed of delivery with less than existing resources – 33% lesser lines of code – 40% fewer files Groupon displaced Ruby and Java with Node.js across the board: – 50% improvement in page response times – Agile builds and deploys
  • 14.
    Nodies are notjust silicon valley hipsters ! And most recently…. Fortune 10 Retailer
  • 15.
    Why do 2million developers Download Node.js every month?
  • 16.
    Node vs Javafor REST routing 16
  • 17.
    Node.. Roadmap pastv0.12 Upgrade v8 and debugger interface Flow Control – Promises, Generators, Zones, etc Error Reporting – Zones – Async-Tracker Enterprise Ops Integration – Logs, Monitoring, Build, Deploy, CI Ecosystem Reference deployments Concurrency 17 Breaking C++ API Changes
  • 18.
  • 19.
  • 20.
  • 21.
    Error tracking/recovery varhttp = require('http'); var cache = {}; function curl(url, cb) { if (cache[url]) return cb(null, cache[url]); var data = ''; http.get(url, function(res) { res.setEncoding('utf8'); res.on('data', function(s) { data += s; }); res.on('end', function() { cache[url] = data; cb(null, data); }); res.on('error', function(err) { cb(err); }); }); } // Usage: curl('http://www.google.com', console.log); 21
  • 22.
    Error tracking/recovery varhttp = require('http'); var cache = {}; function curl(url, cb) { if (cache[url]) // WRONG: Synchronous callback return cb(null, cache[url]); var data = ''; http.get(url, function(res) { res.setEncoding('utf8'); res.on('data', function(s) { data += s; }); res.on('end', function() { cache[url] = data; cb(null, data); }); // WRONG: are you sure that 'end' and 'error' are mutually exclusive? res.on('error', function(err) { cb(err); }); }); // WRONG: the request object may emit 'error' } 22
  • 23.
  • 24.
  • 25.
  • 26.
    Zones for Errorcleanup strongloop.com/zone 26
  • 27.
    What’s coming inExpress 27 Docs in markdown! https://github.com/strongloop/expressjs.com/issues
  • 29.
  • 30.
    Loopback: Open SourceAPI Framework in Node.js PUSH REST API GEO OFF SYNC DEVICE USER FILE Storage In-Memory REST API GATEWAY Channel SDKs CONNECT ORM API ENGINE D A T A M O D E L A P I S D K s REST API API Explorer Dev Ops ON-PREMISES / PRIVATE CLOUD / PUBLIC CLOUD
  • 31.
  • 32.
    API Gateway (Throttling,Proxy, OAuth) API Orchestrator Router Client SDK Isomorphic One URL Space Push API Micro Services Store Cache SL API PaaS Log Console Perf. Console Analytics Console Cloud Services REST/JSON ESB Micro-services Architecture Connectors Enterprise Services Standalone RDBMS NoSQL SOAP ERP Model ---------- ---------- ---------- Model ---------- ---------- ---------- Model ---------- ---------- ---------- REMOTING C O N N E C T O R C O N N E C T O R REST Endpoints Store Cache
  • 33.
    Upcoming Distributed Provisioningand Routing Provision and Deploy App Service Container Service Container Service Container Nginx (LB / SSL) Store (State) Master Worker Worker Controller Agent API Gateway (Routing, Throttling, Proxy, OAuth) Service Container Service Container Service Container Nginx (LB / SSL) Store (State) Master Worker Worker Controller Agent Store (Groups, Routes and State) and Scheduler Server REST/JSON Service Mgr (Exec.) Service Mgr.
  • 34.
    Marquee Features MobileSDKs Pre-Built Services ORM – no SQL Auto API Engine Enterprise Connectors API Gateway
  • 35.
    Some cool featuresin Open Source Offline Sync & Replication Model Auto-Discovery and Relationship Connector
  • 36.
    Automatic modeling andREST API generated
  • 37.
    What’s coming inLoopBack GUI API Rate limiting OAuth 2.0 Swagger 2.0 37
  • 38.
    & helps realizea full-stack JavaScript solution Develop Create UI & styling Arch. & binding Access Native Integrate Existing Data and Services Create Scaffolding Define base CSS Define components Use JS widgets Create Scaffolding Define Models Define Controllers Define Views Define Filters User Device File GeoLocation Notification Define Directives Configure Routes Connect to Data-sources (Oracle, SOAP, Mongo) Model the Data Generate REST API Configure API Security Setup Services Mobile App Mgmt. BLE
  • 39.
    Node.js Platform Support 39 ① Multi-platform (Windows, Unix, Solaris, Mac) support ② On-premises, private or public cloud support ③ Certified Node.js curated modules and ecosystem ④ Commercial Enterprise supported, security updates node-inspector Passport Node-heapdump Node.js Core Loopback Strong-mq strong-cluster-control SL-Config strong-module- loader strong-cluster-connect- store strong-task-emitter Engine.io Mongoose Strong-agent strong-cluster-socket. io-store Asynch strong-config-loader Request Strong-remoting Q Connect Express EJS Socket.IO Reggie Postgres Connector Oracle Connector SQL Server Connector MongoDB Connector REST Connector In-Memory connector LIBUV V8 Profiler
  • 40.
  • 41.
    DevOps Tools –Runtime Mgmt. & Dynamic Scaling
  • 42.
    DevOps Tools -Profilers
  • 43.
    DevOps Tools -Performance Monitoring
  • 44.
    StrongLoop’s commercial business Support Security subscription Training Consulting API Gateway strong-agent – Monitoring Connectors to enterprise systems API Microservices Mesh Controller

Editor's Notes

  • #4 Jason Pressman Nick – Ignition, Splunk Neil – Walmart Kiran – LinkedIn Marten – MySQL, Eucalyptus Paul – WebLogic Juan Carlos – Informatica
  • #12 Libuv: Full-featured event loop backed by epoll, kqueue, IOCP, event ports. Asynchronous TCP and UDP sockets Asynchronous DNS resolution Asynchronous file and file system operations File system events ANSI escape code controlled TTY IPC with socket sharing, using Unix domain sockets or named pipes (Windows) Child processes Thread pool Signal handling High resolution clock Threading and synchronization primitives
  • #14  https://www.paypal-engineering.com/2013/11/22/node-js-at-paypal/ https://engineering.groupon.com/2013/misc/i-tier-dismantling-the-monoliths/#more-1551