Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Node.js in the real world: step out of the buzz...

trodrigues
November 10, 2011

Node.js in the real world: step out of the buzzword cloud and get things done!

See what I did with that title ?

Node.js has been the subject of much talk and discussion in the past couple of years. People keep talking about it's amazing capabilities for the real time web and the fact that it allows you to do JavaScript Everywhere (TM). And everyone loves to show their toy apps which they've built in 5 minutes with a few lines of JavaScript.

But what about things being built in the real world with Node.js ? And what's the real advantage of having JavaScript on the server side ?

This talk will go through real world usage examples, tools, components (how they help you and what they can do for you), tips on how to manage projects and code and all the other things that you need to think about when you set out to do real work.

trodrigues

November 10, 2011
Tweet

Other Decks in Programming

Transcript

  1. 4 Thursday, November 10, 11 JS dev for 3 years

    writing JS for longer than that love for the language strenghts (and also knowledge of weaknesses)
  2. 5 Thursday, November 10, 11 naturally attracted to node.js however,

    many things taken from granted not there when i started looking at it
  3. “OMG! look at the amazing chat app I wrote in

    5 lines of code!” 6 Thursday, November 10, 11
  4. Real world usage means useful modules and libraries 10 Thursday,

    November 10, 11 people are developing real products with node and creating the modules and libraries needed
  5. And lots of new (old) problems to solve... 11 Thursday,

    November 10, 11 some of the problems are general and seen in another languages and frameworks
  6. 12 Thursday, November 10, 11 fooled you. not really making

    node.js apps in the real world (yet) always taken an interest on how node can have real world usage
  7. A lot of this is not new 13 Thursday, November

    10, 11 Been aggregating others experiences over time
  8. But before that... 14 Thursday, November 10, 11 why node.js

    is important (not getting deep into this) benefits are also very relative
  9. JS Everywhere! 16 Thursday, November 10, 11 code reuse benefits

    not always present less of a mind shift in small companies
  10. Event based goodness 20 Thursday, November 10, 11 Everything is

    asynchronous, many libs developed from scratch for node the language is (somehow) ready for it
  11. 22 Thursday, November 10, 11 Some say...it’s faster than Java/Python/Ruby/whatever...

    Depends a lot on your use case (and if you did things right)
  12. Good at fulfilling lots of small requests 23 Thursday, November

    10, 11 better for responding to lots of small requests some reports of bad performance: low throughput reports...
  13. Node.js is not the new X 26 Thursday, November 10,

    11 not A web framework intended to write network programs (webservers mostly)
  14. Make sure it makes sense for you http://nodeguide.com/convincing_the_boss.html 27 Thursday,

    November 10, 11 you might not need it. don’t throw away your django apps yet
  15. Ok, I want to use node 29 Thursday, November 10,

    11 Some things you need to know (not getting deep into this)
  16. Shared file descriptors via Unix sockets http://bit.ly/lUyx5n 42 Thursday, November

    10, 11 unix sockets on the same machine, faster than network (duh) cluster helps
  17. Separate them out of your main event loop http://1.jn.5d.sl.pt 46

    Thursday, November 10, 11 Or even write them natively if you need to
  18. Separate stuff that doesn’t need to be done in real

    time 47 Thursday, November 10, 11 and shown back to the user
  19. How bout that pesky 1gb heap limit? 49 Thursday, November

    10, 11 It’s gone now. Not sure if on node yet
  20. All of them suck. 53 Thursday, November 10, 11 Code

    compilation, writing code in weird ways
  21. Use bind to pass inner variables around underscore.js is your

    friend and JS will have it by default 57 Thursday, November 10, 11 good old bind from prototype.js this is not jquery bind
  22. Log everything http://bit.ly/lUyx5n 63 Thursday, November 10, 11 everytime you

    have problems and aggregate it in redis or something
  23. If it dies and you don’t know why you’re in

    a world of pain 64 Thursday, November 10, 11 yes, this is a problem with node you might be leaving stuff hanging and cause memory leaks
  24. If you don’t know why it fails, kill it 65

    Thursday, November 10, 11 restart the process on uncaught exceptions or node gets wonky and you don’t really know why it fails
  25. But kill it nicely! http://1.jx.y4.sl.pt 66 Thursday, November 10, 11

    Don’t just kill existing connections. Cleanup and kill it as gracefully as you can. process monitors are your friends
  26. You should be treating your errors early anyway 67 Thursday,

    November 10, 11 if you know what problems can arise, treat them remember, log everything
  27. http:// 76 Thursday, November 10, 11 no idea what they’re

    doing with node been doing async in c++ for a while
  28. 77 Thursday, November 10, 11 many contributions to node core

    and other modules using node since the early days
  29. jsconf wifi https://github.com/mabels/Sashimi 78 Thursday, November 10, 11 connection load

    balancing based on whatever types of connections are available wifi at jsconf.us: fucking awesome!
  30. socket.io, express, node- canvas, mongoose... 80 Thursday, November 10, 11

    Huge node contributors: Guillermo Rauch, TJ Holowaychuk
  31. 81 Thursday, November 10, 11 node as a backend, huge

    contributors amazing IDE these days
  32. 84 Thursday, November 10, 11 node.js daemon for stats collection

    via udp aggregates and sends data to graphite
  33. 86 Thursday, November 10, 11 using node.js as a Xdomain

    proxy for their api easier to write your own proxy in JS and better performant than ruby
  34. 88 Thursday, November 10, 11 github campfire chat bot easily

    scriptable to interact with anything, even hardware
  35. 89 Thursday, November 10, 11 github component for repo archive

    packaging (zip, tarball) proxies data from fileservers into client
  36. 92 Thursday, November 10, 11 social network twitter style rewritten

    in node from netty (and cited as a netty performance example)
  37. 93 Thursday, November 10, 11 walkie talkie app for smartphones,

    node.js backend c++ complex, python slow, large number of open connections