Your SlideShare is downloading. ×
0
Nodejs @ Yahoo
Nodejs @ Yahoo
Nodejs @ Yahoo
Nodejs @ Yahoo
Nodejs @ Yahoo
Nodejs @ Yahoo
Nodejs @ Yahoo
Nodejs @ Yahoo
Nodejs @ Yahoo
Nodejs @ Yahoo
Nodejs @ Yahoo
Nodejs @ Yahoo
Nodejs @ Yahoo
Nodejs @ Yahoo
Nodejs @ Yahoo
Nodejs @ Yahoo
Nodejs @ Yahoo
Nodejs @ Yahoo
Nodejs @ Yahoo
Nodejs @ Yahoo
Nodejs @ Yahoo
Nodejs @ Yahoo
Nodejs @ Yahoo
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Nodejs @ Yahoo

1,465

Published on

Presentation given as an internal tech talk to share our early Node.js efforts and experience in our Beijing R&D Center.

Presentation given as an internal tech talk to share our early Node.js efforts and experience in our Beijing R&D Center.

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

No Downloads
Views
Total Views
1,465
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
24
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript

    • 1. @ Yahoo! Fabian Frank <frankfa@yahoo-inc.com>UIE Front-End: Search Direct, SearchX (PHP, node.js) spare time: youthmedia.eu (Rails)
    • 2. ????????
    • 3. Prefork/Worker Model• A set of N workers (Threads, Processes)• An incoming connection is assigned to a worker and the worker is now “in use” until the connection drops, even if it is only waiting• OS timesharing enables serving much more connections at the same time than CPUs are available, at the expense of context switching• If all workers are in use, incoming connection waits (and average response time rockets)
    • 4. non-blocking IO has been around for a long time• int read(int FD, char* buf, int len); • returns after reading at least 1 byte • what one uses normally• int aio_read(struct aiocb* {int FD; char* buf; int len}); • use aio_error(struct aiocb*) to check if the read finished, if yes then call aio_return() • select or kqueue appeared later (year 2000)
    • 5. Event Oriented Model• An incoming connection (or data) triggers an event, which is put on top of the event queue• Whenever processing of one event has finished, receive the next event from the event queue• No built-in or OS timesharing, one process
    • 6. • Event-oriented• JavaScript on V8, because authors gave up on Ruby due to performance constraints• single-threaded by design, but several node processes can run at the same time leveraging several cores• event oriented HTTP and TCP implementation for Server and Client• (a)synchronous file system access
    • 7. V8• JavaScript Engine written in C++ for Google Chrome• JavaScript is compiled into machine code before execution• Embeddable into custom C++ applications• Garbage collection by stopping program flow and removing all objects without references
    • 8. Demo• A small event based server
    • 9. Awesomeness in Node.js• JavaScript - the good parts• Same language on server and client• Event oriented model scales very well with increasing concurrency and network IO• You can actually send your application and its state (JSON) to the client, where it continues execution
    • 10. Pitfalls in Node.js• Scales badly with computational complexity • Web workers API implementation promised• Same language, but still the game on the server is a different one• JavaScript - the bad parts • hopefully ES5 strict can help
    • 11. YNodeJS• Multi-core support• Modules for YIV,YDOD,YCK, etc.• Implements open_basedir restrictions like PHP
    • 12. Stability Considerations• Following the prefork model, you only lose 1 connection when a worker dies • or a few if you have several threads per process• Following the event oriented model, you lose all connections when your process dies • or half, a quarter, etc. depending on the number of processes
    • 13. Server Side YUI• YUI is fully functional• Creating a YUI instance with module loading is very slow • can be dealt with using caching• Y.io is significantly slower than http.request • just use http.request if performance matters• Overhead of adding a framework vs. performance
    • 14. Manhattan• Node.js cloud service• Deploy applications with one command
    • 15. Search Direct Modules Case Study• Right Panel retrieved using AJAX• { ‘html’: ‘<div>...</div>’, ‘css’: ‘...’, js: ‘...’, ... }
    • 16. SD: Characteristics• Simple request (query and ~3 other parameters that matter)• Retrieve data from always 1 back-end, aggressive timeout• Render a small piece of HTML, put it in a JSON object with some string constants• A lot of concurrent requests (one request per character that is being typed in a Y! search box)
    • 17. Scalability• PHP based solution has an average response time of >100ms for 50 concurrent connections
    • 18. Scalability• PHP based solution has an average response time of >100ms for 50 concurrent connections
    • 19. Scalability• PHP based solution has an average response time of >100ms for 50 concurrent connections
    • 20. Conclusion• Node.js can deliver great performance and scalability in our use case• The Mustache templating engine adds minimal extra latency, which indicates strong JS performance• Using YUI via a global shared instance is fine, but creating an instance per request is currently not feasible
    • 21. See you on nodejs-users@ !
    • 22. References• $ man aio aio_read aio_error aio_return• http://www.freebsd.org/releases/3.0R/notes.html• http://www.freebsd.org/releases/4.1R/notes.html• http://www.nodejs.org/• http://www.yuiblog.com/blog/2010/04/05/running- yui-3-server-side-with-node-js/• http://mustache.github.com/• http://code.google.com/apis/v8/embed.html

    ×