Skip to content
WordPress

What is MaxScale? A proxy for MariaDB and MySQL databases

Team Host.it 5 min read

Content

We've already talked about how MaxScale allows us to have high-performance databases and build flexible architectures. Now we will go into detail about the features and functionality of this database proxy.

A proxy is a server that acts as an intermediary in a connection: it receives requests from a client and redirects them to other servers that are the recipients of the requests. In other words, a proxy is a means of rerouting a connection between two computers so that they are not connected directly. A proxy works like a switchboard operator: it receives the call from whoever wants to call and forwards it to the desired extension.

MaxScale can be inserted transparently between the application and the MySQL server, exactly like a web proxy does between our browser (e.g. Firefox) and the site we are trying to visit. Thanks to a proxy it is possible to have:

Redundancy: using more than one database behind the proxy. A single server does not provide reliability and high availability in the event of a machine downtime.

Reduction in infrastructure costs: because generally two small servers are less expensive than a single high-performance server.

We will see two types of database proxy servers:

Transport layer proxies like HAProxy

Application layer proxies like MaxScale

HAProxy: an efficient, fast and functional proxy To date, the most used proxy in the MySQL environment is the HAProxy which works at a lower level (level 4: transport). HAproxy knows nothing about MySQL and is only concerned with balancing connections between multiple servers. It is very fast, light and efficient, however this balancing is done without knowing what it is sorting. This makes the system less efficient since one server may receive many heavy requests, while other servers may be unloaded. So HAProxy is not the winning choice in all cases.

MaxScale: a proxy that can do amazing things

MaxScale works at a higher level (level 7: application), by monitoring the servers it is able to understand what is happening within the infrastructure. Knowing the MySQL protocol, you can intervene by manipulating the traffic between client and server. Here are some of its main features:

Database query filtering

Routing management: Routing requests to one or more database servers

Edit queries on the fly before they reach the database

Possibility to hide the internal structure of the infrastructure leaving a single access point.

High reliability and scalability of the system

Ability to move a database from the local server to an external server without changing the application configuration

Automatically divides the writes on the MASTER server and the reads on one or more SLAVE databases.

MaxScale can provide load balancing of connections without the need to use applications or CMS that provide this functionality. This means that CMS like Joomla! or WordPress can benefit from using Master/Slave replication to make their site scalable.

Features of MaxScale The strong point of MaxScale is certainly its modularity which allows considerable freedom by adapting to many use cases. MaxScale is:

Modular: a system of modules defines its functionality

Extendable: it is possible to apply multiple filters even in cascade

Flexible: Modules and filters can be added dynamically

Below are the 5 modules that make up the heart of MaxScale:

Protocol: gives the possibility of using multiple protocols e.g. MySQL client, http, telnet

Authentication: the authentication system allows clients to access MaxScale using the credentials present on the Backend servers

Monitor - Reads system state configuration directly from backend servers

Router: Routes connections to one or more backend databases

Filter and logging: filters allow you to modify queries or write a log file with all requests and responses received.

1. Connection Protocol Clients connect to MaxScale instead of MySQL database without knowing the difference. They can use the same connection libraries used until now: e.g. MySQL client or MariaDB client.

2. Authentication MaxScale does not have an authentication system or user database. The same users present in the backend databases, loaded when the application starts, are used.

3. Monitor It is used to understand at any time the status of all backend databases connected to MaxScale. In this way it is possible to know which is the Master server and how many Slaves are correctly replicating the data. The monitor can be used to control a Galera Cluster.

4. Router Directs traffic from the client to the servers using a specific rule:

Connection routing: normal router for connecting to a database

Read/Write Split router: divides the write requests on the MASTER and the read requests on one of the connected SLAVES

5. Filters and query logs Among the most powerful tools made available by MaxScale there are certainly the filters that allow you to carry out advanced operations on queries without changing the behavior of the application:

Processing SQL queries and results

Using a simple regex

By analyzing, modifying or rejecting queries

By placing multiple filters in cascade

During our testing for MariaDB we understood that this product can help us scale our Joomla Cloud Hosting platform, maintaining backward compatibility with all versions of Joomla! and use the most up-to-date database servers at the same time. Version 1.0.4-stable was released a few weeks ago. Although the project is still young, I would recommend it to anyone who has a very large site and wants to have the ability to scale the database performance without changing the CMS code.

In the next article we will see how we created a development environment using Docker and Vagrant. If you are using MaxScale for one of your projects leave a comment to share this experience with us.

WordPress hosting

Hosting optimized for WordPress

SSD, backups, SSL and Application Manager: publish and update your site with Italian-speaking support.

From the blog

WordPress

WordPress 7.0 e l’AI

Cosa cambia per le web agency

Sicurezza

Patch a caldo, sito acceso

CVE kernel senza riavvii a raffica

From the archive

WordPress

Host Academy on the National Youth Card, 58% discount for young people up to 35 years old

WordPress

New features and releases - September 2022