. Net Core Socket Stress test
Recall that the previous colleague said go Lang wrote the push service machine can reach 800,000 connections, so you want to test how much. Net Core can achieve. Simply write the full-async server and client code (without any optimizations). Test environment is only notebook 180,000 connection CPU point 26% memory point 1.2G, visually placed on the server 800,000 there is still hope.
First, the test code
Server: Initiates TcpListener listener, asynchronously accepts client connection Accepttcpclientasync. After the connection arrives, asynchronously reads the client data and sends the data back to the client intact.
Client: Start 60 tasks, each task asynchronously connected to the server, after the connection to start the data sending and receiving tasks, in the sending and receiving tasks, the first to send 140bytes of data to the server and then read the data returned from the server, waiting for 30s (task.delay) loop front-end receiving and waiting steps. A total of 60,000 connections.
Data statistics: The server client has the corresponding data statistics, statistics are: The number of connected sockets, the total number of packets sent, the total number of received packets.
Code Address: Https://github.com/chrishaly/TcpStressTest
Second, the test method
Server: Windows 10, running the service program.
Client: (1) Windows 10 and service side same machine (2) Windows Server r2-vmware (3) Windows 7-vmware. Add DWORD value under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters because Winodws has a limit on the number of connections required to modify the registry increase number of connections maxuserport=65534. Run the client program on the client host. 3 clients Each 60,000 connection only 180,000 connection
III. Environment and results (details of each process)
Host |
Configuration |
Number of socket connections |
CPU consumption |
Memory consumption |
Service side |
Notebook I7-4720HQ, 16G memory |
179900 |
19% ~36% |
1.2G |
Client Win 10 |
Notebook I7-4720HQ, 16G memory |
60,000 |
5% |
241M |
Client Win 2012 |
VMWare 1 CPU 1 Core, RAM 2G |
60,000 |
Around 8% |
318M |
Client Win 7 |
VMWare 1 CPU 4 Core, RAM 2G |
59,900 |
Around 8% |
258M |
Iv. Some problems encountered: mainly on the socket connection limit, modify the registry on Windows.
Five, the episode: The client was originally to use Linux, first with the Debian 8.6 x64 connection number reached 16,000 problems, found the next Debian maximum connection number Ulimit–a No limit, did not continue to find the reason. Decisively opened the Ubuntu Server 16.04 TLS connection is also around 16,000 appeared the addressalreadyinuse exception, and then tried the desktop version of Ubuntu 16.04 TLS also has this problem. The goal is to test the virtual machine too much for another one, using VMware Win 7, VMware Windows Server R2. Debian, Ubuntu connection data problems to see later.
Six, there is a picture of the truth: 4 running Windows upper left corner that is the service side
Service process condition: PID is 19944 for the service process
. Net Core Socket Stress test