Menu

Why Patroni failover takes 26–49 seconds with default settings (and how to make it faster)
📰

Why Patroni failover takes 26–49 seconds with default settings (and how to make it faster)

DEV Community: postgres·Diego Gil Serrano·2 days ago
#oLHnO8zA
#devtopostgresql#devto#dev#patroni#primary
Reading 0:00
15s threshold

You build a Patroni + etcd + HAProxy cluster, kill the primary in a test, and your write loop stops for half a minute or more. Nothing is broken. That is what the default settings are designed to do. This post explains where those seconds go and what you can change.

The three settings that matter

All three live in Patroni's dynamic configuration (stored in the DCS, changed with patronictl edit-config ). From the official documentation:

Setting What it is Default Minimum

loop_wait "the number of seconds the loop will sleep" between HA cycles 10 1

ttl the TTL of the leader lock; "think of it as the length of time before initiation of the automatic failover process" 30 20

retry_timeout "timeout for DCS and PostgreSQL operation retries"; "DCS or network issues shorter than this will not cause Patroni to demote the leader" 10 3

The documentation also sets a hard rule when you change them:

loop_wait + 2 * retry_timeout <= ttl

Enter fullscreen mode

Exit fullscreen mode

With defaults: 10 + 2 × 10 = 30 ≤…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.