NETWORKING WITH NODEJS            Philipp Fehre http://sideshowcoder.com      Inspired by Dirk Haage http://dirk.haage.info/
WHY?
• Speed
• Speed• Event   driven programming
• Speed• Event   driven programming• Javascript
• Speed• Event   driven programming• Javascript• Because   we can!
BASICS
• Real   Simple TCP
• Real    Simple TCP• Build   a binary packet
• Real    Simple TCP• Build   a binary packet• Sent    the Packet (UDP/TCP Socket)
• Real    Simple TCP• Build   a binary packet• Sent    the Packet (UDP/TCP Socket)• Make    DNS Requests
TCP SERVER
TCP CLIENT
DATA
ENCODING
BUILD PACKET
OPEN A SOCKET
SENDING
EXAMPLE
GROWL
DOING SOMETHING USEFUL                NOW...
RDNS ISTRUKTA PROJECT
RDNS ISTRUKTA PROJECT• Resolve   reverse DNS names
RDNS ISTRUKTA PROJECT• Resolve   reverse DNS names• Scanthe whole Internet
RDNS ISTRUKTA PROJECT• Resolve   reverse DNS names• Scanthe whole Internet• 2^32   IPs so better be fast!
MAKE A DNS REQUEST
REMINDER HOW DNS WORKS
2^32 REQUEST TO 1 DNS               SERVER?
2^32 REQUEST TO 1 DNS                           SERVER?• Does   not work, any sensible server will respond with “meh”
2^32 REQUEST TO 1 DNS                           SERVER?• Does   not work, any sensible server will respond with “meh”• Nee...
2^32 REQUEST TO 1 DNS                           SERVER?• Does   not work, any sensible server will respond with “meh”• Nee...
2^32 REQUEST TO 1 DNS                           SERVER?• Does   not work, any sensible server will respond with “meh”• Nee...
EXPOSING SETTING
MAKE A DNS REQUEST VIA A         SPECIFIC SERVER
WHY NODE?
WHY NODE?• Requests   need to run async
WHY NODE?• Requests   need to run async• The   Javascript way to handle evented systems
WHY NODE?• Requests    need to run async• The     Javascript way to handle evented systems• First   implementation in Pyth...
EVENTED ARCHITECTURE
2^32 IP = NEED FOR SPEED
2^32 IP = NEED FOR SPEED• Sync: Python   4 workers 36000 Requests/min = 82 Days
2^32 IP = NEED FOR SPEED• Sync: Python   4 workers 36000 Requests/min = 82 Days• Async: Node    1 process 500000 Requests/...
DEMO
PRO-THOUGHTS
PRO-THOUGHTS• Event   driven programming
PRO-THOUGHTS• Event    driven programming• Easily   modifiable
PRO-THOUGHTS• Event    driven programming• Easily   modifiable• Node     is moving quick
PRO-THOUGHTS• Event    driven programming• Easily   modifiable• Node     is moving quick• Javascript   is fun!
COUNTER-THOUGHTS
COUNTER-THOUGHTS• API   not “there” yet in some cases
COUNTER-THOUGHTS• API   not “there” yet in some cases• Really   web focused
COUNTER-THOUGHTS• API   not “there” yet in some cases• Really   web focused• Node     is moving to quick (from time to tim...
REFERENCES•   Node DNS Patch: https://github.com/sideshowcoder/Add-NodeJS-DNS-Server-Settings•   Growl for Node: https://g...
AD!
Network with node
Network with node
Network with node
Upcoming SlideShare
Loading in...5
×

Network with node

2,248

Published on

Talk about basic networking with nodejs. Originally at MunichJS 5.5.2011 (munichjs.org)

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

  • Be the first to like this

No Downloads
Views
Total Views
2,248
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

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
  • \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
  • Network with node

    1. 1. NETWORKING WITH NODEJS Philipp Fehre http://sideshowcoder.com Inspired by Dirk Haage http://dirk.haage.info/
    2. 2. WHY?
    3. 3. • Speed
    4. 4. • Speed• Event driven programming
    5. 5. • Speed• Event driven programming• Javascript
    6. 6. • Speed• Event driven programming• Javascript• Because we can!
    7. 7. BASICS
    8. 8. • Real Simple TCP
    9. 9. • Real Simple TCP• Build a binary packet
    10. 10. • Real Simple TCP• Build a binary packet• Sent the Packet (UDP/TCP Socket)
    11. 11. • Real Simple TCP• Build a binary packet• Sent the Packet (UDP/TCP Socket)• Make DNS Requests
    12. 12. TCP SERVER
    13. 13. TCP CLIENT
    14. 14. DATA
    15. 15. ENCODING
    16. 16. BUILD PACKET
    17. 17. OPEN A SOCKET
    18. 18. SENDING
    19. 19. EXAMPLE
    20. 20. GROWL
    21. 21. DOING SOMETHING USEFUL NOW...
    22. 22. RDNS ISTRUKTA PROJECT
    23. 23. RDNS ISTRUKTA PROJECT• Resolve reverse DNS names
    24. 24. RDNS ISTRUKTA PROJECT• Resolve reverse DNS names• Scanthe whole Internet
    25. 25. RDNS ISTRUKTA PROJECT• Resolve reverse DNS names• Scanthe whole Internet• 2^32 IPs so better be fast!
    26. 26. MAKE A DNS REQUEST
    27. 27. REMINDER HOW DNS WORKS
    28. 28. 2^32 REQUEST TO 1 DNS SERVER?
    29. 29. 2^32 REQUEST TO 1 DNS SERVER?• Does not work, any sensible server will respond with “meh”
    30. 30. 2^32 REQUEST TO 1 DNS SERVER?• Does not work, any sensible server will respond with “meh”• Need to spread request across servers
    31. 31. 2^32 REQUEST TO 1 DNS SERVER?• Does not work, any sensible server will respond with “meh”• Need to spread request across servers• Handle own recursive resolution
    32. 32. 2^32 REQUEST TO 1 DNS SERVER?• Does not work, any sensible server will respond with “meh”• Need to spread request across servers• Handle own recursive resolution• Need to set DNS Server per request
    33. 33. EXPOSING SETTING
    34. 34. MAKE A DNS REQUEST VIA A SPECIFIC SERVER
    35. 35. WHY NODE?
    36. 36. WHY NODE?• Requests need to run async
    37. 37. WHY NODE?• Requests need to run async• The Javascript way to handle evented systems
    38. 38. WHY NODE?• Requests need to run async• The Javascript way to handle evented systems• First implementation in Python did not perform well enough...
    39. 39. EVENTED ARCHITECTURE
    40. 40. 2^32 IP = NEED FOR SPEED
    41. 41. 2^32 IP = NEED FOR SPEED• Sync: Python 4 workers 36000 Requests/min = 82 Days
    42. 42. 2^32 IP = NEED FOR SPEED• Sync: Python 4 workers 36000 Requests/min = 82 Days• Async: Node 1 process 500000 Requests/min = 5 Days* * Calculated wrong before sorry it’s not 2.5h
    43. 43. DEMO
    44. 44. PRO-THOUGHTS
    45. 45. PRO-THOUGHTS• Event driven programming
    46. 46. PRO-THOUGHTS• Event driven programming• Easily modifiable
    47. 47. PRO-THOUGHTS• Event driven programming• Easily modifiable• Node is moving quick
    48. 48. PRO-THOUGHTS• Event driven programming• Easily modifiable• Node is moving quick• Javascript is fun!
    49. 49. COUNTER-THOUGHTS
    50. 50. COUNTER-THOUGHTS• API not “there” yet in some cases
    51. 51. COUNTER-THOUGHTS• API not “there” yet in some cases• Really web focused
    52. 52. COUNTER-THOUGHTS• API not “there” yet in some cases• Really web focused• Node is moving to quick (from time to time)!
    53. 53. REFERENCES• Node DNS Patch: https://github.com/sideshowcoder/Add-NodeJS-DNS-Server-Settings• Growl for Node: https://github.com/sideshowcoder/Nodrrr• Web: http://sideshowcoder.com Twitter: @ischi• Pictures courtesy of google image search ;)
    54. 54. AD!
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×