A million connections...
   AND BEYOND!!!
     Node.js at Scale
One million
connections!!!
A million isn't
very much these
     days...
One hundred
    billion
connections!!!
What this talk is really
       about
  Picking meaningful benchmarks

  Current state of Node.js benchmarks

  Understanding why benchmarks aren't _that_
  important

  How to pick the right language/framework/lib
What can we measure?

Computation    Disk I/O

Net work I/O   Throughput

  TCP          Libraries

  UDP            URL Parsing

  HTTP           etc
How do we measure?


 Load averages

 Memory usage

 Average time - Average perf. of each operation

 Latency - Actual performance of each operation
Comparison

Erlang vs. Node.js vs. Tornado

3 Erlang libs

Stock Node.js

Stock Tornado

Single core
Desired vs. Real
  Responses
Response times
I pity the fool who
     uses Node
Questioning benchmarks


   What do average times mean?

     Responses on a curve

   Who uses in memory servers?
Finding Node's strength
 connections: 933990

 errors: 0

 Read from remote host gqzdj9ab.joyent.us:
 Operation timed out

 Connection to gqzdj9ab.joyent.us closed.

 Enki:~ $
var net = require('net')


var conns = 0


function connectToServer(ip) {
    conn = net.createConnection(8000, ip)
    conn.on('connect', function() {
      conns += 1
    })
    conn.on('end', function() {
     conns -= 1
    })
}


for(i=0;i<61000;i++) {
    connectToServer('72.2.120.106')
}
var net = require('net')


var s = net.createServer()
var c = 0;
var e = 0;


s.on('connection', function(socket) {
 c += 1


 socket.on('end', function() {
  c -= 1
 })
 socket.on('error', function(e) {
   e += 1
 })
})


s.listen(8000)


setInterval(function() {
 console.log('connections: ' + c)
  console.log('errors: ' + e)
}, 5000)
Finding Node's strength
    PID USERNAME SIZE RSS STATE PRI NICE      TIME CPU PROCESS/NLWP

  22593 root    758M 642M cpu11 25       0 0:17:54 6.2% node/1

  22542 croucher 4308K 3084K cpu2   59     0 0:00:08 0.2% prstat/1

 ...



 ...



 ZONEID     NPROC SWAP RSS MEMORY        TIME CPU ZONE

       27   31 1489M 782M   38% 1:59:54 6.3% gqzdj9ab
Where to use atomic
  measurements

 Measuring performance improvements over time

 Figuring out the hot-path

 Profiling against your specific use case
8x Perf
improvement
I am a super




                                        stuff
       effective
     measurement
 Because I put stuff on one axis and
 things on another and now I'm like             things
proper science and you should totally
 use me to base all your judgements
       about everything on…

           no seriously...
Why benchmarks aren't
as important as we think

   There is a tradeoff bet ween performance and
   productivity

   If this weren't true we'd all still be writing in ASM
Fit for purpose
Sandboxed language       Event Driven
   PHP, Python              Node.js

   Java, C#                 Event Machine (Ruby)
   Ruby, etc                Tornado (Python)

                         Message Passing
                            Erlang
Class of languages for the
          Internet
    New languages/platforms like Node.js designed for
    Internet applications

    New class of languages are efficient enough, but are
    they easy enough?

    Node.js designed from scratch for net work server
    programming
Reasons to use Node

 It's really fast. Very much fast enough.

 It's easy to use for Internet/Web applications.

 It's JavaScript.

 It has an extremely active community.

 It has a lot of project velocity.
What we need from
  benchmarks
Benchmarks to test real world use cases
  Servers that do more than just 'hello world'
Benchmarks to compare real test cases from many
platforms
Benchmarks that reflect mobile clients
Node CI on many platforms
Questions?

I'm on Twitter http:/ witter.com/sh1mmer
                     /t

  That's a "one" in my nick

Check out the book on http://ofps.oreilly.com

  It's free to read and comment. New release this
  week

A million connections and beyond - Node.js at scale

  • 1.
    A million connections... AND BEYOND!!! Node.js at Scale
  • 2.
  • 3.
    A million isn't verymuch these days...
  • 4.
    One hundred billion connections!!!
  • 5.
    What this talkis really about Picking meaningful benchmarks Current state of Node.js benchmarks Understanding why benchmarks aren't _that_ important How to pick the right language/framework/lib
  • 6.
    What can wemeasure? Computation Disk I/O Net work I/O Throughput TCP Libraries UDP URL Parsing HTTP etc
  • 7.
    How do wemeasure? Load averages Memory usage Average time - Average perf. of each operation Latency - Actual performance of each operation
  • 8.
    Comparison Erlang vs. Node.jsvs. Tornado 3 Erlang libs Stock Node.js Stock Tornado Single core
  • 9.
  • 10.
  • 11.
    I pity thefool who uses Node
  • 12.
    Questioning benchmarks What do average times mean? Responses on a curve Who uses in memory servers?
  • 13.
    Finding Node's strength connections: 933990 errors: 0 Read from remote host gqzdj9ab.joyent.us: Operation timed out Connection to gqzdj9ab.joyent.us closed. Enki:~ $
  • 14.
    var net =require('net') var conns = 0 function connectToServer(ip) { conn = net.createConnection(8000, ip) conn.on('connect', function() { conns += 1 }) conn.on('end', function() { conns -= 1 }) } for(i=0;i<61000;i++) { connectToServer('72.2.120.106') }
  • 15.
    var net =require('net') var s = net.createServer() var c = 0; var e = 0; s.on('connection', function(socket) { c += 1 socket.on('end', function() { c -= 1 }) socket.on('error', function(e) { e += 1 }) }) s.listen(8000) setInterval(function() { console.log('connections: ' + c) console.log('errors: ' + e) }, 5000)
  • 16.
    Finding Node's strength PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS/NLWP 22593 root 758M 642M cpu11 25 0 0:17:54 6.2% node/1 22542 croucher 4308K 3084K cpu2 59 0 0:00:08 0.2% prstat/1 ... ... ZONEID NPROC SWAP RSS MEMORY TIME CPU ZONE 27 31 1489M 782M 38% 1:59:54 6.3% gqzdj9ab
  • 17.
    Where to useatomic measurements Measuring performance improvements over time Figuring out the hot-path Profiling against your specific use case
  • 18.
  • 19.
    I am asuper stuff effective measurement Because I put stuff on one axis and things on another and now I'm like things proper science and you should totally use me to base all your judgements about everything on… no seriously...
  • 20.
    Why benchmarks aren't asimportant as we think There is a tradeoff bet ween performance and productivity If this weren't true we'd all still be writing in ASM
  • 21.
    Fit for purpose Sandboxedlanguage Event Driven PHP, Python Node.js Java, C# Event Machine (Ruby) Ruby, etc Tornado (Python) Message Passing Erlang
  • 22.
    Class of languagesfor the Internet New languages/platforms like Node.js designed for Internet applications New class of languages are efficient enough, but are they easy enough? Node.js designed from scratch for net work server programming
  • 23.
    Reasons to useNode It's really fast. Very much fast enough. It's easy to use for Internet/Web applications. It's JavaScript. It has an extremely active community. It has a lot of project velocity.
  • 24.
    What we needfrom benchmarks Benchmarks to test real world use cases Servers that do more than just 'hello world' Benchmarks to compare real test cases from many platforms Benchmarks that reflect mobile clients Node CI on many platforms
  • 25.
    Questions? I'm on Twitterhttp:/ witter.com/sh1mmer /t That's a "one" in my nick Check out the book on http://ofps.oreilly.com It's free to read and comment. New release this week