Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to maximize the epoll concurrency of 4G memory servers

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to achieve the maximum concurrency of 4G memory server epoll". The explanation in this article is simple and clear and easy to learn and understand. Please follow Xiaobian's train of thought to study and learn "how to achieve the maximum amount of 4G memory server epoll concurrency".

According to the subject means to calculate a maximum number of concurrent connections according to memory. The first thing to do is to find out where a single connection consumes memory.

The first one is socket buffer. There is one for read and one for write, and the default size is

The code is as follows:

/ proc/sys/net/ipv4/tcp_rmem (for read)

/ proc/sys/net/ipv4/tcp_wmem (for write)

The default sizes are both 87K and 16K, the lowest is 4K and 4K, and the highest is 2m and 2m. In practice, the minimum default value should be 8K and 8K.

And then the logical IO buffer.

For example, if you listen for recv events, you need to have memory available (usually socket is set up and allocated, and disconnected will be released).

This memory is self-controlled when writing socket programs, the minimum is 4K, and the actual use of 8K is 8K.

Now set up an optimization scheme and usage scenario, first assume that 4G memory is all free (the system and other processes also need memory. .

If the size of the network packet can be controlled below 4K, it is assumed that all connected networks will not be congested, or the total amount of congestion is less than 4K:

The memory consumption of a connection is 4 "4" 4 "4" 16K.

4G hand 16K = 262000 concurrency

If the size of the network packet can be controlled below 8K, it is assumed that all connected networks will not be congested, or the total amount of congestion is less than 8K.

The memory usage of a socket is between 24K and 32K, which is conservatively calculated according to 32K.

4 Gram 32K = 131000 parallel, this in the production environment as a pure network level of memory consumption, can be used as a reference.

If the default configuration is used, if all connected networks are seriously congested, the logical occupation of the sending queue is not considered.

Using the default configuration is 2M+2M+8+8 ~ = 4m

4G/4M=1024 concurrency (…

If you consider that the sending queue is also congested, you can make up for it yourself.

If it is optimized only for running points and for concurrency, there is no resident logical buffer and the network throughput of socket is very small and the load is smooth, set the socket buffer size system to the lowest.

So, yes.

4G/8K = 524000 concurrency this should be the limit.

Thank you for your reading. the above is the content of "how to achieve the maximum epoll concurrency of 4G memory servers". After the study of this article, I believe you have a deeper understanding of how to achieve maximum epoll concurrency of 4G memory servers, and the specific usage needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report