PHPackages                             louislivi/smproxy - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. louislivi/smproxy

ActiveProject[Database &amp; ORM](/categories/database)

louislivi/smproxy
=================

A MySQL database connection pool based on MySQL protocol and Swoole.

v1.3.1(6y ago)1.8k418259[15 issues](https://github.com/louislivi/SMProxy/issues)[1 PRs](https://github.com/louislivi/SMProxy/pulls)MITPHPPHP ^7.0

Since Nov 22Pushed 3y ago56 watchersCompare

[ Source](https://github.com/louislivi/SMProxy)[ Packagist](https://packagist.org/packages/louislivi/smproxy)[ Docs](https://github.com/louislivi/smproxy)[ RSS](/packages/louislivi-smproxy/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (5)Versions (20)Used By (0)

中文 | [English](./README-EN.md)

```
  /$$$$$$  /$$      /$$ /$$$$$$$
 /$$__  $$| $$$    /$$$| $$__  $$
| $$  \__/| $$$$  /$$$$| $$  \ $$ /$$$$$$   /$$$$$$  /$$   /$$ /$$   /$$
|  $$$$$$ | $$ $$/$$ $$| $$$$$$$//$$__  $$ /$$__  $$|  $$ /$$/| $$  | $$
 \____  $$| $$  $$$| $$| $$____/| $$  \__/| $$  \ $$ \  $$$$/ | $$  | $$
 /$$  \ $$| $$\  $ | $$| $$     | $$      | $$  | $$  >$$  $$ | $$  | $$
|  $$$$$$/| $$ \/  | $$| $$     | $$      |  $$$$$$/ /$$/\  $$|  $$$$$$$
 \______/ |__/     |__/|__/     |__/       \______/ |__/  \__/ \____  $$
                                                               /$$  | $$
                                                              |  $$$$$$/
                                                               \______/

```

[SMProxy](https://smproxy.louislivi.com)
========================================

[](#smproxy)

[![release](https://camo.githubusercontent.com/2cbb4739d2b9f67c3da965307651b20c749dc8b6a90609a75528fee3a71922ff/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6c6f7569736c6976692f534d50726f78792e7376673f7374796c653d706f706f75742d737175617265)](https://github.com/louislivi/SMProxy/releases)[![forks](https://camo.githubusercontent.com/01bcfb507f2dbde771eb4f5643f329370f0c99d1f13e4a769763ec13e60c43e3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f6c6f7569736c6976692f534d50726f78792e7376673f7374796c653d706f706f75742d737175617265)](https://github.com/louislivi/SMProxy/network/members)[![stars](https://camo.githubusercontent.com/53a9eaf7694fa13184f9e2e65f87d57c6071775f1bbaa3d7d7a60ca4bcb61b68/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6c6f7569736c6976692f534d50726f78792e7376673f7374796c653d706f706f75742d737175617265)](https://github.com/louislivi/SMProxy/stargazers)[![Build Status](https://camo.githubusercontent.com/067898648fdaba15504f8c0649a0520ac133ccdf6185979bad877900009d58f7/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f636f6d2f6c6f7569736c6976692f534d50726f78792e7376673f7374796c653d706f706f75742d737175617265)](https://travis-ci.com/louislivi/SMProxy)[![Gitter](https://camo.githubusercontent.com/4bd60fb26edfeadd2ba3fb6b4b00d3b5e7c6e374ba4f0f73a1020f8fb15a068b/68747470733a2f2f696d672e736869656c64732e696f2f6769747465722f726f6f6d2f6c6f7569736c6976692f534d70726f78792e7376673f7374796c653d706f706f75742d737175617265)](https://gitter.im/louislivi/SMproxy)[![license](https://camo.githubusercontent.com/509282e98ecafa6ebc002076372cd8c605ee093fcd2cdab142f97d129bc1a2d9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6c6f7569736c6976692f534d50726f78792e7376673f7374796c653d706f706f75742d737175617265)](https://github.com/louislivi/SMProxy/blob/master/LICENSE)[![SMProxy](https://camo.githubusercontent.com/4a5bad5cd25b7d72ea73f05ca57c30bfcf00cd0ae5423f0d1b5095dfd0e07d7a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f534d50726f78792d2546302539462539322539372d70696e6b2e7376673f7374796c653d706f706f75742d737175617265)](https://github.com/louislivi/SMProxy)[![Backers on Open Collective](https://camo.githubusercontent.com/07ef57a16bd9cad04eb771799cf92715e68503dc95c4c7f5ce99e0001d134329/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f534d50726f78792f6261636b6572732f62616467652e7376673f7374796c653d706f706f75742d737175617265)](#backers)[![Sponsors on Open Collective](https://camo.githubusercontent.com/97cf8d406ea674adb795e02449cbc5f9099207badeba6d4c7a5c6f89c0b462f3/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f534d50726f78792f73706f6e736f72732f62616467652e7376673f7374796c653d706f706f75742d737175617265)](#sponsors)

Swoole MySQL Proxy
------------------

[](#swoole-mysql-proxy)

一个基于 MySQL 协议，Swoole 开发的MySQL数据库连接池。

原理
--

[](#原理)

将数据库连接作为对象存储在内存中，当用户需要访问数据库时，首次会建立连接，后面并非建立一个新的连接，而是从连接池中取出一个已建立的空闲连接对象。 使用完毕后，用户也并非将连接关闭，而是将连接放回连接池中，以供下一个请求访问使用。而连接的建立、断开都由连接池自身来管理。

同时，还可以通过设置连接池的参数来控制连接池中的初始连接数、连接的上下限数以及每个连接的最大使用次数、最大空闲时间等等。 也可以通过其自身的管理机制来监视数据库连接的数量、使用情况等。超出最大连接数会采用协程挂起，等到有连接关闭再恢复协程继续操作。

特性
--

[](#特性)

- 支持读写分离
- 支持数据库连接池，能够有效解决 PHP 带来的数据库连接瓶颈
- 支持 SQL92 标准
- 采用协程调度
- 支持多个数据库连接，多个数据库，多个用户，灵活搭配
- 遵守 MySQL 原生协议，跨语言，跨平台的通用中间件代理
- 支持 MySQL 事务
- 支持 HandshakeV10 协议版本
- 完美兼容 MySQL5.5 - 8.0
- 兼容各大框架，无缝提升性能

设计初衷
----

[](#设计初衷)

PHP 没有连接池，所以高并发时数据库会出现连接打满的情况，Mycat 等数据库中间件会出现部分 SQL 无法使用，例如不支持批量添加等，而且过于臃肿。 所以就自己编写了这个仅支持连接池和读写分离的轻量级中间件，使用 Swoole 协程调度 HandshakeV10 协议转发使程序更加稳定，不用像 Mycat 一样解析所有 SQL 包体，增加复杂度。

开发与讨论
-----

[](#开发与讨论)

- 文档：
- QQ群：722124111
- 欢迎各类 Issue 和 Pull Request。

贡献者列表
-----

[](#贡献者列表)

因为有你们，SMProxy 才能走到现在。

[![](https://camo.githubusercontent.com/0b62cad3ad2fa1c0678b5fe29a197a02c5ddaa95f0d73403092f47298b64c624/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f534d50726f78792f636f6e7472696275746f72732e7376673f77696474683d38393026627574746f6e3d66616c7365)](https://github.com/louislivi/SMProxy/graphs/contributors)

Backers
-------

[](#backers)

Thank you to all our backers! 🙏 \[[Become a backer](https://opencollective.com/SMProxy#backer)\]

[![](https://camo.githubusercontent.com/4916e7a8ce14c5c3ba630a9ffee803cb5b065271fa8724cb9dad7615c69af550/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f534d50726f78792f6261636b6572732e7376673f77696474683d383930)](https://opencollective.com/SMProxy#backers)

Sponsors
--------

[](#sponsors)

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. \[[Become a sponsor](https://opencollective.com/SMProxy#sponsor)\]

[![](https://camo.githubusercontent.com/14cc9ef84d51762c275ad51ed579da53cdc42f54f09312fdf7de0c6b556e873c/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f534d50726f78792f73706f6e736f722f302f6176617461722e737667)](https://opencollective.com/SMProxy/sponsor/0/website)[![](https://camo.githubusercontent.com/ba1286f5f0e459dbe2103620f48c9a03c371d6247c65dc14dad4b7854ed90908/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f534d50726f78792f73706f6e736f722f312f6176617461722e737667)](https://opencollective.com/SMProxy/sponsor/1/website)[![](https://camo.githubusercontent.com/3745e9d60e6649407040e0e5cee33b1e34fce28c137205abe7da5207af6c5f16/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f534d50726f78792f73706f6e736f722f322f6176617461722e737667)](https://opencollective.com/SMProxy/sponsor/2/website)[![](https://camo.githubusercontent.com/88d19d052375b101dc5391abe042c388259e93dde59cfbee223d6e6e4d63abe5/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f534d50726f78792f73706f6e736f722f332f6176617461722e737667)](https://opencollective.com/SMProxy/sponsor/3/website)[![](https://camo.githubusercontent.com/f53798bd2d89880b9cb4db68b86447d6ea56e745294b390f712b47aff8ee0c6f/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f534d50726f78792f73706f6e736f722f342f6176617461722e737667)](https://opencollective.com/SMProxy/sponsor/4/website)[![](https://camo.githubusercontent.com/556e26150b694b7df0c7efcc1c5344f795bad520e56197324d4c2c1f7bc9372e/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f534d50726f78792f73706f6e736f722f352f6176617461722e737667)](https://opencollective.com/SMProxy/sponsor/5/website)[![](https://camo.githubusercontent.com/27531f91fe002f29ae5d6b09fba2bff07b1a0d0bdf4b2ac3b8c85c740e6061e9/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f534d50726f78792f73706f6e736f722f362f6176617461722e737667)](https://opencollective.com/SMProxy/sponsor/6/website)[![](https://camo.githubusercontent.com/fed76f916cc7870768e8d5f56b181e9b6b808324720bb969fa4bd72fb2a2e79a/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f534d50726f78792f73706f6e736f722f372f6176617461722e737667)](https://opencollective.com/SMProxy/sponsor/7/website)[![](https://camo.githubusercontent.com/029c8f990056e1d5c8c80607aeecc649165003ef2fc974fe539e272a82eedf40/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f534d50726f78792f73706f6e736f722f382f6176617461722e737667)](https://opencollective.com/SMProxy/sponsor/8/website)[![](https://camo.githubusercontent.com/c049e4db48057e256f215059f6dc1494f608f1f2740591a14b66f41263e23a7d/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f534d50726f78792f73706f6e736f722f392f6176617461722e737667)](https://opencollective.com/SMProxy/sponsor/9/website)

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity40

Moderate usage in the ecosystem

Community28

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 74.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~24 days

Recently: every ~88 days

Total

18

Last Release

2311d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b46f8f0b389a141530ae076826ccb9d90046994d3de9d32ef7de255818bec468?d=identicon)[louislivi](/maintainers/louislivi)

---

Top Contributors

[![louislivi](https://avatars.githubusercontent.com/u/23403807?v=4)](https://github.com/louislivi "louislivi (306 commits)")[![wi1dcard](https://avatars.githubusercontent.com/u/25447002?v=4)](https://github.com/wi1dcard "wi1dcard (97 commits)")[![fghrsh](https://avatars.githubusercontent.com/u/19676990?v=4)](https://github.com/fghrsh "fghrsh (2 commits)")[![dingzihu](https://avatars.githubusercontent.com/u/33281842?v=4)](https://github.com/dingzihu "dingzihu (2 commits)")[![monkeywithacupcake](https://avatars.githubusercontent.com/u/7316730?v=4)](https://github.com/monkeywithacupcake "monkeywithacupcake (1 commits)")[![no-serve-people](https://avatars.githubusercontent.com/u/25813184?v=4)](https://github.com/no-serve-people "no-serve-people (1 commits)")[![txznothing](https://avatars.githubusercontent.com/u/28583321?v=4)](https://github.com/txznothing "txznothing (1 commits)")

---

Tags

composerconnection-poolconnectionscoroutinesmycatmysqlphppoolproxysmproxyswooleswoole-mysql-proxydatabasemysqlConnectionswoolepoolsmproxy

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/louislivi-smproxy/health.svg)

```
[![Health](https://phpackages.com/badges/louislivi-smproxy/health.svg)](https://phpackages.com/packages/louislivi-smproxy)
```

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k578.4M5.6k](/packages/doctrine-dbal)[cycle/database

DBAL, schema introspection, migration and pagination

64690.9k31](/packages/cycle-database)[tommyknocker/pdo-database-class

Framework-agnostic PHP database library with unified API for MySQL, MariaDB, PostgreSQL, SQLite, MSSQL, and Oracle. Query Builder, caching, sharding, window functions, CTEs, JSON, migrations, ActiveRecord, CLI tools, AI-powered analysis. Zero external dependencies.

845.7k](/packages/tommyknocker-pdo-database-class)[mix/database

Simple database for use in multiple execution environments, with support for FPM, Swoole, Workerman, and optional pools

1515.3k9](/packages/mix-database)[chillerlan/php-database

An extensible database wrapper and query builder.

431.2k2](/packages/chillerlan-php-database)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
