mysql r w splitting_MySQL Proxy RW Splitting

本文探讨了MySQL复制实现读写分离的概念,指出其能有效扩展读取负载。然而,目前存在一些问题,如连接状态管理、只跟踪特定SQL语句、连接池管理以及安全认证等挑战。作者提出在MySQL Proxy内部自动化处理这一过程的Proof of Concept,并列出了已知的限制和待解决的问题,表明该特性尚不适合生产环境使用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Read/Write Splitting

The MySQL Replication allows to scale out read-load.

To use it nicely your application has to be aware of reading data from slaves and writing data to the master. Read/Write splitting wants to automate that process inside the MySQL Proxy.

In

a Proof of Concept of that idea is presented.

Limitations

There are a few problems left before that feature is in a acceptable state:

Connection State

Up to now the example script only knows about:

transactions go to the master

auto-increment INSERTs will wait for the next SELECT INSERT_ID()

SELECT SQL_CALC_FOUND_ROWS will wait for the next SELECT FOUND_ROWS()

LOCK TABLES

Currently most of the other commands that change the connection state are ignored.

SET NAMES utf8

CREATE TEMPORARY TABLE ...

SET @a = 1; SELECT @a;

Stored Procedures

SHOW SESSION STATUS

The rw-splitting.lua script has to be extended to track those statements and either:

replicate the state to the new connection (SET NAMES utf8)

don't switch the connection

Connection Pool

The MySQL Proxy maintains a connection pool if the scripting layer disconnects the backend from the client connection:

proxy.connection.backend_ndx = 0

The backend connection can be taken from the pool by other client connections afterwards.

For the R/W-Splitting you need 2 open connections for each client connection:

one to the master

one to the slave

As the authentication protocol never transmits the real password nor anything we can use to authenticate against another server, we need a internal storage of credentials to open connections to the backend-servers when we are short of connections in the pool.

That's currently missing.

Bugs

Yes, we know that RW-Splitting is not for production use yet, it is a Proof of Concept. To keep track of the known issues:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值