From: Steve Litt slitt@troubleshooters.com
Recently I've been getting the dreaded X error "Maximum number of clients exceeded", so I performed an lsof -U to find who was using UNIX sockets. This uncovered a buggy looping program I wrote using up gobs of UNIX sockets, along with some browsers, dbus-daemon, electron (used by vscode), smbd, and Dovecot, which uses 36 UNIX sockets.
Only 36? The number of sockets seems to scale proportionally with the number of users. The login process of my service easily consumes several hundred sockets and could on occasions run into the thousands. (See also my previous posts on socket starvation.)
Each client connection will consume a few sockets -- it uses maybe a few more than some applications do as they separate privileged daemons from worker daemons, and pass data around via sockets, but socket use if within reason.
I can kill dbus-daemon and the buggy program I wrote, minimize use of browsers, disable smbd except when I (rarely) need it, but can you think of things I can do to reduce the number of UNIX sockets used by Dovecot on my machine?
You can limit the number of clients per IP (e.g. mail_max_userip_connections) to lower the number of concurrent mailboxes that are open. Or use the idle process facility to park inactive connections (not sure if that frees sockets). Or cap the number of clients (process_limit, service_count, etc.), but if you're bumping up against those limits, you've either underprovisioned your service or you have something misconfigured. (Again, see my previous post on service_limit.)
Maybe you need to *increase* those limits if you're hitting some client limit in regular use.
From what you describe, you resolved the cause of your socket starvation whose cause was not dovecot. I'm not sure what you hope to gain by saving a few sockets that dovecot uses just to make headroom for a buggy script.
Joseph Tam jtam.home@gmail.com