• Save
Streams are Awesome - (Node.js) TimesOpen Sep 2012
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Streams are Awesome - (Node.js) TimesOpen Sep 2012

on

  • 5,100 views

 

Statistics

Views

Total Views
5,100
Views on SlideShare
4,847
Embed Views
253

Actions

Likes
3
Downloads
0
Comments
0

15 Embeds 253

http://localhost 217
https://twitter.com 9
http://www.linkedin.com 6
https://www.linkedin.com 4
http://www.onlydoo.com 3
http://faxo.com 3
http://twitter.com 2
http://fr.slideshare.net 2
http://www.caucapino4u.com 1
http://flashattackcrew.blogspot.com 1
http://kred.com 1
https://si0.twimg.com 1
http://flashattackcrew.blogspot.mx 1
http://photos1.servepics.com 1
http://novaxarxabusos.omitsis.com 1
More...

Accessibility

Upload Details

Uploaded via as Apple Keynote

Usage Rights

CC Attribution-ShareAlike LicenseCC Attribution-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Streams are Awesome - (Node.js) TimesOpen Sep 2012 Presentation Transcript

  • 1. Streams are awesome.@sh1mmer
  • 2. Tom Hughes-Croucher @sh1mmer
  • 3. Scalable Server-Side Code with JavaScript Node Up and Running Tom Hughes-Croucher http://ofps.oreilly.com/titles/9781449398583/http://shop.oreilly.com/product/0636920015956.do
  • 4. Client → ServerServer → DB Computation Computation@sh1mmer
  • 5. Non event-driven frontend@sh1mmer
  • 6. @sh1mmer
  • 7. Server@sh1mmer
  • 8. Request@sh1mmer
  • 9. @sh1mmer
  • 10. Event-driven frontend@sh1mmer
  • 11. Place- holder@sh1mmer
  • 12. @sh1mmer
  • 13. Shared WorkResources@sh1mmer
  • 14. Memory operations@sh1mmer
  • 15. var x = "I am a string" ~1ns Running 1 instruction 2ns Data from l1 cpu cache 5ns Data from l2 cpu cache 80ns Data from ram@sh1mmer
  • 16. @sh1mmer
  • 17. Mobile data latency@sh1mmer
  • 18. @sh1mmer
  • 19. 100 Blue Whales Cat@sh1mmer
  • 20. Node.js Streams@sh1mmer
  • 21. Streams• Readable • Pause • Resume • data event• Writable • Write• Pipe
  • 22. Event Loop Fail node.cc add-ons v8 libuv libev iocp
  • 23. nextTick Event Loop FailnextTick Run stuff TCP Conn node.cc FS Read add-ons v8 TCP Conn v8 func libuv v8 TCP func Conn libev iocp v8 FS func Read FS Read
  • 24. stream.pause()@sh1mmer
  • 25. nextTick Event Loop FailnextTick stream.pause() TCP Conn node.cc FS Read add-ons v8 TCP Conn v8 func libuv v8 TCP func Conn libev iocp v8 FS func Read FS Read
  • 26. New Streams• Writable • Same (hooray!)• Readable • Configure buffer waterline • readable event • read(len) -> returns data• Pipe • Doesnt mix with direct access
  • 27. Node.js Domains@sh1mmer
  • 28. var d = domain.create(); function readSomeFile(filename, cb) { fs.readFile(filename, utf8, d.bind(function(er, data) { // if this throws, it will also be passed to the domain return cb(er, data ? JSON.parse(data) : null); })); } d.on(error, function(er) { // an error occurred somewhere. // if we throw it now, it will crash the program // with the normal line number and stack message. });@sh1mmer
  • 29. Questions!@sh1mmer