Restful web services with nodejs

4,363 views
4,154 views

Published on

Node.js (Node) , the brain child of Ryan Dahl, was released in 2009 when he worked for Joyent, Inc. Node is one of the most hyped technologies to arrive on the web development scene, though it is also one of the most misunderstood.

So what is Node? Is it a programming language like Python, Java, or C++? Is it an application framework like Django, Rails, or Symphony? Is it maybe some type of middleware that can be plugged into existing web stacks like Memcached or RabbitMQ? Actually, it is none of the above. Node is simply a set of JavaScript language bindings to Google's powerful V8 engine. This begs the question: "what is a language binding and what is V8?"

This presentation introduces Node from an architectural perspective by discussing its implementation followed by a practical demonstration of how to build an application using it through a real-world example. Michael Filbin of Aspenware explains how Ryan liberated JavaScript from the browser and brought the power of event-driven, non-blocked programming to every developer by using the world's most popular programming language.

Published in: Technology
0 Comments
6 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,363
On SlideShare
0
From Embeds
0
Number of Embeds
80
Actions
Shares
0
Downloads
85
Comments
0
Likes
6
Embeds 0
No embeds

No notes for slide
  • ConcurrencyHandle multiple requests simultaneously and gracefullyManage memory for each request efficientlyLatencyThe delay between in computing cycles between instruction executionComputationally intensive tasks may induce grater latency (blocking)ComplexityImplementing parallel computing is difficultThread managementRace conditionsContention for locked structuresThread deadlocksStabilityUsing event loops avoids the need for multithreadingMemory utilization is stable as request frequency increases
  • Restful web services with nodejs

    1. 1. 6000 Greenwood Plaza Blvd Suite 110 Greenwood Village, CO 80111 303.798.5458 www.aspenware.comRESTful WebServiceswith Node.js Michael Filbin m.filbin@aspenware.com
    2. 2. Brief Introductionto NodeRESTful Web Serviceswith Node.js
    3. 3. 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 https://github.com/joyent/node/wiki/Projects,-Applications,-and-Companies-Using-NodeRESTful Web Services Brief Introduction to Nodewith Node.js
    4. 4. 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-onsRESTful Web Services Brief Introduction to Nodewith Node.js
    5. 5. What problems does it solve?• Concurrency• Latency• Complexity• StabilityRESTful Web Services Brief Introduction to Nodewith Node.js
    6. 6. Token Example:• Apache utilize multi-threading• Nginx utilizes asynchronous I/O C10K problem – Dan KegelRESTful Web Services Brief Introduction to Nodewith Node.js
    7. 7. RESTful Web Services Brief Introduction to Nodewith Node.js
    8. 8. RESTful Web Services Brief Introduction to Nodewith Node.js
    9. 9. 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 clientRESTful Web Services Brief Introduction to Nodewith Node.js
    10. 10. 2.5 × 10 8 2.4 x 10 8 Network 2 × 10 8 1.5 × 10 8 Com puting Cycles 1 × 10 8 4.1 x 10 7 5 × 10 7 Disk 3 cycles 14 cycles 240 cycles L1 Cache L2 Cache RAM 0 ProcessRESTful Web Services Brief Introduction to Nodewith Node.js
    11. 11. Paradigm change doesn’t have to be difficult…RESTful Web Services Brief Introduction to Nodewith Node.js
    12. 12. 1 $(#login).bind(’click, function(event){ 2 event.preventDefault(); 3 // Do something interesting 4 });RESTful Web Services Brief Introduction to Nodewith Node.js
    13. 13. RESTful Web Services Brief Introduction to Nodewith Node.js
    14. 14. Shouting MatchRESTful Web Serviceswith Node.js
    15. 15. 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 Services Shouting Matchwith Node.js
    16. 16. Project Constraints: • Crowd-source data • No way to authenticate users • Distributed development team • Simple deployment strategy • Very little time • Request throttlingRESTful Web Services Section Title Goes Herewith Node.js
    17. 17. Technology Used: • Express application framework • Coffeescript • Jade markup templates • Less CSS preprocessor • “Twit” twitter client • “js-yaml” YAML parser • Mocha testing framwork • Chai DSLRESTful Web Services Shouting Matchwith Node.js
    18. 18. ConclusionRESTful Web Serviceswith Node.js
    19. 19. Summation & Thank you’s: • Node is • not a fad… • not the answer to all your problems • gives you flexibility • fun to useRESTful Web Services Conclusionwith Node.js
    20. 20. More on Shouting Match: Rob Clark Mike Filbin Adam Roderick # 1130 # 1610 # 1204 16:30 – 17:30 09:30 – 10:30 10:45 – 11:45 Application A new Photoshop RESTful Services architecture using workflow with Node.js Backbone and NodeRESTful Web Services Conclusionwith Node.js
    21. 21. 6000 Greenwood Plaza Blvd Suite 110 Greenwood Village, CO 80111 303.798.5458 www.aspenware.comMichaelFilbinThis 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 m.filbin@aspenware.com

    ×