. NET Socket TCP 50W Online connection interaction test

Source: Internet
Author: User

In normal communication, people often ask how much online can the. NET socket support? Is it far from C + + or Linux? The main reason for this problem is that. NET few people do this kind of testing, And under Linux, you often hear about 100w or 500w online connectivity tests. How exciting the numbers seem to be ... In fact, in the process of writing a communication service in the past few years, it is realized that the number of connections has little effect on the whole, mainly due to the familiar network model and hardware resources. In order to further confirm the problem, I intend to. NET under test 100w connection interaction, but due to insufficient hardware memory can not be 100W connection, so can only run a 50W online effect.

Test the limited number of hardware and IP port limits, in order to meet this time the test needs to have to add multiple IPs on a single machine ...

10 IPs were added to the client computer for testing, each IP was bound to 10000-60000 ports, and the tester built a thread for each IP to create the connection, and after the connection was created, a quantitative round-robin connection sent messages to the server.

Test Program

static void Connect (object state)

{String IPAddress = (string) state;            System.Net.IPAddress IP = System.Net.IPAddress.Parse (IPAddress); for (int i=10000;i<60000;i++) {try {Socket msocket = new S                    Ocket (AddressFamily.InterNetwork, SocketType.Stream, protocoltype.tcp);                    Msocket.bind (New System.Net.IPEndPoint (IP, i));                    Msocket.connect (Mhost, mport);                    SocketAsyncEventArgs SAE = new SocketAsyncEventArgs (); Sae.                    SetBuffer (new byte[1024], 0, 1024); Sae.                    Usertoken = Msocket;                    sae.completed + = OnReceive;                    BeginReceive (Msocket, SAE);                    Lock (Msockets) {msockets.add (msocket); }} catch (Exception e_) {Console.WriteLine ("Create Socke T client error {0} with {1}@{2} ", E_. MessAge, IPAddress, i);            } System.Threading.Thread.Sleep (1);                    } while (true) {for (int i = 0; i <; i++) {                    Long index = System.Threading.Interlocked.Increment (ref mindex); msockets[(int) (index% msockets.count)].                Send (Encoding.UTF8.GetBytes ("{\" name\ ": \" henryfan\ "}"));            } System.Threading.Thread.Sleep (1); }        }
The code program is relatively simple, each time to get 20 connections for data transmission, each send after the sleep once, so that the main purpose is to prevent the use of resources to run out of the test; after all, this time the test is based on the number of connections. Test Results

The entire test results and I think not much of the discrepancy, after the construction of 50W connection due to the small amount of data interaction, so in addition to occupy more memory than the basic server CPU pressure.

   

50W Connection The entire interaction is approximately 1.2w of request response per second. Because there are too many connections in the case of more than more than 10 w connections, the Netstat has not been able to properly display the number of connections for that port ....; Although the number of connections is much higher, the program consumes less CPU resources.

The average CPU occupancy rate is about 7%.

the memory footprint of the server is around 2.6G, because the memory of the actual operating system that does not control the socket level is full.

Summarize

Due to memory limitations in these tests can not run to 100w connection a little pity. A very important question has been further explained from the results The ability to measure a service only from the number of connections does not make much sense. Only the request response volume can reflect the performance benefits of the service side. So when you see the 100W connected test article not to be amazed, After all, the request response volume is the embodiment of the index. If the students who are interested in their computer memory resources enough to make a higher number of connections, in order to facilitate testing and provide testing procedures.

/files/file/20140907/20140907145550_4695.rar


. NET Socket TCP 50W Online connection interaction test

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.