14.6.6. MySQL Proxy FAQ

Questions

  • 15.6.6.1: In load balancing, how can I separate reads from writes?

  • 15.6.6.2: How do I use a socket with MySQL Proxy? Proxy change logs mention that support for UNIX sockets has been added.

  • 15.6.6.3: Can I use MySQL Proxy with all versions of MySQL?

  • 15.6.6.4: Can I run MySQL Proxy as a daemon?

  • 15.6.6.5: Will the proxy road map involve moving popular features from Lua to C? (For example, Read/Write splitting.)

  • 15.6.6.6: Do proxy applications run on a separate server? If not, what is the overhead incurred by Proxy on the DB server side?

  • 15.6.6.7: With load balancing, what happens to transactions? Are all queries sent to the same server?

  • 15.6.6.8: We have looked at using MySQL Proxy but we are concerned about the alpha status. When do you think the proxy will be considered production ready?

  • 15.6.6.9: Is it possible to use MySQL Proxy with updating a Lucene index (or Solr) by making TCP calls to that server to update?

  • 15.6.6.10: Is the system context switch expensive, how much overhead does the Lua script add?

  • 15.6.6.11: How much latency does a proxy add to a connection?

  • 15.6.6.12: Do you have to make one large script and call it at proxy startup, can I change scripts without stopping and restarting (interrupting) the proxy?

  • 15.6.6.13: If MySQL Proxy has to live on same machine as MySQL, are there any tuning considerations to ensure both perform optimally?

  • 15.6.6.14: Can MySQL Proxy be used on slaves and intercept binary log messages?

  • 15.6.6.15: I currently use SQL Relay for efficient connection pooling with a number of Apache processes connecting to a MySQL server. Can MySQL Proxy currently accomplish this? My goal is to minimize connection latency while keeping temporary tables available.

  • 15.6.6.16: Are these reserved function names (for example, error_result()) that get automatically called?

  • 15.6.6.17: As the script is re-read by MySQL Proxy, does it cache this or is it looking at the file system with each request?

  • 15.6.6.18: Given that there is a connect_server() function, can a Lua script link up with multiple servers?

  • 15.6.6.19: Is the MySQL Proxy an API?

  • 15.6.6.20: The global namespace variable example with quotas does not persist after a reboot, is that correct?

  • 15.6.6.21: Can MySQL Proxy handle SSL connections?

  • 15.6.6.22: Could MySQL Proxy be used to capture passwords?

  • 15.6.6.23: Are there tools for isolating problems? How can someone figure out whether a problem is in the client, the database, or the proxy?

  • 15.6.6.24: Can you explain the status of your work with memcached and MySQL Proxy?

  • 15.6.6.25: Is MySQL Proxy similar to what is provided by Java connection pools?

  • 15.6.6.26: So authentication with connection pooling has to be done at every connection? What is the authentication latency?

  • 15.6.6.27: If you have multiple databases on the same box, can you use proxy to connect to databases on default port 3306?

  • 15.6.6.28: What about caching the authorization information so clients connecting are given back-end connections that were established with identical authorization information, thus saving a few more round trips?

  • 15.6.6.29: Is there any big web site using MySQL Proxy? For what purpose and what transaction rate have they achieved?

  • 15.6.6.30: How does MySQL Proxy compare to DBSlayer?

  • 15.6.6.31: I tried using MySQL Proxy without any Lua script to try a round-robin type load balancing. In this case, if the first database in the list is down, MySQL Proxy would not connect the client to the second database in the list.

  • 15.6.6.32: Is it “safe” to use LuaSocket with proxy scripts?

  • 15.6.6.33: How different is MySQL Proxy from DBCP (Database connection pooling) for Apache in terms of connection pooling?

  • 15.6.6.34: MySQL Proxy can handle about 5000 connections, what is the limit on a MySQL server?

  • 15.6.6.35: Would the Java-only connection pooling solution work for multiple web servers? With this, I would assume that you can pool across many web servers at once?

  • 15.6.6.36: Can you dynamically reconfigure the pool of MySQL servers that MySQL Proxy will use for load balancing?

  • 15.6.6.37: In the quick poll, I see "Load Balancer: read-write splitting" as an option, so would it be correct to say that there are no scripts written for Proxy yet to do this?

Questions and Answers

15.6.6.1: In load balancing, how can I separate reads from writes?

There is no automatic separation of queries that perform reads or writes to the different backend servers. However, you can specify to mysql-proxy that one or more of the “backend” MySQL servers are read only.

shell> mysql-proxy \
--proxy-backend-addresses=10.0.1.2:3306 \
--proxy-read-only-backend-addresses=10.0.1.3:3306 &

15.6.6.2: How do I use a socket with MySQL Proxy? Proxy change logs mention that support for UNIX sockets has been added.

Specify the path to the socket:

--proxy-backend-addresses=/path/to/socket

15.6.6.3: Can I use MySQL Proxy with all versions of MySQL?

MySQL Proxy is designed to work with MySQL 5.0 or higher, and supports the MySQL network protocol for 5.0 and higher.

15.6.6.4: Can I run MySQL Proxy as a daemon?

Use the --daemon option. To keep track of the process ID, the daemon can be started with the --pid-file=file option to save the PID to a known file name. On version 0.5.x, the Proxy cannot be started natively as a daemon.

15.6.6.5: Will the proxy road map involve moving popular features from Lua to C? (For example, Read/Write splitting.)

We will keep the high-level parts in the Lua layer to be able to adjust to special situations without a rebuild. Read/Write splitting sometimes needs external knowledge that may only be available by the DBA.

15.6.6.6: Do proxy applications run on a separate server? If not, what is the overhead incurred by Proxy on the DB server side?

You can run the proxy on the application server, on its own box, or on the DB-server depending on the use case.

15.6.6.7: With load balancing, what happens to transactions? Are all queries sent to the same server?

Without any special customization the whole connection is sent to the same server. That keeps the whole connection state intact.

15.6.6.8: We have looked at using MySQL Proxy but we are concerned about the alpha status. When do you think the proxy will be considered production ready?

We are on the road to the next feature release: 0.9.0. It will improve the performance quite a bit. After that we may be able to enter the beta phase.

15.6.6.9: Is it possible to use MySQL Proxy with updating a Lucene index (or Solr) by making TCP calls to that server to update?

Yes, but it is not advised for now.

15.6.6.10: Is the system context switch expensive, how much overhead does the Lua script add?

Lua is fast and the overhead should be small enough for most applications. The raw packet overhead is around 400 microseconds.

15.6.6.11: How much latency does a proxy add to a connection?

In the range of 400 microseconds per request.

15.6.6.12: Do you have to make one large script and call it at proxy startup, can I change scripts without stopping and restarting (interrupting) the proxy?

You can just change the script and the proxy will reload it when a client connects.

15.6.6.13: If MySQL Proxy has to live on same machine as MySQL, are there any tuning considerations to ensure both perform optimally?

MySQL Proxy can live on any box: application, database, or its own box. MySQL Proxy uses comparatively little CPU or RAM, with negligible additional requirements or overhead.

15.6.6.14: Can MySQL Proxy be used on slaves and intercept binary log messages?

We are working on that. See http://jan.kneschke.de/2008/5/30/mysql-proxy-rbr-to-sbr-decoding for an example.

15.6.6.15: I currently use SQL Relay for efficient connection pooling with a number of Apache processes connecting to a MySQL server. Can MySQL Proxy currently accomplish this? My goal is to minimize connection latency while keeping temporary tables available.

Yes.

15.6.6.16: Are these reserved function names (for example, error_result()) that get automatically called?

Only functions and values starting with proxy.* are provided by the proxy. All others are user provided.

15.6.6.17: As the script is re-read by MySQL Proxy, does it cache this or is it looking at the file system with each request?

It looks for the script at client-connect and reads it if it has changed, otherwise it uses the cached version.

15.6.6.18: Given that there is a connect_server() function, can a Lua script link up with multiple servers?

MySQL Proxy provides some tutorials in the source package; one is examples/tutorial-keepalive.lua.

15.6.6.19: Is the MySQL Proxy an API?

No, MySQL Proxy is an application that forwards packets from a client to a server using the MySQL network protocol. The MySQL Proxy provides a API allowing you to change its behavior.

15.6.6.20: The global namespace variable example with quotas does not persist after a reboot, is that correct?

Yes. If you restart the proxy, you lose the results, unless you save them in a file.

15.6.6.21: Can MySQL Proxy handle SSL connections?

No, being the man-in-the-middle, Proxy cannot handle encrypted sessions because it cannot share the SSL information.

15.6.6.22: Could MySQL Proxy be used to capture passwords?

The MySQL network protocol does not allow passwords to be sent in cleartext, all you could capture is the encrypted version.

15.6.6.23: Are there tools for isolating problems? How can someone figure out whether a problem is in the client, the database, or the proxy?

You can set a debug script in the proxy, which is an exceptionally good tool for this purpose. You can see very clearly which component is causing the problem, if you set the right breakpoints.

15.6.6.24: Can you explain the status of your work with memcached and MySQL Proxy?

There are some ideas to integrate proxy and memcache a bit, but no code yet.

15.6.6.25: Is MySQL Proxy similar to what is provided by Java connection pools?

Yes and no. Java connection pools are specific to Java applications, MySQL Proxy works with any client API that talks the MySQL network protocol. Also, connection pools do not provide any functionality for intelligently examining the network packets and modifying the contents.

15.6.6.26: So authentication with connection pooling has to be done at every connection? What is the authentication latency?

You can skip the round-trip and use the connection as it was added to the pool. As long as the application cleans up the temporary tables it used. The overhead is (as always) around 400 microseconds.

15.6.6.27: If you have multiple databases on the same box, can you use proxy to connect to databases on default port 3306?

Yes, MySQL Proxy can listen on any port, provided that none of the MySQL servers are listening on the same port.

15.6.6.28: What about caching the authorization information so clients connecting are given back-end connections that were established with identical authorization information, thus saving a few more round trips?

There is an --proxy-pool-no-change-user option that provides this functionality.

15.6.6.29: Is there any big web site using MySQL Proxy? For what purpose and what transaction rate have they achieved?

Yes, gaiaonline. They have tested MySQL Proxy and seen it handle 2400 queries per second through the proxy.

15.6.6.30: How does MySQL Proxy compare to DBSlayer?

DBSlayer is a REST->MySQL tool, MySQL Proxy is transparent to your application. No change to the application is needed.

15.6.6.31: I tried using MySQL Proxy without any Lua script to try a round-robin type load balancing. In this case, if the first database in the list is down, MySQL Proxy would not connect the client to the second database in the list.

This issue is fixed in version 0.7.0.

15.6.6.32: Is it “safe” to use LuaSocket with proxy scripts?

You can, but it is not advised because it may block.

15.6.6.33: How different is MySQL Proxy from DBCP (Database connection pooling) for Apache in terms of connection pooling?

Connection Pooling is just one use case of the MySQL Proxy. You can use it for a lot more and it works in cases where you cannot use DBCP (for example, if you do not have Java).

15.6.6.34: MySQL Proxy can handle about 5000 connections, what is the limit on a MySQL server?

The server limit is given by the value of the max_connections system variable. The default value is version dependent.

15.6.6.35: Would the Java-only connection pooling solution work for multiple web servers? With this, I would assume that you can pool across many web servers at once?

Yes. But you can also start one proxy on each application server to get a similar behavior as you have it already.

15.6.6.36: Can you dynamically reconfigure the pool of MySQL servers that MySQL Proxy will use for load balancing?

Not yet, it is on the list. We are working on a administration interface for that purpose.

15.6.6.37: In the quick poll, I see "Load Balancer: read-write splitting" as an option, so would it be correct to say that there are no scripts written for Proxy yet to do this?

There is a proof of concept script for that included. But its far from perfect and may not work for you yet.

Copyright © 2010-2024 Platon Technologies, s.r.o.           Home | Man pages | tLDP | Documents | Utilities | About
Design by styleshout