SlideShare ist ein Scribd-Unternehmen logo
1 von 15
Downloaden Sie, um offline zu lesen
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!
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
TUNING UP YOUR F-35!
Upgrade to Node 0.5.3+	

!

Agent holds sockets for any number of hosts

Weitere ähnliche Inhalte

Ähnlich wie Socket Utilization in Node.js

2012 07 making disqus realtime@euro python
2012 07 making disqus realtime@euro python2012 07 making disqus realtime@euro python
2012 07 making disqus realtime@euro python
Adam Hitchcock
 
QCon NY 2014 - Evolving REST for an IoT World
QCon NY 2014 - Evolving REST for an IoT WorldQCon NY 2014 - Evolving REST for an IoT World
QCon NY 2014 - Evolving REST for an IoT World
Todd Montgomery
 

Ähnlich wie Socket Utilization in Node.js (20)

Introduction to gRPC (Application) Presentation
Introduction to gRPC (Application) PresentationIntroduction to gRPC (Application) Presentation
Introduction to gRPC (Application) Presentation
 
Counting image views using redis cluster
Counting image views using redis clusterCounting image views using redis cluster
Counting image views using redis cluster
 
Low latency for high throughput
Low latency for high throughputLow latency for high throughput
Low latency for high throughput
 
Storm Real Time Computation
Storm Real Time ComputationStorm Real Time Computation
Storm Real Time Computation
 
Introduction to ZooKeeper - TriHUG May 22, 2012
Introduction to ZooKeeper - TriHUG May 22, 2012Introduction to ZooKeeper - TriHUG May 22, 2012
Introduction to ZooKeeper - TriHUG May 22, 2012
 
Automating the Hunt for Non-Obvious Sources of Latency Spreads
Automating the Hunt for Non-Obvious Sources of Latency SpreadsAutomating the Hunt for Non-Obvious Sources of Latency Spreads
Automating the Hunt for Non-Obvious Sources of Latency Spreads
 
Deterministic behaviour and performance in trading systems
Deterministic behaviour and performance in trading systemsDeterministic behaviour and performance in trading systems
Deterministic behaviour and performance in trading systems
 
gen_udp and gen_tcp in Elixir
gen_udp and gen_tcp in Elixirgen_udp and gen_tcp in Elixir
gen_udp and gen_tcp in Elixir
 
2012 07 making disqus realtime@euro python
2012 07 making disqus realtime@euro python2012 07 making disqus realtime@euro python
2012 07 making disqus realtime@euro python
 
(WEB401) Optimizing Your Web Server on AWS | AWS re:Invent 2014
(WEB401) Optimizing Your Web Server on AWS | AWS re:Invent 2014(WEB401) Optimizing Your Web Server on AWS | AWS re:Invent 2014
(WEB401) Optimizing Your Web Server on AWS | AWS re:Invent 2014
 
VISUG - Approaches for application request throttling
VISUG - Approaches for application request throttlingVISUG - Approaches for application request throttling
VISUG - Approaches for application request throttling
 
Low level java programming
Low level java programmingLow level java programming
Low level java programming
 
QCon NY 2014 - Evolving REST for an IoT World
QCon NY 2014 - Evolving REST for an IoT WorldQCon NY 2014 - Evolving REST for an IoT World
QCon NY 2014 - Evolving REST for an IoT World
 
Kafka Reliability - When it absolutely, positively has to be there
Kafka Reliability - When it absolutely, positively has to be thereKafka Reliability - When it absolutely, positively has to be there
Kafka Reliability - When it absolutely, positively has to be there
 
Apache Kafka Reliability Guarantees StrataHadoop NYC 2015
Apache Kafka Reliability Guarantees StrataHadoop NYC 2015 Apache Kafka Reliability Guarantees StrataHadoop NYC 2015
Apache Kafka Reliability Guarantees StrataHadoop NYC 2015
 
uWSGI - Swiss army knife for your Python web apps
uWSGI - Swiss army knife for your Python web appsuWSGI - Swiss army knife for your Python web apps
uWSGI - Swiss army knife for your Python web apps
 
Quick QUIC Technical Update (2017)
Quick QUIC Technical Update (2017)Quick QUIC Technical Update (2017)
Quick QUIC Technical Update (2017)
 
Apache Kafka – (Pattern and) Anti-Pattern
Apache Kafka – (Pattern and) Anti-PatternApache Kafka – (Pattern and) Anti-Pattern
Apache Kafka – (Pattern and) Anti-Pattern
 
Approaches to application request throttling
Approaches to application request throttlingApproaches to application request throttling
Approaches to application request throttling
 
Reliability Guarantees for Apache Kafka
Reliability Guarantees for Apache KafkaReliability Guarantees for Apache Kafka
Reliability Guarantees for Apache Kafka
 

Mehr von Akhilesh Gupta

Mehr von Akhilesh Gupta (6)

QCon London 2020: Streaming a million likes/second Real-time interactions on...
QCon London 2020: Streaming a million likes/second  Real-time interactions on...QCon London 2020: Streaming a million likes/second  Real-time interactions on...
QCon London 2020: Streaming a million likes/second Real-time interactions on...
 
QCon SF 2022: The Secret to Finding Impactful Projects to Land a Staff-Plus E...
QCon SF 2022: The Secret to Finding Impactful Projects to Land a Staff-Plus E...QCon SF 2022: The Secret to Finding Impactful Projects to Land a Staff-Plus E...
QCon SF 2022: The Secret to Finding Impactful Projects to Land a Staff-Plus E...
 
Codemotion 2019: A million likes/second: Real-time interactions on Live Video
Codemotion 2019: A million likes/second: Real-time interactions on Live VideoCodemotion 2019: A million likes/second: Real-time interactions on Live Video
Codemotion 2019: A million likes/second: Real-time interactions on Live Video
 
Realtime Content Delivery: Powering dynamic instant experiences
Realtime Content Delivery: Powering dynamic instant experiencesRealtime Content Delivery: Powering dynamic instant experiences
Realtime Content Delivery: Powering dynamic instant experiences
 
Midwest.io 2014: Lightning fast mobile development at scale
Midwest.io 2014: Lightning fast mobile development at scaleMidwest.io 2014: Lightning fast mobile development at scale
Midwest.io 2014: Lightning fast mobile development at scale
 
Mdevcon 2014: Lightning fast mobile development at scale
Mdevcon 2014: Lightning fast mobile development at scaleMdevcon 2014: Lightning fast mobile development at scale
Mdevcon 2014: Lightning fast mobile development at scale
 

Kürzlich hochgeladen

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Kürzlich hochgeladen (20)

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Socket Utilization in Node.js

  • 2. Inefficient use of TCP sockets: Is HTTP keep-alive working?
  • 3. Node’s HTTP module supports keep-alive
  • 4. But there is a catch!
  • 5. TCP Connection kept alive only if PENDING requests in agent queue
  • 6. If requests go out one-by-one Connection closed each time
  • 7. High QPS/Low Latency High time-wait sockets Eventual node CRASH Houston, we’ve had a problem here!
  • 8. NPM Libraries to the rescue!
  • 9. mikeal/request : forever module ceejbot/keep-alive-agent TBEDP/agentkeepalive
  • 10. TUNING UP YOUR F-35! Monitor time_wait sockets ! “If you can’t measure it, you can’t fix it”
  • 11. TUNING UP YOUR F-35! maxSockets ! Concurrent sockets agent can have open/host
  • 12. TUNING UP YOUR F-35! idleTimeout ! Time for which connection is unused before it is discarded
  • 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. TUNING UP YOUR F-35! Upgrade to Node 0.5.3+ ! Agent holds sockets for any number of hosts