ichynul/auto-process

1.0.5 2023-04-10 07:41 UTC

This package is auto-updated.

Last update: 2024-04-10 09:37:20 UTC


README

自动创建多个process对应多个端口,可使用apachenginx等做负载均衡。 实现原理:https://www.workerman.net/doc/webman/others/task.html

  • windows下webman不支持多进程,使用此插件帮你自动创建多个process + port,配合nginx、apache等环境增加并发能力。 相关问题 https://www.workerman.net/q/10247 https://www.workerman.net/q/10238

  • linux系统也可以用使用,如果你使用了nginx作为代理,那顺便使用nginx做一下负载均衡。

关于linux性能比较: linux上要在使用nginx时才有可比性,nginx+多process多端口与nginx+单端口去比较。 linux上使用的目的也不是非要比单端口的性能强,而是因为nginx毕竟是成熟的解决方案,在负载均衡方面有些可配置的选项,比如ip_hash、least_conn等。

我没做过linux对比测试,要用的自己测试一下再决定是否使用吧。。

安装

composer require ichynul/auto-process

使用

在配置文件config/server.php中调整默认端口进程数量count数量为1。(windows可忽略此步,linux必调,否则默认端口开启多进程,负载均衡配置要适当考量多一些权重。)

在配置文件config/plugin/auto/port/app.php中调整process_count数量。

例如8,那将会自动创建7不同的端口.

nginx 代理设置

和官方配置一样: https://www.workerman.net/doc/webman/others/nginx-proxy.htmlupstream webman添加多个server-port

upstream webman {
    server 127.0.0.1:8787;
	server 127.0.0.1:8788;
	server 127.0.0.1:8789;
	server 127.0.0.1:8790;
	server 127.0.0.1:8791;
	server 127.0.0.1:8792;
	server 127.0.0.1:8793;
	server 127.0.0.1:8794;
	#...更多
    keepalive 10240;
}
server {
	#...
}

Windows上使用nssm生成网站服务,开机自启,崩溃自启

https://www.workerman.net/a/1422

Windows集成环境推荐

upupw+kangle

效果图(可选)

启动后: 启动后 任务管理器显示: 任务管理器显示 杀死进程模拟程序异常终止: 杀死进程模拟程序异常终止

LICENSE

MIT