Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is my current test setup:

  • SQL0: (master+slave)
  • SQL1: (master+slave)
  • loadbalancer0:
  • loadbalancer1:
    • Virtual IP:

The Loadbalancers are connected to eachother using heartbeat, and both of them run MySQL-Proxy.

Everything works like a charm; one of the SQL server dies, everything stays up. One of the LBs die, everything stays up.

However, when checking which SQL server is being used, I noticed it's always the same, unless that one becomes unavailable.

After a couple of hours SQL1 for example has 600.000 queries, whereas SQL0 has, say, 20.000.

Is there a way to balance it more, to come near ~50% SQL0, and ~50% SQL1?

This is my basic line I start the proxy with:

/usr/bin/mysql-proxy --proxy-skip-profiling -b -b --keepalive -P :3306

As proof, here a test run every 10 mins since yesterday afternoon.

enter image description here

share|improve this question
up vote 1 down vote accepted

The MySQL proxy is connection based. You mentioned queries in your question, to use that as an example if you have one box that opens up one connection and does 100,000 queries over it, they will all go to the same back-end server. You can verify this by looking at the source code:

182         GQueue *conns = network_connection_pool_get_conns(pool, username, NULL);
184         /**
185          * if we know this use, return a authed connection
186          */
187         if (conns) {
188                 entry = g_queue_pop_head(conns);

It is just grabbing the next connection off the pool. If you look at number of TCP connections for the ODBC you are using they should come out to 50/50.

You could look at increasing the number of db connections in your ODBC configuration for your application in hopes of spreading the query load that way.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.