Upload
shubhra-kar
View
730
Download
1
Embed Size (px)
Citation preview
APIs in minutes with Node.js
Shubhra Kar Product Manager
Oct 2014
Some StrongLoop personalities
Ben Noordhuis
Al Tsang Jimmy GuerreroBert Belder
Ryan GrahamKrishna Raman
Ritchie Martori
Sam RobertsMiroslav Bajtos
Raymond Feng
John HigginsIssac Roth
3
Jason Pressman Kiran Prasad
Neil Day
Nick Sturiale
Paul Ambrose
Marten Mickos
Fortune 10 retailer
The Frontend is changing (Mobile First !)
5
API Economy
Transaction Volume
API Endpoints
Mashups
SaaS
Mobile
IoT
1 Billion 5 Billion 50 Billion
6
Why APIs
SaaS Mobile IoT
SOA
Web
App Server
Database Datacube
API Server
HTML JSON
What’s needed ? Legacy services need to fit too !
API centric EnterpriseThousands 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?
Node is FAST
Node is perfect for APIs
Node is JavaScript
…and highly concurrent!
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 eventif there is a callback associated
with e: call the callback
Threads Don’t Wait !
Behind the Curtain
Node Bindings C/C++(socket, http, etc.)
V8
Libuv
Libeio(thread pool)
Libev(event loop)
IOCP(IO
completion ports)
Node Standard Library (JavaScript)
epoll/kqueue/poll (event ports)
Linux Kernel
Windows
KernelYes, 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)
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
Why Node.js?
Nodies are not just silicon valley hipsters !
And most recently….Fortune 10Retailer
Why do 2 million developers Download Node.js every month?
16
Node vs Java for REST routing
17
Node..
Roadmap past v0.12
Upgrade v8 and debugger interfaceFlow Control– Promises, Generators, Zones, etc
Error Reporting– Zones– Async-Tracker
Enterprise Ops Integration– Logs, Monitoring, Build, Deploy, CI
EcosystemReference deploymentsConcurrency
Breaking C++ API Changes
18
Async-tracker
19
Async-tracker: get involved
20
Ops integration
21
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);
22
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'}
23
Error tracking/recovery
24
Error tracking/recovery
25
Error tracking/recovery
26
Zones for Error cleanup
strongloop.com/zone
27
What’s coming in Express
https://github.com/strongloop/expressjs.com/issues
Docs in markdown!
Strongloop and Node.js
29
RESTAPI
PUSH
GEOOFF
SYNC
DEVICE
USER FILE
Storage
In-Memory
REST
APIGATEWAY
Channel SDKs
CONNECTORM
API ENGINE
DATAMODEL
API
SDKs
Loopback: Open Source API Framework in Node.js
REST API
APIExplorer
DevOps
ON-PREMISES / PRIVATE CLOUD / PUBLIC CLOUD
Upcoming API Gateway
API Orchestrator
Router
Client SDK
Isomorphic
One URL Space
Push
API Micro Services
Store Cache
SL API PaaS
Log Console
Perf.Console
Analytics
Console
CloudService
s
REST/JSON
API Gateway (Throttling, Proxy, OAuth)
ESB
RDBMS NoSQL SOAPStandalone ERP
ConnectorsEnterprise Services
Model------------------------------
Model------------------------------
Model------------------------------
REMOTING
CONNEC TOR
CONNEC TOR
RESTEndpoints
Micro-services Architecture
Store Cache
Service Container
Upcoming Distributed Provisioning and Routing
Nginx (LB / SSL)
Sto
re (S
tate
)
Master
Service Container
Worker
Worker
Controller
Agent
Service Container
Service Container
Nginx (LB / SSL)
Sto
re (S
tate
)
Master
Service Container
Worker
Worker
Controller
Agent
Service Container
Store (Groups, Routes and State) and Scheduler
Server
Provision and Deploy App
REST/JSON
API Gateway (Routing, Throttling, Proxy, OAuth)
ServiceMgr
(Exec.)Service
Mgr.
Marquee Features
Mobile SDKs Pre-Built Services ORM – no SQL
Enterprise ConnectorsAuto API Engine API Gateway
Some cool features in Open Source
Offline Sync & Replication
Model Auto-Discovery and Relationship
Connector
Automatic modeling and REST API generated
37
What’s coming in LoopBack
GUIAPI Rate limitingOAuth 2.0 Swagger 2.0
& helps realize a full-stack JavaScript solution
Develop
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
Model the Data
Generate REST API
Connect to Data-sources (Oracle, SOAP, Mongo)
Setup Services
Configure API Security
Mobile App Mgmt.
Create UI & styling Arch. & binding Access Native Integrate Existing Data and Services
BLE
Node.js Platform Support
39
Node.js Core
strong-module-loader
strong-cluster-connect-
store
strong-cluster-control
SL-Config
Loopback Strong-mq
strong-task-emitter
Engine.io Mongoose
Strong-agent
strong-cluster-
socket.io-store
strong-config-loader
Request
Node-heapdump
Asynch
node-inspector
Passport
Strong-remoting
Q
EJS
Express
Connect
Socket.IO
Reggie Postgres Connector
Oracle Connector
SQL ServerConnector
MongoDBConnector
REST Connector
In-Memory connector
LIBUV
V8 Profiler
① 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
DevOps Tools – Debugging
DevOps Tools – Runtime Mgmt. & Dynamic Scaling
DevOps Tools - Profilers
DevOps Tools - Performance Monitoring
StrongLoop’s commercial business
SupportSecurity subscriptionTrainingConsultingAPI Gatewaystrong-agent – MonitoringConnectors to enterprise systemsAPI Microservices Mesh Controller