In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article shows you how much the maximum concurrency of Linux server is, the content is concise and easy to understand, definitely can make you shine, through the detailed introduction of this article I hope you can gain something.
1. opening remarks
Before starting today's article, throw out an interview question:
What is the maximum concurrent number of stand-alone computers you have encountered?
What do you think is the maximum concurrent number of server physical machines currently configured normally?
For back-end developers, concurrency tends to correlate positively with technical difficulty, and it does: volume determines architecture.
The server will have different emphases according to different business scenarios. The pursuit of high concurrency is not the fundamental goal. High availability & stability is more important.
Therefore, our ultimate goal is to pursue high concurrency, reduce costs and increase efficiency on the basis of ensuring high availability and high stability.
High availability & high concurrency is what we intuitively feel. In essence, this is a complex system engineering. Every link will affect the result. Every piece is worth studying and deepening.
2. C10K and C10M problems
At the beginning of 2000, the scale of the global Internet was not large, but at that time, the C10K problem had already been raised. The so-called C10K was a stand-alone 1w concurrency problem. Although it is not a difficult problem now, it was a very far-sighted and challenging problem at the beginning.
There is no mention of epoll in APUE version 3, so we do not have a long time to solve the C10k problem, in which IO multiplexing epoll/kqueue/iocp and other technologies play a very important role in solving the C10k problem.
Open source gods have developed network libraries such as libevent/libuv based on epoll/kqueue, which greatly improves the development efficiency of highly concurrent networks, which is no stranger to C/C++ programmers.
Here is a brief mention of the outlook and challenge for the next decade: the C10M problem.
The group of people who stood on the wave had long begun to think about making a single machine reach 1000w concurrency. Now it sounded incredible, but to achieve this goal, in addition to hardware upgrades, more important was the transformation of the system software and protocol stack.
Errata Security CEO Robert Graham's speech at Shmoocon 2013, the big guy's important point is:
Don't let the OS kernel do all the heavy lifting: shift packet processing, memory management, processor scheduling, etc. from the kernel to the application to do it efficiently, and let an OS like Linux handle only the control layer, leaving the data layer entirely to the application.
That's true, don't you think the Linux kernel does too many things it shouldn't?
DPDK, PFRING, NETMAP and other technologies that have appeared in recent years are similar ideas, and the popular coprocessor +CPU architecture is also like this:
3. Analysis of Maximum Concurrent Number of Server
The aforementioned C10K and C10M questions revolve around improving server concurrency, but it is inevitable to ask: What is the maximum concurrency limit of the server?
3.1 five-tuple
Friends who have done communication must have heard of the concept of a quintuple. A quintuple can uniquely label a network connection, so to understand and analyze the maximum concurrency number, you must understand the quintuple:
In this case, it can be basically considered that: theoretical maximum concurrency = number of unique quintuples on the server side.
3.2 Port &IP combinations
So what is the maximum number of unique quintuples on the server?
Some people say 65535, obviously not, but the reason there are such answers is because the current Linux port number is a 2-byte short type, a total of 2^16 ports, excluding some of the ports occupied by the system, the available ports are really only more than 64000.
For the server itself, the number of DestPorts is indeed limited. Suppose there are multiple network cards, and each network card is bound to multiple IPs. The combination of the number of ports and the number of IPs on the server is also limited.
For the client, the port and IP itself are also limited, although this is a combination problem, but the number is still limited:
3.3 theoretical limit of concurrency
Looking at the previous port &IP combination calculation, it seems that the number of concurrency is not particularly large.
No, it's really going to be big.
Analysis, the previous calculations are for a single server or client, but in fact each server will deal with all clients of the entire network, so from the server point of view, the number of source IPs and source ports is very large.
Theoretically, the client IP that the server can accept is 2^32(calculated according to IPv4), the port number is 2^16, and the current port number is still 16 bits. All this theoretical maximum value is 2^48, which is really large!
3.4 actual situation
There is no such thing as a free lunch.
Each connection consumes system resources, so in practice it is possible to set the maximum number of concurrency to ensure the security and stability of the server, so this theoretical maximum number of concurrency is impossible to achieve.
In fact, the number of concurrency and business are directly related, such as Redis memory type server concurrency hundreds of thousands are no problem, most of them tens/hundreds/thousands/tens of thousands of etc. exist.
4. Maximum number of client connections
Understand that the maximum number of concurrent servers is 2^48, so how many servers can the client connect to at most?
For the client, of course, you can increase the connection capacity by means of multiple network cards and multiple IPs. We still assume that the client has only one network card and one IP. Due to the limitation of the number of ports to 2^16, the ports occupied by the system are removed, leaving almost 64000 available.
That is to say, although the client can connect to any destination IP and destination port, the client's own port is limited, so the theoretical maximum number of connections of the client is 2^16, including the system occupied port.
5. Client in NAT Environment
After solving the first two problems, let's look at another problem:
How many simultaneous intranet IPs can a public network egress NAT service device support to access public network services simultaneously?
After all, public network IP is limited and expensive. Most of our machines are connected to NAT in the local area network for external network access, so this scenario is still very familiar.
Take a look at the process of IP& port replacement and mapping restoration when the intranet machine accesses the external network, and you will understand:
Because the client at this time is a NAT device, a maximum of 65535 concurrent accesses to the external network are supported in a NAT environment.
What is the maximum concurrency of Linux servers? Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserves, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.