Let us suppose that the Unix domain socket created for a specific server-client program. Customer sends 10 GB buffer to the socket and meanwhile it is consumed by the server.
Does OS (Linux / BSD) split 10 GB buffer into multiple packets and sends / consumes them, or do they
if at one time the domain socket 10 Can not send a GB buffer, so what is the limit of the practical size of a packet?
Obligations:
- The program will run on both Linux 2.6.32+ and free BSD 9 + +
- The buffer size ranges from 3 bytes Up to 10 GB maximum will be sent.
-
If multiple packets are sent to Unix socket (using SOCK_DATAGRAM), then the maximum amount can be sent without blocking the data, both buffer sizes of the socket (See above) depends on the maximum number of unread packs on and Unix socket (kernel parameter
net.unix.max_dgram_qlen).
andFinally, according to a packet (SOCK_DATAGRAM) requires moderation (according to) memory. How many popular memory is available in the kernel depends on many factors (such as I / O load on the system etc ...)
So to maximize the performance on your application, you have a socket buffer size (due to socket writing system calls to reduce the user / kernel space projection switch) and A large unix socket queue (as much as possible to reduce productive and consumer volume) is required. However, the product of the socket sends the buffer size and the length of the queue will not be as large as the kernel causing the exit from the memory areas (due to write failures).
Actual figures will require you to set limits by using your system configuration and usage ... initially from
wmem_max
to 256 KB andmax_dgram_qlen
Start at 32 and keep repeatingwmem_max
as long as you do not notice Start to start things, adjust themax_dgram_qlen
to balance the activity of the manufacturer and the consumer. Will need to be (though if If the producer is faster or too slow than the consumer, then the size of the queue will not have much effect).Note that your manufacturer has to send the socket to the buffer size by calling
wmem_max
bytes and sending the code to setockopt (SO_SNDBUF)wmem_max
to split the data into the byte segment (and the user has to re-submit them).Best guess: Practical limitations should be around wmem_max ~ 8Mb and unix_dgram_qlen ~ 32.
There are several factors that will determine the maximum size of a packet which is a Unix socket: wmem_max
socket buffer sends the maximum size kernel setting, which determines the maximum size of the buffer that can be set using the code. Setocap (SO_SNDBUF) can be read from / proc / sys / net / core / wmem_max
and sysctl net.core.wmem_max = VALUE
( Setting is to be changed in the /etc/sysctl.conf
reboot). Note that this setting applies to all socket and socket protocols, not only on Unix Sockets.
Comments
Post a Comment