From 4b721bfcd4c168ad4301f2c8750217a0d56339be Mon Sep 17 00:00:00 2001 From: link2xt Date: Mon, 2 Jun 2025 22:02:59 +0000 Subject: [PATCH] Reconfigure imap-login to high-performance mode High-security mode could be configured to handle more connections by increasing process_limit, but has problems logging in many users at once after each Dovecot restart or config reload. --- CHANGELOG.md | 3 ++ cmdeploy/src/cmdeploy/dovecot/dovecot.conf.j2 | 36 +++++++++++++------ 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c4bc075..034155b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## untagged +- Reconfigure Dovecot imap-login service to high-performance mode + ([#578](https://github.com/chatmail/relay/pull/578)) + - Increase nginx connection limits ([#576](https://github.com/chatmail/relay/pull/576)) diff --git a/cmdeploy/src/cmdeploy/dovecot/dovecot.conf.j2 b/cmdeploy/src/cmdeploy/dovecot/dovecot.conf.j2 index d6e9e878..f6511be0 100644 --- a/cmdeploy/src/cmdeploy/dovecot/dovecot.conf.j2 +++ b/cmdeploy/src/cmdeploy/dovecot/dovecot.conf.j2 @@ -177,20 +177,34 @@ service auth-worker { } service imap-login { - # High-security mode. - # Each process serves a single connection and exits afterwards. - # This is the default, but we set it explicitly to be sure. - # See for details. - service_count = 1 - - # Inrease the number of simultaneous connections. + # High-performance mode as described in + # # - # As of Dovecot 2.3.19.1 the default is 100 processes. - # Combined with `service_count = 1` it means only 100 connections - # can be handled simultaneously. - process_limit = 10000 + # So-called high-security mode described in + # + # and enabled by default with `service_count = 1` starts one process per connection + # and has problems logging in thousands of users after Dovecot restart. + service_count = 0 + + # Increase virtual memory size limit. + # Since imap-login processes handle TLS connections + # even after logging users in + # and many connections are handled by each process, + # memory size limit should be increased. + # + # Otherwise the whole process eventually dies + # with an error similar to + # imap-login: Fatal: master: service(imap-login): + # child 1422951 returned error 83 + # (Out of memory (service imap-login { vsz_limit=256 MB }, + # you may need to increase it) + # and takes down all its TLS connections at once. + vsz_limit = 1G # Avoid startup latency for new connections. + # + # Should be set to at least the number of CPU cores + # according to the documentation. process_min_avail = 10 }