mysql-proxy, urgh performance and scalability ?

For one our project I needed proxy solution, and mysql-proxy is one of well-known, so it was logical first choice. The obvious question which come in mind is what performance penalty we have using mysql-proxy, version 0.7.1.
So it is easy to test. (By the way sysbench recently was pushed to Launchpad, see lp:sysbench, and Percona is going to be active developer of this project and scripting benchmarks).

I took lp:sysbench with LUA script oltp_complex_ro, and tested for couple connections, here are results (in transactions per second, more is better)


ok, and let’s look on response time (for 1 thread).



Well, I expected some penalty of using proxy… but 2-3x times, that’s overkill. Worth to consider if you want to run Query Analyzer with MySQL-proxy on your MySQL Enterprise setup.

There is alternative – Dormando-proxy, which I want to try also, but the problem is it crashed under sysbench load, so I was not able to get any results yet.

Share this post

Comments (44)

  • peter Reply


    It is interesting what peak overhead would you observe ie if you’re looking at simple sysbench.

    A lot of web applications have a lot of very simple queries (close to single row lookup by key) and these will show maximum overhead.

    On the lower part we probably can try some streaming of large data.

    And well…. Compared to this the overhead we observe by using full slow query logging on server is negligible.

    June 9, 2009 at 10:00 pm
  • Jan Kneschke Reply

    Hi Vadim, please benchmark the current trunk. It has a threaded network-io (–event-threads=4) and want for the 0.9 release which will remove the global Lua lock which is limiting the throughput too. Without a Lua script trunk should show a huge difference already.

    June 10, 2009 at 1:49 am
  • Kay Roepke Reply

    Hi Vadim!

    As you’ve found, the single-threaded implementation of 0.7.1 has its limits. And depending on the workload yes the hit can be up to 75% (which matches quite nicely with worst-case benchmarks I have done in the past).

    As Peter points out: It is interesting to look at the overhead curve across different applications.
    My rule of thumb for 0.7 performance is: The shorter the query execution time, the higher the overhead will be. This is a direct consequence of 0.7 being single-threaded and event-based, because MySQL Proxy 0.7 can make progress whenever it waits for events, so naturally many short queries will mean that Proxy needs to do a lot of work for each query (because the result packets will arrive very shortly after the query was issued, decreasing the time it can spend on other queries).
    Lots of work in Lua scripts will also block progress on other connections in 0.7.

    For 0.8 (current trunk on Launchpad) the picture is different: The multithreading in it applies to all network communication, even when one thread is spending time in Lua (although in 0.8 only one thread can be in Lua-land at any given time – lifting this is scheduled for 0.9 as Jan says). Thus Proxy can make progress on up to as many connections as you have event-threads running. Connections can wander between threads, so on average you can have as many concurrent active connections being serviced as you have threads.

    We are ramping up on regular scalability testing for it, but are not quite there yet (waiting on some infrastructure to be ready) but once we are we will be publishing results regularly.

    If you are interested, we’ve spent quite some time improving the code and architecture documentation in the current trunk (you’ll need doxygen/graphviz/mscgen). It explains the architecture clearly, we are hoping 😉
    In case you find any bugs, please report them at in the Proxy component. If you have additional questions, we are on #mysql-proxy on freenode, as well.


    June 10, 2009 at 2:33 am
  • Baron Schwartz Reply

    It’s worth noting that this is an improvement over the last time I remember Vadim trying out mysql-proxy. Maybe I’m wrong, but I remember it crashing so we couldn’t really benchmark it? Vadim, do you remember that, or am I telling lies?

    June 10, 2009 at 5:40 am
  • Michael Peters Reply

    Have you looked at DBD::Gofer from the Perl world? It doesn’t support transactions but I’d be interested to see how it stacks up.

    June 10, 2009 at 6:37 am
  • erik Reply

    What about using ha-proxy? Its not an sql specific proxy but seems like it could balance the connections just as well as anything.

    June 10, 2009 at 7:28 am
  • Vadim Reply


    I will try recent trunk.
    Current run was without Lua scripts, but actually I am looking to add some scripts, we I need Lua…

    June 10, 2009 at 8:19 am
  • Vadim Reply


    It was long time ago and was very early releases, so I do not remember all details. Can’t say it was in previous release.

    June 10, 2009 at 8:21 am
  • Vadim Reply


    I did not try ha-proxy, it seems it does not support functionality I need, I am looking to handle coming queries in one specific way.

    June 10, 2009 at 8:28 am
  • Robert Reply

    Hi Vadim,

    Try Tungsten Connector. ( It’s written in Java and schedules threads efficiently across multiple cores.

    Also, what do you need Lua for? If you provide a use case we can look at how to get it for you. We have a lot of work afoot in this area, for example implementing session consistency load balancing.

    Cheers, Robert

    June 10, 2009 at 1:05 pm
  • Robert Reply

    BTW Vadim, it looks as if you are hitting the proxy math problem I talked about at your recent and highly esteemed “Performance is Everything” conference. (Slides:

    June 10, 2009 at 1:09 pm
  • mtkopone Reply


    Informative post, but it wasn’t clear to me whether the you used some kind of connection pooling? I.e. is the performance bad because of connection creation, or will the penalty effect each query run thru an open connection.

    June 30, 2009 at 2:24 am
  • B Clark Reply

    This is disappointing. So … what are we supposed to use or do for loadbalancing?

    March 11, 2010 at 8:51 am
  • K. Heraud Reply

    Yes, goog question…
    I have been adviced not to implement using two databases in my webapplication just to split between writes and reads (master / slaves). So I thought mysql-proxy could be great…

    If it leads to 2-3x overheads, is there another alternative to deal with that ?

    July 25, 2011 at 3:47 am
  • Mike Reply

    I’m running MySQL 5.5 with MySQL Enterprise Manager 2.3.6

    I was wondering how many use mysql proxy “in the middle” in order to get Query Analyzer functionallity? This is really all I want it for. I’m at a crossroads trying to decide if going forward want to start implimenting mysql agent “in the middle” on all our production databases to get the Query Analyzer functionality. The main drawbacks I’ve found are the following:

    – Upgrading the agent requires downtime
    – Not able to use IP level access control on user accounts. Have to use ‘webuser’@’%’ for example.
    – Not able to see what servers users are logging in from since all logins are from the agent and are displayed as “localhost” in the processlist.
    – If agent crashes, access to database is lost.
    – Increased overhead.

    I’m just not sure it’s worth it!!

    Just wondering what others are doing. Is MySQL Agent used “in the middle” commonly in production databases?


    September 20, 2011 at 10:35 am
  • Tank Reply

    Is there an alternative proxy now? The main features I want are the following:
    – Connection pool.
    – Failed Over.
    – Sharding.
    – Query Router.

    In addition it is better support stored-procedure and transparent between Mysql Server and application client.

    SQL Relay looks good, but it is not transparent, must break the current code.

    February 27, 2012 at 8:04 pm
  • Vadim Tkachenko Reply


    I am not aware about opensource/free solution.
    From commercial side you may take look at ScaleArc.

    February 27, 2012 at 8:08 pm
  • Robert Hodges Reply

    Look also at Tungsten Enterprise from Continuent. Its Connector has strong failover and query routing capabilities. I do not know of any open source solutions that approach either Tungsten Enterprise or Scalarc capabilities at least for MySQL. (Disclaimer: I work for Continuent and Tungsten is our product.)

    February 27, 2012 at 8:20 pm
  • Tank Reply

    BTW, have you tried Mysql Proxy 0.8.2? How is it?

    February 27, 2012 at 8:47 pm
  • Vadim Tkachenko Reply


    I did not try, but I am not aware about performance fixes that could improve scalability in this version.

    February 27, 2012 at 9:19 pm
  • hotbollah Reply


    Wanted to use mysql proxy for load balancing my slaves for read. Is there a hardware alternative to mysql proxy that i can use to distribute load between my slaves (reads).


    March 5, 2012 at 4:18 am
  • hotbollah Reply


    Still waiting on some feedback. Would really appreciate if anyone knows about a hardware load balancer that can manage load balancing among slaves, as I am not keen on using mysql proxy.


    March 6, 2012 at 4:42 am
  • hotbollah Reply


    Can anyone throw some light on mysqlnd_ms, The mysqlnd replication plugin 1.1.0 release.

    We are working on it instead of mysql proxy as a load balancer.

    March 6, 2012 at 9:34 am
  • Tank Reply

    Hi hotbollah!
    yeah. But it seam to support PHP only, not my C++.

    March 6, 2012 at 7:47 pm
  • hotbollah Reply

    Hi Tank,

    You are right about its support for php, infact it comes in built in with new php4 version.

    It suits my need. But I was more interested in Hardware based load balancer due to heavy traffic, i am still afraid it might crash under load. Although not tried stress testing on it, would do once we apply it fully on our application.

    For you i guess mysql proxy would be a suitable option, spoken to a solution architect at pier1 data centre and she says most of our clients are using mysql proxy…..

    Are you aware of any hardware based load balancer, do let me know if you do


    March 7, 2012 at 2:59 am
  • Tank Reply

    thank you for your post.
    I’m sorry I don’t know about hardware based load balancer.
    I am trying to work on mysql proxy, hope it can help.

    March 7, 2012 at 6:28 am
  • Hotbollah Reply

    Hi Tank,

    After a long trial we have given up on mysqld, and now moving towards mysql-proxy as a solution for production server. was wondering if you can help in installation and configuration, tutorials or anything, as i tried installing with percona server and it just dosent work, or do anything..


    May 13, 2012 at 12:48 pm
  • Masood Alam Reply


    For people convenience I have posted MySQL proxy installation and configuration script. Feel free to try this out for load balancing MySQL database servers or to do read/write split. —> here is the detail.



    December 27, 2012 at 10:30 am
  • Jimmy Burnett Reply

    This mysql proxy documentation says MySQL proxy is in Alpha and not to use in production. Is this a typo?

    February 7, 2013 at 9:59 am
  • Masood Alam Reply


    It is in alpha indeed. Try at your own risk. I have seen a client running it on live system. We moved it away to Ha-proxy, depending on your requirement you can either choose Haproxy for load balancing. If you want to have more advance features of mysql proxy like read-write split and do not want to make any application changes then choice is yours.



    February 7, 2013 at 11:17 am
  • Ernest Mueller Reply

    Yeah, we just got done doing some benchmarks ourselves. We wanted to move to mysql_proxy from haproxy because we wanted better security in the cloud (on haproxy we have to have these admin level password-less accounts to run mySQL traffic through them). 95% TTLB was about 10% slower with haproxy than direct, but 40-60% slower (higher with more load) with mysql_proxy. Sad panda.

    February 11, 2013 at 12:20 pm
  • Masood Alam Reply


    Suddenly MYSQL-PROXY seems to be an hot issue here. My last comment on this would be that as a consultancy we moved client away from proxy because of it crashing in very busy production. Just to give you an idea client buffer pool size was over 100GB. If you want to use it please go ahead, at least my recommendations are against it and I think percona would not recommend it either.


    February 11, 2013 at 1:10 pm
  • Ernest Mueller Reply

    Sounds about right. Yeah, we had two hangs with no error messages or other indications there was anything wrong just in our testing, too. Hrm, I guess read/write splitting and secure proxying is still science fiction.

    February 11, 2013 at 2:45 pm
  • Masood Alam Reply

    If Ha proxy or mysql proxy is no good for you then please look into f5 load balancers for load balancing. Read/write can be done at application level aswell. Nginx can also be used for load balancing and is quite efficient and lightweight.

    February 11, 2013 at 2:53 pm
  • Jimmy Burnett Reply

    Anything wrong with using CSCO ACE?

    February 11, 2013 at 2:54 pm
  • Ernest Mueller Reply

    > Anything wrong with using CSCO ACE?

    Yeah, I can’t get Amazon to stick a couple dozen of ’em in their cloud for me 🙂 We have F5’s and Cisco gear but only in our one physical datacenter. Most of our dbs are in the cloud and part of autoscaling groups.

    Besides the security issue, one of the things we were hoping to get out of mysql-proxy was better load balancing (least connection, handling dynamic pools of db servers)… We can just close connections/pools more frequently to get some of that but at scale that’s a bummer.

    February 11, 2013 at 3:11 pm
  • Omid Reply

    We have been using mysql-proxy in production for more than a year to load-balance reads (the read/write balancing is done in the application). I don’t have any benchmarks or indications into performance gain/penalty. However, I can say that for our traffic (roughly 200 qps on average), mysql-proxy has been pretty stable and required no maintenance.

    March 6, 2013 at 3:27 pm
  • Masood Alam Reply

    Because of the traffic you are getting is bare minimum. I was looking at 20K plus queries per second databases for load balancing.

    March 6, 2013 at 3:30 pm
  • Omid Reply

    Hi Masood,

    I specifically noted the qps to show that mysql-proxy is NOT under heavy traffic in our platform and to avoid any presumption/confusion. I should also note that we are running this platform on low-end VPSs with 512 RAM. For many, mysql-proxy is still NOT ready for production/prime-time. It’s simply not a mature product. However, for some it can be a good/better alternative depending on the requirements and what’s available.
    I’m curious to know how HAProxy is working out for you. In general (not knowing your requirements/setup) at 20k qps, hardware load-balancing (like F5) would be a safer option in my humble opinion.

    March 8, 2013 at 7:11 am
  • Masood Alam Reply

    yes, its for dedicated server 32 cores intel xenon, 196gb ram , buffer pool over 100gb in use, database size is over 500gb, and we have 15 servers now moved to xtradb cluster with each server having virident tachion 1.4 TB drives with flash raid 1.
    per server getting around 20k queries, peak time is around 30k queries per sec. altogether we have over 200k qps..

    So that was our environment..


    March 8, 2013 at 7:43 am
  • Masood Alam Reply

    yes, sorry using multiple f5’s for load balancing, actually it is discussed above already…..

    March 8, 2013 at 11:18 am
  • sathio Reply

    @hotbollah we use it in production and it’s wonderful if you have any specific questions let me know.
    (it handles perfectly thousands of qps on our MMM setup)

    March 13, 2013 at 9:45 am
  • Masood Alam Reply


    I wonder someone can recommend mysql-proxy when MYSQL (the makers of it) are telling you it is in alpha and not to use in production. It is not a great matter when you are getting thousands of queries, it is when you crash while getting thousand of queries per second and then your customer will ask the very same question, is mysql-proxy safe…?


    March 13, 2013 at 11:23 am
  • sathio Reply

    sorry if I wasn’t clear, I’m no longer using mysql-proxy, but mysqlnd_ms.

    March 14, 2013 at 9:42 am

Leave a Reply