bear/swoole

Swoole 脚本用于 BEAR.Sunday

0.6.0 2022-12-29 20:05 UTC

This package is auto-updated.

Last update: 2024-09-13 10:39:08 UTC


README

此库为 BEAR.Sunday 应用程序提供对 Swoole 的支持。

🚀 安装

运行以下命令以安装此库:

composer require bear/swoole
composer require fastd/http 5.0.x-dev

🚀 入口脚本

将入口脚本文件放置在 bin/swoole.php,并包含 IP 地址和端口号。

<?php
require dirname(__DIR__) . '/autoload.php';
exit((require dirname(__DIR__) . '/vendor/bear/swoole/bootstrap.php')(
    'prod-hal-app',       // context
    'MyVendor\MyProject', // application name
    '127.0.0.1',          // IP
    8080                  // port
));

🚀 执行

您可以使用以下命令运行带有 Swoole 的 BEAR.Sunday 应用程序:

php bin/swoole.php

🚀 基准测试

在 MacBook Air M2 2022 上进行测试

  • PHP 8.2

基准测试工具: wrk

Apache 2.4

wrk http://127.0.0.1/

Running 10s test @ http://127.0.0.1/
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     2.94ms    1.63ms  45.60ms   95.46%
    Req/Sec     1.78k    85.91     1.94k    89.00%
  35369 requests in 10.00s, 6.99MB read
Requests/sec:   3535.29
Transfer/sec:    715.29KB

Swoole 5.0.1

wrk http://127.0.0.1:8080/

Running 10s test @ http://127.0.0.1:8080/
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    97.58us   26.76us   1.63ms   81.58%
    Req/Sec    49.89k     2.31k   51.06k    95.54%
  1002194 requests in 10.10s, 191.15MB read
Requests/sec:  99230.51
Transfer/sec:     18.93MB