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”

• Need   to spread request across servers
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
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
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 Python did not perform well enough...
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/min = 5 Days*




                   * Calculated wrong before sorry it’s not 2.5h
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 time)!
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 ;)
AD!
Network with node

Network with node