Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How many SSE connections can a web server maintain?

I'm experimenting with server-sent events (SSE) as an alternative to websockets for real-time data pushing (data in my application is primarily one-directional).

How scalable would this be? I know that each SSE connection uses an HTTP request -- does this mean that a web server can handle as many SSE connections as HTTP requests (something like this answer)? I feel as though this might be the case, but I'm not sure how a SSE connection works and if it is substantially more complex/resource-hungry than a simple HTTP request.

I'm mostly wondering how this compares to the number of concurrent websockets a browser can keep open. This answer suggests that only ~1400-1800 sockets can be handled by a server at the same time.

Can someone provide some insight on this?

(To clarify, I am not asking about how many SSE connections can be kept open from the client; I am asking about how many can be reasonably kept open by a web server.)

like image 833
Jonathan Lam Avatar asked Nov 03 '18 22:11

Jonathan Lam


1 Answers

Tomcat 8 (web server to give an example) and above that uses the NIO connector for handling incoming requst. It can service max 10,000 concurrent connections(docs). It does not say anything about max connections pers se. They also provide another parameter called acceptCount which is the fall back if connections exceed 10,000.

socket connections are treated as files. Every incoming connection to tomcat is like opening a socket and depending on the OS e.g in linux depends on the file-descriptor policy. You will find a common error when too many connections are open or max connections have been reached as the following

java.net.SocketException: Too many files open

You can change the number of open files by editing

/etc/security/limits.conf

It is not clear what is max limit that is allowed. Some say default for tomcat is 1096 but the (default) one for linux is 30,000 which can be changed.

On the article I have shared the linkedIn team were able to go 250K connections on one host.

So that should give you a pretty good idea about max sse connections possible. depends on your web server max connection configuration, OS capacity etc.

like image 68
veritas Avatar answered Jan 03 '23 00:01

veritas