Skip to main content

What is a database proxy?

·529 words·3 mins
DevOps Databases
Alejandro Duarte
Author
Alejandro Duarte
Alejandro Duarte is a Software Engineer, published author, and award winner. He currently works for MariaDB plc as a Developer Relations Engineer. Starting his coding journey at 13 with BASIC on a rudimentary black screen, Alejandro quickly transitioned to C, C++, and Java during his academic years at the National University of Colombia. Relocating first to the UK and then to Finland, Alejandro deepened his involvement in the open-source community. He’s a recognized figure in Java circles, credited with articles and videos amassing millions of views, and presentations at international events.

A proxy is a server software, typically installed in a separate machine, that forwards requests to servers on behalf of clients. When the proxy is in the local network of the client, it’s called simply proxy or forward proxy. If it is in the local network of the server, it’s called a reverse proxy. Proxies can add functionality to a system without having to change or even notify clients and servers.

What is a database proxy?
#

A database proxy is a type of reverse proxy tailored to databases. It takes requests from clients like web applications and forwards them to a database server using configurations that are specific to databases. An intelligent database proxy understands SQL and is able to make decisions on how to treat requests based on configurable rules. This understanding of the database protocols and languages allows database proxies to add functionality, mainly in four categories:

  • High availability. For example, automatic failover and transaction replay.
  • Scalability: The ability to transparently add or remove nodes in the database cluster without having to reconfigure or restart an application.
  • Integrations: For example, import or export data from and to Kafka topics or connect apps developed with a NoSQL database connector to SQL backends.
  • Security: For example, establishing query y result limits or automatic data masking.

MariaDB MaxScale intelligent database proxy

What are the advantages of database proxies?
#

The main advantage of using a database proxy is that it isolates the database topology from application configuration:

  • Developers don’t need to know about replicas or cluster nodes
  • It all looks like a standalone database instance to developers
  • DBAs can add or remove replicas and cluster nodes when needed
  • No need for developers to implement things like load balancing or data masking
  • Fewer code results in faster development, less maintenance, and greater reliability
  • DBAs can make changes without interrupting applications
  • They are transparent and hidden from application configuration
  • Completely hide failures
  • No need for developers to create new connections or retry transactions
  • No need for DBAs to perform a manual failover after being alerted

What are the disadvantages of database proxies?
#

When evaluating database proxies, you should consider the following:

  • A database proxy is a new element in the infrastructure
  • It requires configuration (always use a database proxy that offers good configuration options)
  • It can increment costs
  • Licenses or cloud usage (check licenses before picking a database proxy)

If your application connects to a single database instance and doesn’t require things such as high availability or scaling, a database proxy introduces more complexity than needed. However, if you need other features such as automatic data masking or transparent integrations with Kafka or NoSQL protocols, a database proxy is useful even if there’s no need for high availability and scaling.

How to use a database proxy?
#

A database proxy is installed on a machine and configured to monitor the database nodes and handle requests according to specific requirements. For example, MariaDB MaxScale can be used for transparent read-write splitting where SQL inserts, deletes, and updates are routed to primary (or master) nodes, and SQL selects to replica nodes enabling zero-downtime scale (both up and down). You can see this in action in this video:

Enjoyed this post? I can help your team implement similar solutions—contact me to learn more.

Related

MariaDB replication demo
·261 words·2 mins
DevOps Databases
Database replication is a process that copies data from one database (primary) to another (replica).
Building a Kubernetes cluster on Raspberry Pi (with automation)
·652 words·4 mins
DevOps
Some months ago, I was lucky enough to get a bunch of Raspberry Pi minicomputers from MariaDB Corporation.
What is JPA?
·345 words·2 mins
Programming Databases
JPA stands for Jakarta Persistence API (previously, Java Persistence API). It’s an API specification for database connectivity in Java applications.