承接 small/doctrine-dbal-swoole-pdo-driver 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

small/doctrine-dbal-swoole-pdo-driver

Composer 安装命令:

composer require small/doctrine-dbal-swoole-pdo-driver

包简介

README 文档

README

OpenSwoole and Doctrine

Connection issue

The doctrinal issue is that coroutines use the same connection.

On a service with many connections, users end up waiting for SQL queries to finish one after the other.

Solutions

1) Create a connection for each request

This solution has been adopted in the package diego-ninja/swoole-mysql-doctrine-driver : diego-ninja/swoole-mysql-doctrine-driver

Two issues arise:

  • We are in a long-time process, and connections consume RAM.
  • Under heavy load, database server may block due to a large number of open connections.

2) Use a connection pool

The connection pool is a class replacing native driver that store and reuse connections. You can define the max number of concurent connections, determined by the size of your database server.

The process is simple :

For example : we use a pool of 10 connections.

If there is a free connection, we get the connection. Send the connection and release the connection.

If there is no free connections, we sleep a short time and retry.

small/swoole-pdo-doctrine-driver

This package use small/swoole-patterns abstract pool's class.

Here is an example to configure it with symfony :

doctrine:
    dbal:
        driver: Small\SwooleDbalPdo
        url: '%env(resolve:DATABASE_URL)%'

The source code is available on https://git.small-project.dev/lib/small-swoole-doctine-dbal-pdo

The composer package is available on https://packagist.org/packages/small/small-swoole-doctine-dbal-pdo

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-04-30