4zhvml8 发表于 2024-7-10 18:03:10

PHP的福音!支持都数据库连接,高性能的开源MySQL连接池


    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">针对</span><span style="color: black;">非常多</span> PHP <span style="color: black;">研发</span>者<span style="color: black;">来讲</span>,连接数据库<span style="color: black;">始终</span>是个让人头疼的问题,<span style="color: black;">那样</span>今天 Gitee 为<span style="color: black;">大众</span>介绍的<span style="color: black;">便是</span>一款一个基于 MySQL 协议,Swoole <span style="color: black;">研发</span>的MySQL数据库连接池。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">项目名<span style="color: black;">叫作</span>:SMProxy</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">项目作者:louislivi</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">开源许可协议:MIT</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">项目<span style="color: black;">位置</span>:<a style="color: black;"><span style="color: black;">https://</span><span style="color: black;">gitee.com/lo</span></a>uislivi/smp<span style="color: black;">roxy</span></p>
    <h3 style="color: black; text-align: left; margin-bottom: 10px;">设计初衷</h3>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">PHP <span style="color: black;">无</span>连接池,<span style="color: black;">因此</span>高并发时数据库会<span style="color: black;">显现</span>连接打满的<span style="color: black;">状况</span>,Mycat 等数据库中间件会<span style="color: black;">显现</span>部分 SQL <span style="color: black;">没</span>法<span style="color: black;">运用</span>,例如不支持批量添加等,<span style="color: black;">况且</span>过于臃肿。 <span style="color: black;">因此</span>就自己编写了这个仅支持连接池和读写分离的轻量级中间件,<span style="color: black;">运用</span> Swoole 协程调度 HandshakeV10 协议转发使程序更加稳定,<span style="color: black;">不消</span>像 Mycat <span style="color: black;">同样</span>解析所有 SQL 包体,<span style="color: black;">增多</span><span style="color: black;">繁杂</span>度。</p>
    <h3 style="color: black; text-align: left; margin-bottom: 10px;">项目原理</h3>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">将数据库连接<span style="color: black;">做为</span>对象存储在内存中,当用户<span style="color: black;">必须</span><span style="color: black;">拜访</span>数据库时,首次会<span style="color: black;">创立</span>连接,后面并非<span style="color: black;">创立</span>一个新的连接,而是从连接池中取出一个已<span style="color: black;">创立</span>的空闲连接对象。 <span style="color: black;">运用</span>完毕后,用户<span style="color: black;">亦</span>并非将连接关闭,而是将连接放回连接池中,以供下一个请求<span style="color: black;">拜访</span><span style="color: black;">运用</span>。而连接的<span style="color: black;">创立</span>、断开都由连接池<span style="color: black;">自己</span>来管理。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">同期</span>,还<span style="color: black;">能够</span><span style="color: black;">经过</span>设置连接池的参数来<span style="color: black;">掌控</span>连接池中的初始连接数、连接的上下限数以及<span style="color: black;">每一个</span>连接的最大<span style="color: black;">运用</span>次数、最大空闲时间等等。 <span style="color: black;">亦</span><span style="color: black;">能够</span><span style="color: black;">经过</span>其<span style="color: black;">自己</span>的管理机制来<span style="color: black;">监测</span>数据库连接的数量、<span style="color: black;">运用</span><span style="color: black;">状况</span>等。超出最大连接数会采用协程挂起,等到有连接关闭再恢复协程继续操作。</p>
    <h3 style="color: black; text-align: left; margin-bottom: 10px;">特性</h3>支持读写分离支持数据库连接池,能够有效<span style="color: black;">处理</span> PHP 带来的数据库连接瓶颈支持 SQL92 标准采用协程调度支持多个数据库连接,多个数据库,多个用户,灵活搭配遵守 MySQL 原生协议,跨语言,跨平台的通用中间件代理支持 MySQL 事务支持 HandshakeV10 协议版本完美兼容 MySQL5.5 - 8.0兼容各大框架,<span style="color: black;">没</span>缝<span style="color: black;">提高</span>性能<h3 style="color: black; text-align: left; margin-bottom: 10px;">性能测试</h3>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">介绍了这么多,<span style="color: black;">那样</span>这个项目的性能到底<span style="color: black;">怎样</span>呢?<span style="color: black;">咱们</span><span style="color: black;">能够</span>看一下作者进行的性能测试。</p>
    <h3 style="color: black; text-align: left; margin-bottom: 10px;">没用框架的 PHP 7.2.6</h3>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">未<span style="color: black;">运用</span>连接池:</p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://pic3.zhimg.com/80/v2-a5feb8a8c8319703eb63e9d8f44be5d6_720w.webp" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">运用</span>连接池:</p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://pic4.zhimg.com/80/v2-7fd296f62fa20aa2cb5cc6521ff3b62f_720w.webp" style="width: 50%; margin-bottom: 20px;"></div>
    <h3 style="color: black; text-align: left; margin-bottom: 10px;">ThinkPHP 5.0</h3>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">未<span style="color: black;">运用</span>连接池:</p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://pic1.zhimg.com/80/v2-d875da7d47e352dd308adfcc6f5c989c_720w.webp" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">运用</span>连接池:</p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://pic3.zhimg.com/80/v2-def46d8086302d111af10e3e05f56c0a_720w.webp" style="width: 50%; margin-bottom: 20px;"></div>
    <h3 style="color: black; text-align: left; margin-bottom: 10px;">Laravel 5.7</h3>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">未<span style="color: black;">运用</span>连接池:</p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://pic3.zhimg.com/80/v2-d7e5005d5ef4bc41192989fb0c02f552_720w.webp" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">运用</span>连接池:</p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://pic1.zhimg.com/80/v2-7a53721f77824a9bb62bda911d2d4890_720w.webp" style="width: 50%; margin-bottom: 20px;"></div>
    <h3 style="color: black; text-align: left; margin-bottom: 10px;">MySQL</h3>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">未<span style="color: black;">运用</span>连接池:</p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://pic3.zhimg.com/80/v2-8f0f37e9332b7d77541c5e8977ff084a_720w.webp" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">运用</span>连接池:</p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://pic3.zhimg.com/80/v2-f04e9033d6fd821f7a3c9d1919293ac6_720w.webp" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">当然,作者<span style="color: black;">供给</span>的测试结果只是一个参考,各位<span style="color: black;">研发</span>者在亲自<span style="color: black;">运用</span>的时候,<span style="color: black;">因为</span>数据量,网络环境,数据库配置的<span style="color: black;">区别</span>,以<span style="color: black;">实质</span>压测的结果为准。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">倘若</span>你想<span style="color: black;">认识</span> SMProxy <span style="color: black;">详细</span>的运行和配置<span style="color: black;">办法</span>,<span style="color: black;">那样</span>就点击后面的链接前往项目主页<span style="color: black;">瞧瞧</span>吧,记得给它一个 Star 哦:<a style="color: black;"><span style="color: black;">https://</span><span style="color: black;">g</span></a>itee.com/louislivi/smp<span style="color: black;">roxy</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">倘若</span>你正在寻找 PHP 的开源项目学习,Gitee 上<span style="color: black;">亦</span>有<span style="color: black;">非常多</span>:<a style="color: black;"><span style="color: black;">https://</span><span style="color: black;">gitee.com/explore/all?</span><span style="color: black;">lang=PHP</span></a></p>




星☆雨 发表于 2024-8-24 16:08:43

楼主听话,多发外链好处多,快到碗里来!外链论坛 http://www.fok120.com/

b1gc8v 发表于 2024-10-10 10:55:25

楼主的文章深得我心,表示由衷的感谢!

nqkk58 发表于 2024-11-14 23:29:28

外链发布社区 http://www.fok120.com/
页: [1]
查看完整版本: PHP的福音!支持都数据库连接,高性能的开源MySQL连接池