zoukankan      html  css  js  c++  java
  • ubuntu20部署php-swoole开发环境

    第1步:安装依赖

    add-apt-repository ppa:ondrej/php
    apt install php-dev

    第2步:编译安卓swoole

    wget https://codeload.github.com/swoole/swoole-src/tar.gz/v4.5.2

    然后tar zxvf 之....

    cd swoole-src-4.5.2

    phpize
    ./configure
    make
    make install

    第3步:写入配置文件

    echo 'extension=swoole.so' > /etc/php/7.4/cli/conf.d/20-swoole.ini

    第4步:将下面内容保存成swoole.php并运行php swoole.php测试

    <?php
    //高性能HTTP服务器
    $http = new SwooleHttpServer("0.0.0.0", 9501);
    $http->on("start", function ($server) {
        echo "Swoole http server is started at http://127.0.0.1:9501
    ";
    });
    $http->on("request", function ($request, $response) {
        $response->header("Content-Type", "text/plain");
        $response->end("Hello World
    ");
    });
    $http->start();

    第5步:模拟1000个并发进行压力测试

    ab -n 100000 -c 1000 http://127.0.0.1:9501/

    结果Requests per second: 8651.06 [#/sec] (mean)

    This is ApacheBench, Version 2.3 <$Revision: 1843412 $>

    Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
    Licensed to The Apache Software Foundation, http://www.apache.org/

    Benchmarking 127.0.0.1 (be patient)
    Completed 10000 requests
    Completed 20000 requests
    Completed 30000 requests
    Completed 40000 requests
    Completed 50000 requests
    Completed 60000 requests
    Completed 70000 requests
    Completed 80000 requests
    Completed 90000 requests
    Completed 100000 requests
    Finished 100000 requests


    Server Software: swoole-http-server
    Server Hostname: 127.0.0.1
    Server Port: 9501

    Document Path: /
    Document Length: 12 bytes

    Concurrency Level: 1000
    Time taken for tests: 11.434 seconds
    Complete requests: 100000
    Failed requests: 0
    Total transferred: 16100000 bytes
    HTML transferred: 1200000 bytes
    Requests per second: 8746.07 [#/sec] (mean)
    Time per request: 114.337 [ms] (mean)
    Time per request: 0.114 [ms] (mean, across all concurrent requests)
    Transfer rate: 1375.11 [Kbytes/sec] received

    Connection Times (ms)
    min mean[+/-sd] median max
    Connect: 0 47 6.9 47 65
    Processing: 13 67 10.9 67 112
    Waiting: 0 50 10.7 51 98
    Total: 53 114 8.3 115 145

    Percentage of the requests served within a certain time (ms)
    50% 115
    66% 118
    75% 120
    80% 121
    90% 124
    95% 126
    98% 129
    99% 131
    100% 145 (longest request)

  • 相关阅读:
    eclipse maven POM 第一行提示异常Could not initialize class org.apache.maven.plugin.war.util.WebappStructureSerializer
    Tomcat搭建HTTP文件下载服务器
    Hui datetimepicker 插件不显示左右箭头问题
    【Python】拷贝&列表
    【Python】Python赋值引用、浅拷贝、深拷贝
    【Python】列表的复制
    【Python】电脑安装了多个版本Python,如何切换;
    【Python】定义类、创建类实例
    【Python】白名单方式净化
    c++ 对外提供头文件的模式
  • 原文地址:https://www.cnblogs.com/xiangxisheng/p/13301283.html
Copyright © 2011-2022 走看看