-
Notifications
You must be signed in to change notification settings - Fork 0
How HAProxy Balances Mongo Reads
Azita Abdollahi edited this page May 6, 2025
·
1 revision
HAProxy forwards client connections to secondary MongoDB members using round-robin balancing.
-
frontend mongodb_readslistens on port27018 -
backend mongodb_secondariesincludesmongodb2andmongodb3 -
mode tcpmeans no protocol inspection (needed for MongoDB)
This allows:
- Efficient distribution of read queries
- HAProxy health checks to ensure only live secondaries are used
You must ensure:
- Reads are allowed on secondaries (
rs.secondaryOk()) - Clients use
readPreference: secondaryPreferredor similar