MySQLProxyCache
MySQLProxyCache
MySQLProxyCache
MySQLProxyCache

MySQLProxyCache

par Carles Mateo

English Linux Linux Databases Cache MySQL Performance

mysqlproxycache — Make MySQL answer faster, without changing your application

mysqlproxycache 1.1, by Carles Mateo

mysqlproxycache is a caching proxy written in Go that sits between your application and your MySQL server.
Your application connects to it exactly as it connects to MySQL.
Results of repeated queries come straight from memory.
Your MySQL server only does the work that actually needs a database.

This is the new release written in Go, evolved from the previous MySqlProxyCache written in Java in 2010.

Why mysqlproxycache


No code changes

Change the host and port in your connection settings, and that's all. No new
library, no cache keys to design, and no "remember to clear the cache"
calls scattered through your code. PHP, Java, Python, Node.js, Go, the
`mysql` command line: anything that talks to MySQL talks to mysqlproxycache.

Huge gains from JOINs and ORDER BY SELECTs

With mysqlproxycache after the first query, the next ones in memory are super-fast.
This is specially impressive on heavy queries like joins, that are repeated in your websites and CMS.
Imagine a Join query that takes 100 seconds to be processed by MySQL. Image 20 requests at the same time. Those 20 requests to your MySQL server would make it tremble for few minutes, however mysqlproxycache makes only one request to the MySQL server. 
After the data is cached, next requests take milliseconds are server by mysqlproxycache in less than 1 second, while MySQL would still need close to 100 seconds per each request.
For repeated heavy queries, like for consolidating accounting, that may take one hour to be processed by MySQL server, after the first one, mysqlproxycache will serve the next ones in les than 1 second (if there were no queries updating the data).

In our battery of tests, which consists in 10 queries to MySQL and to mysqlproxy cache, speeds of mysqlproxycache serving the data x3,000 times faster than MySQL are normal.

Huge speed increase in CMS page serving

WordPress, Drupal, PrestaShop, Ibexa... all can benefit from the super speed of the cached queries.
Scenarios were there are few writes, and many reads, like web pages, posts, content tree... are the most benefited from mysqlproxycache.

Less load on MySQL

Most applications ask the same questions to the database over and over: product pages, menus,
settings, user profiles, countries, translations. mysqlproxycache answers repeated questions from
memory, so they never reach MySQL. That frees MySQL's CPU and disk for the
queries that need it, and can delay or avoid a costly hardware upgrade and save your business from servers crashing and from degraded service due to slow speed of MySQL.

Answers from memory

A cached result goes back to your application directly from RAM. MySQL doesn't parse, plan or execute the query again, and no disk is read.

Never serves outdated data after a change

Caching is easy. Caching correctly is the hard part, and it's where
mysqlproxycache puts most of its work:

  • Automatic invalidation. When an `INSERT`, `UPDATE`, `DELETE`, `TRUNCATE` or schema change touches a table, every cached result that used that table is dropped immediately, before the next read can see it.
  • Understands your database structure. It knows about views, foreign keys with cascades and triggers. A change to one table also drops the cached results of the tables and views that depend on it.
  • Transaction-aware. Inside a transaction, your application always talks to MySQL directly. When the transaction commits, the affected tables are cleared from the cache again.
  • Safe against race conditions. A query that was running while a write happened is never stored, so old data can't slip back into the cache.

Knows what must never be cached

mysqlproxycache reads every SQL statement with a full MySQL parser. Results
that could change on their own, such as queries using `NOW()`, `RAND()` or any
other function, stored procedures, variables, or locking reads (`FOR UPDATE`),
are always sent to MySQL. Writes are never cached.

Stampede protection

When a popular cached result expires, or a traffic spike arrives, hundreds of
users can ask for the same data at the same moment. Without protection, all
of those queries hit MySQL at once. That is the classic "cache stampede" that
brings databases down at the worst possible time.

mysqlproxycache sends only the first one to MySQL. The others wait a few
moments and get the same answer from memory. In our tests, 200 identical
queries arriving at the same moment reached MySQL exactly once
.

Keeps answering when MySQL is busy or restarting

Results that are already cached are served from memory, even while MySQL is
under heavy load or briefly unavailable. At boot, mysqlproxycache waits for
MySQL to come up instead of failing.

Fewer connections to MySQL

mysqlproxycache keeps a pool of ready, authenticated connections to MySQL and
opens more only when needed. Clients whose queries are all answered from the
cache don't use a MySQL connection at all.

Predictable memory use

You choose the maximum memory. mysqlproxycache stays within it and releases
the oldest cached results first when it needs room. To protect your server,
it refuses to start with a limit above 95% of the machine's RAM.

Uses all your CPU cores

Built in Go, mysqlproxycache serves many clients in parallel on every core of
your server. You can cap the number of cores it uses, so it shares the machine
nicely with MySQL or your application.

Simple to run

- One static binary with no dependencies, built for Ubuntu 26.04 LTS.
- Install in one command; it runs as a hardened systemd service under its
  own unprivileged user.
- One small, commented configuration file.
- Clear logs and periodic statistics: hit ratio, memory used, connections
  and stampede activity.
- A `-check` command validates your configuration and your MySQL login before
  you go live.

Features at a glance


  • Drop-in MySQL protocol proxy | ✔ |
  • Automatic cache invalidation on writes | ✔ |
  • Aware of views, cascading foreign keys and triggers | ✔ |
  • Transaction-safe | ✔ |
  • Never caches functions, procedures or writes | ✔ |
  • Stampede protection with configurable wait time | ✔ |
  • Optional expiry time (TTL) for cached results | ✔ |
  • Memory limit with oldest-first eviction | ✔ |
  • Connection pool to MySQL | ✔ |
  • Multi-core | ✔ |
  • `caching_sha2_password` and `mysql_native_password` logins | ✔ |
  • Prepared statements, multi-statements, `LOAD DATA LOCAL` passed through | ✔ |
  • systemd service with security hardening | ✔ |
  • Statistics in the logs | ✔ |

Compatibility


- Server OS: Ubuntu 26.04 LTS, x86_64. We focus on this platform only. Should work well in other platforms, but it is certified for Ubuntu 26.04 LTS only.
- Database: MySQL 8.0 (tested with MySQL 8.0.34 Community Server).
- Clients: any MySQL driver or tool using the standard MySQL protocol.

Is it right for you?


mysqlproxycache works best when:

- your application reads much more than it writes;
- the same queries are repeated by many users or many page views;
- the writes to your data go through your application, and so through
  mysqlproxycache.

Good to know before you buy:

- If other programs write to MySQL directly, bypassing the proxy, set a short
  expiry time (TTL) so cached results refresh on their own.
- Connections between your application and mysqlproxycache are not encrypted
  (no TLS). Run it on a private network or on the same server as your
  application.
- Queries that contain functions, such as `COUNT(*)` or `NOW()`, are always
  sent to MySQL and never cached.

What you get


- The `mysqlproxycache` program for Ubuntu 26.04 LTS (x86_64)
- Installer and uninstaller
- Ready-to-use systemd service
- Commented configuration file
- Complete user guide: installation, every setting, troubleshooting
- License agreement and third-party notices

Get started in five minutes


```bash
unzip mysqlproxycache-1.1-linux-amd64.zip
cd mysqlproxycache-1.1-linux-amd64
sudo ./install.sh
sudo nano /etc/mysqlproxycache/mysqlproxycache.conf
sudo systemctl start mysqlproxycache
```

Then point your application at port 3307 instead of 3306 (the port can be configured).

License is per server and grants right to receive any new releases for a year.

*mysqlproxycache is developed by Carles Mateo.
Pièces jointes
  • MySqlProxyCache v.1.1 for Ubuntu 26.04 LTS 64 bits installer (4.4 MB)
  • SHA256 Hash checksum file for mysqlproxycache-1.1-linux-amd64.zip (102 B)
€3000.00 €1500.00 Offre valable jusqu'au 2026-10-10 23:59
Dernière mise à jour: 2026-10-09