Comments (5)
你的协程数量开太多了,超过了当前脚本的最大申请内存限制,要在当前脚本设定协程的数量。
\Swoole\Coroutine::set([ 'max_coroutine' => 1000, ]);
并且在启动协程的地方添加休息时间,防止系统过载:
$coroutineStat = \Swoole\Coroutine::stats(); if ($coroutineStat['coroutine_num'] >= 100) { \Swoole\Coroutine::sleep(1); }
希望能够交流下,我近几天,也为这个问题困扰。我不知道这是不是一个好的解决方案,期望有大神可以回复下。
from saber.
go(function () use ($host, $port, $poolSize, $queueKey) { $pool = new DotCloud\RedisPool($host, $port, $poolSize); while (true) { $redis = $pool->get(); if ($redis->lLen($queueKey) > 0) { $data = $redis->rPop($queueKey); if (empty($data)) { $pool->put($redis); continue; } // ...... // redis 里取出数据[ ['uri'=> ''], ['uri'=> ''] ],使用requests并发请求 $responses = Swlib\SaberGM::requests($urls); // ...... } $pool->put($redis); } });
# php --ri swoole swoole swoole support => enabled Version => 4.2.9 Author => Swoole Group[email: [email protected]] coroutine => enabled debug => enabled trace_log => enabled epoll => enabled eventfd => enabled signalfd => enabled cpu_affinity => enabled spinlock => enabled rwlock => enabled sockets => enabled openssl => OpenSSL 1.0.2k-fips 26 Jan 2017 http2 => 1.31.1 pcre => enabled zlib => enabled mutex_timedlock => enabled pthread_barrier => enabled futex => enabled mysqlnd => enabled async_redis => enabled Directive => Local Value => Master Value swoole.enable_coroutine => On => On swoole.aio_thread_num => 2 => 2 swoole.display_errors => On => On swoole.use_namespace => On => On swoole.use_shortname => On => On swoole.fast_serialize => Off => Off swoole.unixsock_buffer_size => 8388608 => 8388608# cat /var/log/messages | grep swoole Dec 3 11:06:01 izwz99ilp8qh025s8ak1y9z kernel: php[12589]: segfault at 8 ip 00007fdd0544409b sp 00007fdd04f9fed0 error 4 in swoole.so[7fdd053c9000+132000] Dec 3 13:40:32 izwz99ilp8qh025s8ak1y9z kernel: php[16214]: segfault at 8 ip 00007fd42a84409b sp 00007fd42a39fed0 error 4 in swoole.so[7fd42a7c9000+132000] # uname -a Linux izwz99ilp8qh025s8ak1y9z 3.10.0-693.2.2.el7.x86_64 #1 SMP Tue Sep 12 22:26:13 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux # php -v PHP 7.1.24 (cli) (built: Nov 7 2018 18:08:20) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.1.24, Copyright (c) 1999-2018, by Zend Technologies # gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper Target: x86_64-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux Thread model: posix gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)
你的协程数量开太多了,超过了当前脚本的最大申请内存限制,要在当前脚本设定协程的数量。
`
\Swoole\Coroutine::set([ 'max_coroutine' => 1000, ]);
并且在启动协程的地方添加休息时间,防止系统过载:
$coroutineStat = \Swoole\Coroutine::stats();
if ($coroutineStat['coroutine_num'] >= 100) { \Swoole\Coroutine::sleep(1); }
`
希望能够交流下,我近几天,也为这个问题困扰。我不知道这是不是一个好的解决方案,期望有大神可以回复下。
from saber.
@roverliang #2175 帖子也发这里了,你可以看看,目前想跟踪这个问题还跟踪不到,不跟踪的时候就出现了
from saber.
@roverliang 应该不是你说的这个问题了,我这个数字一直都是1
array(3) {
["stack_size"]=>
int(8192)
["coroutine_num"]=>
int(1)
["coroutine_peak_num"]=>
int(1)
}
from saber.
@roverliang 不知道你说的问题是什么, 协程不会过载
from saber.
Related Issues (20)
- WARNING swSSL_connect: SSL_connect(fd=4) failed. Error: error:1414D172:SSL routines:tls12_check_peer_sigalg:wrong signature type[1|370]
- 模拟登陆没有返回302状态
- 怎么获取全部响应报文? HOT 1
- 关于Http客户端download时请求头Range
- Connect timeout! the server is not listening on the port or the network is missing! HOT 4
- Cookie parseHeader方法解析cookie需要增加容错 HOT 1
- JA3指纹反爬破解,需要开放ssl_ciphers参数配置 HOT 3
- 相同的response header会覆盖 HOT 1
- 请问 WebSocket 支持 proxy 吗?
- SaberGM::download中文名文件下载失败 HOT 1
- You can't enqueue a waiting request when using the max concurrency control!
- 如何禁止url自动转码? HOT 2
- 获取请求内容乱码 HOT 3
- 报错:Call to a member function push() on null HOT 1
- 连接wss协议时,报了一个很奇怪的错Websocket upgrade failed by [Connection timed out] HOT 1
- Warning "Deprecated: Implicit conversion from float to int loses precision"
- HTTP -1 Unknown: Connect timeout! the server is not listening on the port or the network is missing HOT 1
- 请教一下关于并发请求的问题.
- saber对url中的","的处理与其他http客户端有不一样的地方
- ssl_crypto_method
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from saber.