Comments (4)
异步 Server 在执行完 onMessage 回调之后协程就会退出,而 Coroutine Server 不同,同一个客户端连接总会有一个协程,因此 250 个客户端就会有 250 协程,需要占用内存。
from swoole-src.
异步 Server 在执行完 onMessage 回调之后协程就会退出,而 Coroutine Server 不同,同一个客户端连接总会有一个协程,因此 250 个客户端就会有 250 协程,需要占用内存。
250个协程不至于造成3倍的资源消耗吧
from swoole-src.
3倍只是巧合
from swoole-src.
并不是纠结于这个“3”,而是对于其中的消耗点想要更详细的了解
run(function () {
$i = 250;
while ($i--) {
Coroutine::create(function () {
while (true) {
sleep(1);
}
});
}
// 内存使用
$memory = memory_get_usage();
$memory = $memory / 1024;
$memory = $memory / 1024;
$memory = round($memory, 2);
echo '当前内存使用:' . $memory . 'MB' . PHP_EOL;
$channel = new Channel(1);
$channel->pop();
});
当前内存使用:3.84MB
而上面的实验结果差异为:54-18=36MB,不止协程占用的内存消耗
from swoole-src.
Related Issues (20)
- `proc_open` failed because `Pty` is not supported in Swoole
- hyperf启动报错,worker进程异常退出 HOT 6
- Suggestion: Better core logging
- 切换业务前出现了一些异常 HOT 2
- Question: Coroutine\Http\Server Settings HOT 7
- WARNING Server::check_worker_exit_status(): worker(pid=337, id=2) abnormal exit, status=0, signal=11 HOT 3
- Context::parse_multipart_data() (ERRNO 9010): parse multipart body failed, HOT 1
- mac 通过swoole-cli运行项目无法导出数据 HOT 5
- Server::check_worker_exit_status(): worker(pid=294, id=0) abnormal exit HOT 5
- hyperf:执行pgsql查询,worker进程退出
- php官方docker的alpine包无法开启sqlite
- swoole 5.1.2编译安装提示error: ‘gettid’ was not declared in this scope; did you mean ‘getuid’ HOT 7
- Using package_length_func HOT 9
- Coroutine\Socket客户端绑定地址失败 HOT 5
- php.ini enable swoole extension composer error : segmentation fault php composer HOT 3
- postgresql在服务端主动断开连接时swoole无法捕获异常 HOT 10
- 5.1.2 Context::parse_multipart_data 导致abort 进程退出 HOT 11
- A bug occurred in Swoole-v5.1.1, please report it. HOT 19
- Websocket connection failed. SSL related Issue? HOT 1
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 swoole-src.