Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to adjust socket descriptors?

Tags:

enter image description here

I want to know who to adjust quantity of the socket descriptors?

In addition, how to auto-close the connection for limited timeout?

like image 677
Chen Yu Avatar asked May 10 '14 06:05

Chen Yu


People also ask

How do you increase socket descriptors in Rabbitmq?

You can do this by running locate rabbitmq-server on the bash prompt. Then open the file with sudo vim /etc/default/rabbitmq-server . It is a file which will contain the line ulimit -n 4096 . If the line is commented out with a # , uncomment the line.

What are socket descriptors?

Each socket within the network has a unique name associated with it called a socket descriptor—a fullword integer that designates a socket and allows application programs to refer to it when needed.

Do sockets use file descriptors?

There is no difference between a socket (descriptor) and a file descriptor(s). A socket is just a special form of a file. For example, you can use the syscalls used on file descriptors, read() and write(), on socket descriptors.

What is socket descriptor in Unix?

Sockets allow communication between two different processes on the same or different machines. To be more precise, it's a way to talk to other computers using standard Unix file descriptors. In Unix, every I/O action is done by writing or reading a file descriptor.


1 Answers

Looks like you have to change max opened file descriptors in your system.

From RabbitMQ installation manual for Debian and Ubuntu systems, section Controlling system limits:

RabbitMQ installations running production workloads may need system limits and kernel parameters tuning in order to handle a decent number of concurrent connections and queues. The main setting that needs adjustment is the max number of open files, also known as ulimit -n. The default value on many operating systems is too low for a messaging broker (eg. 1024 on several Linux distributions). We recommend allowing for at least 65536 file descriptors for user rabbitmq in production environments. 4096 should be sufficient for most development workloads.

There are two limits in play: the maximum number of open files the OS kernel allows (fs.file-max) and the per-user limit (ulimit -n). The former must be higher than the latter.

The most straightforward way to adjust the per-user limit for RabbitMQ is to edit the /etc/default/rabbitmq-server (provided by the RabbitMQ Debian package) or rabbitmq-env.conf to invoke ulimit before the service is started.

ulimit -S -n 4096

This soft limit cannot go higher than the hard limit (which defaults to 4096 in many distributions). The hard limit can be increased via /etc/security/limits.conf. This also requires enabling the pam_limits.so module and re-login or reboot.

Note that limits cannot be changed for running OS processes.

For more information about controlling fs.file-max with sysctl, please refer to the excellent Riak guide on open file limit tuning.

P.S.:

The similar issue was discussed in RabbitMQ mailing list "Increasing the file descriptors limit". The last message contains final link to the RabbitMQ installation document and explicitly point to ulimit issue, but reading through it also may help you to deal with you problem while the whole thread covers the descriptors limit issue from different points.

like image 91
pinepain Avatar answered Oct 01 '22 14:10

pinepain