SOCKET UTILIZATION IN
NODE.JS
Akhilesh Gupta	

@agupta03
Inefficient use of TCP sockets: Is HTTP keep-alive working?
Node’s HTTP module supports keep-alive
But there is a catch!
TCP Connection kept alive only if	

PENDING requests in agent queue
If requests go out one-by-one	

Connection closed each time
High QPS/Low Latency
High time-wait sockets
Eventual node CRASH
Houston, we’ve had a problem here!
NPM Libraries to the rescue!
mikeal/request : forever module

ceejbot/keep-alive-agent

TBEDP/agentkeepalive
TUNING UP YOUR F-35!
Monitor time_wait sockets	

!

“If you can’t measure it, you can’t fix it”
TUNING UP YOUR F-35!
maxSockets
!

Concurrent sockets agent can have open/host
TUNING UP YOUR F-35!
idleTimeout
!

Time for which connection is unused before it is discarded
THE ENGINEERING
HAPPINESS GRAPH
Normal agent:

Keep alive agent (30 seconds):

Transactions:
60000 hits!
Availability:
100.00 %!
Elapsed time:
46.53 secs!...
TUNING UP YOUR F-35!
Upgrade to Node 0.5.3+	

!

Agent holds sockets for any number of hosts
Upcoming SlideShare
Loading in...5
×

Socket Utilization in Node.js

327

Published on

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

  • Be the first to like this

No Downloads
Views
Total Views
327
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
13
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Socket Utilization in Node.js

  1. 1. SOCKET UTILIZATION IN NODE.JS Akhilesh Gupta @agupta03
  2. 2. Inefficient use of TCP sockets: Is HTTP keep-alive working?
  3. 3. Node’s HTTP module supports keep-alive
  4. 4. But there is a catch!
  5. 5. TCP Connection kept alive only if PENDING requests in agent queue
  6. 6. If requests go out one-by-one Connection closed each time
  7. 7. High QPS/Low Latency High time-wait sockets Eventual node CRASH Houston, we’ve had a problem here!
  8. 8. NPM Libraries to the rescue!
  9. 9. mikeal/request : forever module ceejbot/keep-alive-agent TBEDP/agentkeepalive
  10. 10. TUNING UP YOUR F-35! Monitor time_wait sockets ! “If you can’t measure it, you can’t fix it”
  11. 11. TUNING UP YOUR F-35! maxSockets ! Concurrent sockets agent can have open/host
  12. 12. TUNING UP YOUR F-35! idleTimeout ! Time for which connection is unused before it is discarded
  13. 13. THE ENGINEERING HAPPINESS GRAPH
  14. 14. Normal agent: Keep alive agent (30 seconds): Transactions: 60000 hits! Availability: 100.00 %! Elapsed time: 46.53 secs! Data transferred: 14.88 MB! Response time: 0.05 secs! Transaction rate: 1289.49 trans/sec! Throughput: 0.32 MB/sec! Concurrency: 59.81! Successful transactions:60000! Failed transactions: 0! Longest transaction: 0.45! Shortest transaction: 0.00 Transactions: 60000 hits! Availability: 100.00 %! Elapsed time: 29.70 secs! Data transferred: 14.88 MB! Response time: 0.03 secs! Transaction rate: 2020.20 trans/sec! Throughput: 0.50 MB/sec! Concurrency: 59.84! Successful transactions:60000! Failed transactions: 0! Longest transaction: 0.15! Shortest transaction: 0.01
  15. 15. TUNING UP YOUR F-35! Upgrade to Node 0.5.3+ ! Agent holds sockets for any number of hosts
  1. A particular slide catching your eye?

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

×