6000 Greenwood Plaza BlvdSuite 110Greenwood Village, CO 80111303.798.5458
www.aspenware.com
RESTful Web Serviceswith Node.js Michael Filbin
RESTful Web Serviceswith Node.js
Brief Introduction to Node
What is Node.js?• A set of bindings to Google’s V8 JavaScript engine• Originally intended creating asynchronous TCP
servers• Other use cases:
• Web application frameworks• Language interpreters/preprocessors• Command-line interface utilities8
Brief Introduction to Node
https://github.com/joyent/node/wiki/Projects,-Applications,-and-Companies-Using-Node
RESTful Web Serviceswith Node.js
Node Architecture?• Standard Library is written in JavaScript• JS binding written in C/C++• Single-threaded• Event-driven• Non-blocking I/O• Modular dependency system• Allows for extension through C/C++ add-ons
RESTful Web Serviceswith Node.js
Brief Introduction to Node
What problems does it solve?• Concurrency• Latency• Complexity• Stability
RESTful Web Serviceswith Node.js
Brief Introduction to Node
Token Example:• Apache utilize multi-threading• Nginx utilizes asynchronous I/O
C10K problem – Dan Kegel
RESTful Web Serviceswith Node.js
Brief Introduction to Node
RESTful Web Serviceswith Node.js
Brief Introduction to Node
RESTful Web Serviceswith Node.js
Brief Introduction to Node
What is Asynchronous I/O?• Using an event loop
• Request is received• Non-IO operations return immediately• IO operations defer to system asych API
(epoll, kqueue, select)• IO interrupt received and callback is executed• Data returned to client
Brief Introduction to NodeRESTful Web Serviceswith Node.js
Brief Introduction to NodeRESTful Web Serviceswith Node.js
Paradigm change doesn’t have to be difficult…
Brief Introduction to NodeRESTful Web Serviceswith Node.js
1 $('#login').bind(’click', function(event){2 event.preventDefault();3 // Do something interesting4 });
RESTful Web Serviceswith Node.js
Brief Introduction to Node
RESTful Web Serviceswith Node.js
Brief Introduction to Node
RESTful Web Serviceswith Node.js
Shouting Match
Project Goals:• Single-page application• Server calls completely asynchronous• Utilize web sockets for real-time updates• RESTful service tier• More than just “Hello World”
RESTful Web Serviceswith Node.js
Shouting Match
Project Constraints:
Section Title Goes Here
• Crowd-source data• No way to authenticate users• Distributed development team• Simple deployment strategy• Very little time• Request throttling
RESTful Web Serviceswith Node.js
Technology Used:• Express application framework• Coffeescript• Jade markup templates• Less CSS preprocessor• “Twit” twitter client• “js-yaml” YAML parser• Mocha testing framwork• Chai DSL
RESTful Web Serviceswith Node.js
Shouting Match
RESTful Web Serviceswith Node.js
Conclusion
Summation & Thank you’s:
Conclusion
• Node is • not a fad…• not the answer to all your problems• gives you flexibility• fun to use
RESTful Web Serviceswith Node.js
More on Shouting Match:
Conclusion
Rob Clark Mike Filbin Adam Roderick
# 161009:30 – 10:30
A new Photoshop workflow
# 120410:45 – 11:45
RESTful Services with Node.js
# 113016:30 – 17:30
Application architecture using
Backbone and Node
RESTful Web Serviceswith Node.js
6000 Greenwood Plaza BlvdSuite 110Greenwood Village, CO 80111303.798.5458
www.aspenware.com
MichaelFilbinThis is where you can put your biographical info, buttry to keep it short otherwise it’ll push the signature too low.
Michael Filbin, Software Developer [email protected]