Source: S9t9 For real-time data acquisition projects
S9T9 for real-time data acquisition projects, scenarios such as this: 5000 clients, each client every 500MS to upload data to the server.
As you know, the S9T9 forum, like Indy This blocking communication control, can generally support a TCP long connection that cannot be more than 1000 (if you want to maintain a stable operation).
The reason is that everyone knows that the blocking method will create a new thread for each socket connection, and that the maximum number of threads a single process in Windows can theoretically allow is 2048.
Actually, it's a lot less to do.
Some say it can be solved with the IOCP communication model of windows, admittedly. But IOCP programming is too complex.
It is said that you can use Indy to solve the problem by using a short connection. In view of the frequency of uploading data every 500MS, short connections are not really suitable, because a short connection will have to establish and disconnect the socket every time.
It is particularly time-consuming to establish and disconnect socket connections, so you use a TCP long connection.
Some people say why think of blocking, the answer is: because blocking programming is the simplest.
In fact, for the 5000-long connection of the client, Indy can have a way to achieve. Since a single process can only support 1000 or so long connections, is it possible to support 5,000 long connections by opening 5 processes?
It is said that the blocking of the 5,000 connections means that Windows will open 5,000 threads, so many threads, windows can suffer.
So immediately hands-on experiment, a process opened 1500 threads, a total of 4 processes, each thread every 100ms, execution for the i:=1 to Do,windows Task Manager display, each process
Occupy 40.4M of memory, CPU utilization rate only percent a fraction, total CPU usage only a few percent, memory usage rate also only 20%,windows dispatch not a little problem.
This scenario requires only one public network IP, which binds different ports for different processes.