Exploring Top MySQL Middleware: Atlas, MySQL Router, Mycat, Cobar, and More
This article surveys several MySQL middleware solutions—including Atlas, MySQL Router, Mycat, Cobar, Amoeba, and client‑side sharding—detailing their architectures, key features, advantages, and practical recommendations for production use.
1. Introduction
MySQL is a ubiquitous database in internet companies; when performance issues arise, horizontal scaling via master‑slave replication improves read throughput, while sharding addresses write bottlenecks. This article focuses on MySQL data access middleware (DAL) implementations rather than high‑availability architectures.
2. Atlas
Atlas is a MySQL‑protocol data middleware developed by Qihoo 360. Built on MySQL‑Proxy 0.8.2, it fixes many bugs and adds features. It is widely used internally at 360 and by over 50 companies, handling tens of billions of read/write requests daily.
2.1. Atlas Overview
Atlas sits between applications and MySQL, acting as a client to the backend DB and as a server to the frontend application. It implements both MySQL client and server protocols and maintains a connection pool to reduce MySQL load.
Key functions include:
Read‑write separation
Slave load balancing
IP filtering
Automatic sharding
Graceful DBA‑controlled DB online/offline
Automatic removal of failed DB nodes
Advantages over official MySQL‑Proxy:
Core logic rewritten in C (Lua only for management)
Improved network and thread models
Real connection pool implementation
Optimized lock mechanism, delivering dozens‑fold performance gains
3. MySQL Router
Official MySQL Router is a lightweight proxy placed between client applications and DB servers. It detects, analyzes, and forwards queries, supporting read‑write separation, automatic failover, load balancing, and connection pooling.
3.1. Router Architecture
Router distinguishes read and write traffic by port: write queries go to the primary, while read‑only queries are round‑robin distributed among replicas.
3.2. Main Functions
Read‑write separation
Automatic primary‑replica failover
Load balancing
Connection pooling
4. Mycat
Mycat evolved from the open‑source Cobar project, rewriting the network module with NIO and enhancing buffer handling, aggregation, and join capabilities. Since version 1.4 it no longer depends on the original Cobar core.
4.1. Mycat Overview
Mycat is a high‑performance database middleware that supports SQL92, adheres to the native MySQL protocol, and works across languages, platforms, and databases.
4.2. Main Features
SQL92 compliance
Transparent MySQL protocol, cross‑language support
Heartbeat‑based automatic failover, read‑write separation, support for MySQL, Galera, Percona, MariaDB clusters
NIO‑based high‑concurrency handling
Automatic sharding, aggregation (SUM, COUNT, MAX, etc.)
Cross‑database joins, including multi‑table joins via CALTLET
Global tables and ER‑based sharding for efficient multi‑table queries
Multi‑tenant support
Weak XA distributed transactions
Global sequence numbers for primary‑key generation
Rich sharding rules and plugin architecture
Web and CLI monitoring
Support for Oracle, DB2, SQL Server, MongoDB, and other back‑ends via JDBC
Password encryption, service degradation, IP whitelist, SQL blacklist, injection protection
Table partitioning (since 1.6) and ZooKeeper‑managed clustering with online upgrade and scaling
5. Cobar
Cobar provides distributed MySQL services, acting as a transparent proxy that enables linear scaling of traditional databases.
5.1. Architecture
5.2. Status
Developed by Alibaba, Cobar has been stable for over three years, handling more than 3,000 MySQL schemas, processing over 50 billion SQL requests and terabytes of data daily. Development halted after 2013, and Mycat emerged as its successor.
6. Amoeba
Amoeba (released in 2008) is an open‑source MySQL front‑end proxy that provides load balancing, high availability, SQL filtering, read‑write separation, routing, and result merging across multiple databases.
6.1. Architecture
6.2. Status
The project is no longer maintained.
7. MySQL Proxy
MySQL Proxy sits between client and server, allowing monitoring, analysis, and modification of traffic via Lua scripts. It can implement load balancing, query filtering, and read‑write separation, though it is now deprecated in favor of MySQL Router.
8. Client‑Side Sharding
Client‑side sharding splits databases and tables within the application code, e.g., routing user IDs to different databases/tables based on the last digits of the UID. Advantages include no middleware overhead and fine‑grained control via code.
9. Conclusion
For production environments, the author recommends using Atlas or Mycat; client‑side sharding is suitable when strong development capability or DBA support exists. MySQL Router is still maturing, and other middleware that is no longer updated should be avoided unless legacy constraints require them.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
