Home  >  Q&A  >  body text

SMProxy, a MySQL database connection pool developed by Swoole based on the MySQL protocol.

SMProxy

Swoole MySQL Proxy

A MySQL database connection pool developed by Swoole based on the MySQL protocol.

Principle

Store the database connection as an object in the memory. When the user needs to access the database, the connection will be established for the first time. Later, instead of establishing a new connection, it will be taken out from the connection pool. An established idle connection object. After use, the user does not close the connection, but puts the connection back into the connection pool for the next request. The establishment and disconnection of connections are managed by the connection pool itself.

At the same time, you can also control the initial number of connections in the connection pool, the upper and lower limits of connections, the maximum number of uses of each connection, the maximum idle time, etc. by setting the parameters of the connection pool. It can also monitor the number, usage, etc. of database connections through its own management mechanism. If the maximum number of connections is exceeded, the coroutine will be suspended, and the coroutine will be resumed until a connection is closed to continue the operation.

Features

Supports read-write separation. Supports database connection pool, which can effectively solve the database connection bottleneck caused by PHP. Supports SQL92 standard and uses coroutine scheduling to support multiple database connections, multiple databases, and multiple databases. individual users, flexible combination and compliance with the MySQL native protocol, cross-language, cross-platform general middleware agent supports MySQL transactions supports HandshakeV10 protocol version is perfectly compatible with MySQL4.1 - 8.0 compatible with major frameworks, seamlessly improves performance

Design Original Intention

PHP does not have a connection pool, so the database will be full of connections when concurrency is high. Database middleware such as Mycat will cause some SQL to be unusable, such as batch addition is not supported, and it is too bloated. So I wrote this lightweight middleware that only supports connection pooling and read-write separation. Using Swoole coroutine scheduling and HandshakeV10 protocol forwarding makes the program more stable. There is no need to parse all SQL package bodies like Mycat, which increases complexity.

Development and Discussion

Documentation:https://smproxy.louislivi.com

If you are blocked, please visit:https:/ /smproxy.gitee.louislivi.com

QQ group: 722124111 All types of Issues and Pull Requests are welcome.

Contributor List


子山子山2114 days ago1334

reply all(0)I'll reply

No reply
  • Cancelreply