MySQL proxy server
I have spent some time thinking about and working on a project that went public on GitHub at the beginning of this year. That project is called MaxScale and is primarily a proxy server for MySQL/MariaDB databases, although it can be something much more than this. The obvious and often asked question is why do we need another proxy? I want to try to give you a flavor for what MaxScale is and why I think there is a need for a tool like MaxScale. The architecture of MaxScale makes it different from your average proxy
- MaxScale has awareness of the content it is shipping.
- As well as being aware of the content the proxy is shipping it is also aware of the configuration and state of the servers to which requests are proxied.
- It provides plugin modules that can be used to implement the routing logic, supported protocols, authentication methods, monitoring and filters.
- The implementation is a lightweight, event driven core executed by multiple threads, efficient multiplexing of multiple requests on a single thread allows the best use to be made of the available threads.
Why content awareness helps
MaxScale is able to look inside of the requests it is forwarding and use data gathered by viewing the request content to help it decide the best location to send the request. This means that it is possible to look at the SQL statements, determine the read or write scope of the statement, the database objects that are manipulated and the keys involved in the statement. Using all of this data MaxScale can then make very well educated decisions as to which is the best destination database server to handle the request.
As well as content awareness MaxScale is also aware of the dynamic configuration of the database servers. This means that it can take into account the current state of each server and the role it is currently assigned within a cluster of servers. In a typical Master/Slave replication scenario this could mean knowing which server is currently the writeable master and which are slaves. It is possible to take this even further and have MaxScale aware of any replication lag in the system on a per server, per schema or per table basis. The result is that MaxScale has the information to be able to make the best use possible of the database servers that are behind the proxy. This can all be done transparently to the client applications that simply attach to MaxScale as if it were a single instance of MySQL or MariaDB.