On 20 Apr 2017, at 17.35, Webert de Souza Lima webert.boss@gmail.com wrote:
Hi,
often I run into the situation where a dovecot server goes down for maintenance, and all users get concentrated in the remaining dovecot server (considering I have 2 dovecot servers only).
When that dovecot server comes back online, director server will send new users to it, but the dovecot server that was up all the time will still have tons of clients mapped to it.
I suggest the director servers to always try to balance load between servers, in the way:
- if a server has several more connections than other, mark it to re-balance
- when a user connected to this loaded server disconnects, map it to another server (that is per definition not the same server) immediately.
that way it would gracefully re-balance, not killing existing connections, just waiting for them to finish.
You could effectively do this by shrinking the director_user_expire time. But if it's too low, it causes director to be a bit more inefficient when assigning users to backends. Also if backends are doing any background work (e.g. full text search indexing) director might move the user away too early. But setting it to e.g. 5 minutes would likely help a lot.
There's of course also the doveadm director flush, which can be used to move users between backends, but that requires killing the connections for now. I've some future plans to make it possible to move connections between backends without disconnecting the IMAP client.