Load balancing over a pool of slaves based on replication delay

Hi,

I’m looking to load balance over a bunch of slaves where I’d like the LB to send the incoming connection to the server that has the least amount of replication delay. Checked out HAproxy and a couple of others and it looks like you can do it with least connections but not for load balancing based on a custom metric like replication delay.

Does anyone have any good ideas before I write my own load balancer?

Thanks,

Andrew