The router in mysql is an open source lightweight middleware between the application layer and the DB layer. The router can forward the request analysis of the front-end application to the back-end DB server for processing, thereby achieving DB load balancing.
What is MySQL Router?
(Recommended tutorial: mysql video tutorial)
MySQL Router is an open source lightweight middleware between the application layer and the DB layer , it can forward the request analysis of the front-end application to the back-end DB server for processing, thereby achieving DB load balancing. It can be said that it is a replacement for the previous MySQL Proxy. We can find its source code on Github. Similar tools include 360’s Atlas, Meituan-Dianping’s DBProxy, MyCat, etc.
MySQL Router Architecture
Using this architecture, the front-end application does not need to directly connect to the DB Server, but Just connecting to MySQL Router can easily expand the database cluster. Next, let's take a look at some of its other main functions.
Main functions
1. Automatic failover
Using MySQL Router to implement read-write separation, the front-end application layer does not It is necessary to connect directly to the underlying DB, but to connect to MySQL Router uniformly. MySQL Router is transparent to the front-end application layer, and we do not need to do any processing at the code layer. The application layer will use MySQL Router as a normal MySQL instance. If the underlying DB Master fails, it will automatically use the Backup node to replace it, which is very convenient.
2. DB load balancing
MySQL middleware distributes requests to the underlying database according to certain rules through a connection pool-like method, thereby realizing DB reading and writing. Separation and high availability.
The above is the detailed content of What is router in mysql. For more information, please follow other related articles on the PHP Chinese website!