I have a website in which Javascript sends HTTP POST Ajax requests every 5 seconds to a PHP script on a CentOS server. If I check netstat
, I see lots of connections in TIME_WAIT
state (mostly between 6 and 9). And this is for just one user. But the website should be getting hundreds, maybe thousands of such requests every 5 seconds from users viewing the website. The PHP script then gets some data from the DB to return it to the user. So I am wondering if my current solution is good/not resource intensive for the server.
I have looked into changing network settings on the server, such as the usual net.ipv4.tcp_fin_timeout
,
net.ipv4.tcp_tw_recycle
and
net.ipv4.tcp_tw_reuse
.
But the first one is not related to how many TIME_WAIT connections there can be. And I'd rather not change these settings, because it's a web server for the website etc, and not a dedicated server for keepalives only.
I was wondering if Ajax can send HTTP POST using UDP to get rid of the TCP-specific overhead, but that is not possible.
This leads me to the questions: what else can I do to make the sending of keepalives as less resources intensive as possible? Is there a lightweight server service that can handle these kinds of requests?