With node.js server on EC2, how can I reduce TCP connection time?

During the profiling of my application, I noticed that on the Firebug Net panel, the connection time, that is, the TCP connection timeout, is constantly about 70-100 ms. See image below:

notice "connecting"

Of course, in the grandiose scheme of things, 100 ms is not long, but I saw other services that respond 0ms Connection time. Therefore, if other servers can, I should also be able to.

Any thoughts on how I can even ask you to fix this problem?

+4
source share
2 answers

I would start by looking to see if iptables is doing anything that can get in the way. Also, if you were working with an ELB load balancer (or any other load balancer), I would remove it from the mix and see if you have a longer wait time than expected.

You can also install lighttpd or Apache separately and see what happens. If you get a lower connection time, this will point to your Node.js. construct. Although not final.

+1
source

I would suggest a simple test to check if this problem is related to your server:

  • Launch another instance in the same availability zone as your server.
  • Control your server with Apache Benchmark from the second instance:

    ab -c 1 -n 20000 http://<private_server_instance_ip>:<port>/<URL>

    It is important to set a private IP address here, not a private or public DNS, in order to eliminate the effects of domain name resolution.

  • Check the average time spent on the request: if it is about 1 ms, the described problem does not apply to your server.

Benchmarking with FireFox BTW may not be the best idea, because the results may depend on a number of circumstances.

0
source

Source: https://habr.com/ru/post/1380651/


All Articles