Month: 6 月 2021

wrk压力测试

2021年6月30日 未分类

wrk是一款简单的HTTP压测工具,托管在Github上,https://github.com/wg/wrk.
wrk 的一个很好的特性就是能用很少的线程压出很大的并发量. 原因是它使用了一些操作系统特定的高性能 io 机制, 比如 select, epoll, kqueue 等.

git clone https://github.com/wg/wrk.git
cd wrk make
cp wrk /usr/local/bin

测试

wrk -t4 -c100 -d30s http://www.lenmot.com  

 

swoole不能通过添加php.ini扩展方式添加到PHP扩展中

2021年6月29日 PHP

Manually enabling Swoole via php.ini

On most systems Swoole can be enabled by directly editing your

php.ini

configuration file, you will want to add

extension=swoole

to the end of the file and then Swoole should be enabled.

Enabling Swoole via phpenmod

Some Linux distributions like Debian or Ubuntu use the PHP

mods-available

to load PHP extensions, in this case you can use

phpenmod

to enable Swoole.

 

一般系统 都可以通过添加扩展到php.ini的方式添加swoole支持,但我用的debian10+php7.4不支持,报如下错
 

PHP Warning: PHP Startup: Unable to load dynamic library 'swoole' (tried: /usr/lib/php/20190902/swoole (/usr/lib/php/20190902/swoole: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/swoole.so (/usr/lib/php/20190902/swoole.so: undefined symbol: php_json_exception_ce)) in Unknown on line 0

 

只能通过

 phpenmod 方式添加

#!/bin/bash

# Create a Swoole extension PHP ini file, letting PHP know which modules to load
$ sudo bash -c "cat > /etc/php/<PHP_VERSION>/mods-available/swoole.ini << EOF
; Configuration for Swoole
; priority=25
extension=swoole
EOF"

# Enable the Swoole PHP extension only on CLI mode
$ sudo phpenmod -s cli swoole

# Optional: Enable Swoole for specific version of PHP CLI
$ sudo phpenmod -s cli -v 7.4 swoole

# Check if the Swoole extension has been enabled
$ php -m | grep swoole

 

You can also disable Swoole using

phpdismod

if you need to (this is not uninstalling, just turning Swoole off):

#!/bin/bash

# Turn off Swoole for CLI or a specific PHP install
sudo phpdismod -s cli swoole
sudo phpdismod -s cli -v 7.4 swoole

supervisor 启动 laravel-echo-server 关于设置 startsecs

2021年6月23日 laravel

laravel-echo-server启动需要比较长时间,如果通过supervisor来监控laravel-echo-server的运行状态,极有可能在默认情况下超时导致重新启动,很容易就死循环了。

startsecs默认是10,如果进程启动有可能超过10秒,则设置大一点吧

;[program:example]
;command=/bin/echo; the program (relative uses PATH, can take args)
;priority=999                ; the relative start priority (default 999)
;autostart=true              ; start at supervisord start (default: true)
;autorestart=true            ; retstart at unexpected quit (default: true)
;startsecs=10                ; number of secs prog must stay running (def. 10)
;startretries=3              ; max # of serial start failures (default 3)
;exitcodes=0,2               ; 'expected' exit codes for process (default 0,2)
;stopsignal=QUIT             ; signal used to kill process (default TERM)
;stopwaitsecs=10             ; max num secs to wait before SIGKILL (default 10)
;user=chrism                 ; setuid to this UNIX account to run the program
;log_stdout=true             ; if true, log program stdout (default true)
;log_stderr=true             ; if true, log program stderr (def false)
;logfile=/var/log/supervisor.log    ; child log path, use NONE for none; default AUTO
;logfile_maxbytes=1MB        ; max # logfile bytes b4 rotation (default 50MB)
;logfile_backups=10          ; # of logfile backups (default 10)
 

 

 

;command=/bin/echo;         supervisor启动时将要开启的进程。相对或绝对路径均可。若是相对路径则会从supervisord的$PATH变中查找。命令可带参数。
;priority=999                    指明进程启动和关闭的顺序。低优先级表明进程启动时较先启动关闭时较后关闭。高优先级表明进程启动时启动时较后启动关闭时较先关闭。
;autostart=true                  是否随supervisord启动而启动
;autorestart=true                进程意外退出后是否自动重启
;startsecs=10                    进程持续运行多久才认为是启动成功
;startretries=3                  重启失败的连续重试次数
;exitcodes=0,2                   若autostart设置为unexpected且监控的进程并非因为supervisord停止而退出,那么如果进程的退出码不在exitcode列表中supervisord将重启进程
;stopsignal=QUIT                 杀进程的信号
;stopwaitsecs=10                 向进程发出stopsignal后等待OS向supervisord返回SIGCHILD 的时间。若超时则supervisord将使用SIGKILL杀进程
 

composer self-update && composer clearcache

2021年6月23日 laravel

The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems)
    Unzip with unzip command failed, falling back to ZipArchive class

好好的composer install死活不成功,提示上面信息,

又是

composer self-update

又是清除vendor重新安装的,没有效果


一顿google后,发现composer clearcache解决