MongoDB & HAProxy

If you want to put haproxy in front of mongodb cluster, haproxy needs to know the status of mongodb nodes. I’ve found this config, which uses mongos native ping command. But I needed to know, which node is master (because I use simple replication, not a shard) so I can send write queries. For this purpose, I’ve modified that config, so it uses isMaster() function and expects “ismaster\x00\x01” as result.