# 协程内存开销
新版本`4.0`使用了`C`栈+`PHP`栈的协程实现方案。`Server`程序每次请求的事件回调函数中会创建一个新协程,处理完成后协程退出。
在协程创建时需要创建一个全新的内存段作为`C`和`PHP`的栈,底层默认分配`2M(C)`虚拟内存+`8K(PHP)`内存(`PHP-7.2`或更高版本)。实际并不会分配这么内存,系统会根据在内存实际读写时发生缺页中断,再分配实际内存。
> 由于`PHP-7.1/7.0`未提供设置栈内存尺寸的接口,这些版本每个协程将申请`256K`的`PHP`内存
相比于异步回调程序,协程会增加一些内存管理的开销。有一定性能损耗。经过压测`QPS`依然可以达到较高的水平。
```shell
ab -c 100 -n 500000 -k http://127.0.0.1:9501/
This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
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 50000 requests
Completed 100000 requests
Completed 150000 requests
Completed 200000 requests
Completed 250000 requests
Completed 300000 requests
Completed 350000 requests
Completed 400000 requests
Completed 450000 requests
Completed 500000 requests
Finished 500000 requests
Server Software: swoole-http-server
Server Hostname: 127.0.0.1
Server Port: 9501
Document Path: /
Document Length: 24 bytes
Concurrency Level: 100
Time taken for tests: 3.528 seconds
Complete requests: 500000
Failed requests: 0
Keep-Alive requests: 500000
Total transferred: 132500000 bytes
HTML transferred: 12000000 bytes
Requests per second: 141738.54 [#/sec] (mean)
Time per request: 0.706 [ms] (mean)
Time per request: 0.007 [ms] (mean, across all concurrent requests)
Transfer rate: 36680.38 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 2
Processing: 0 1 0.9 0 7
Waiting: 0 1 0.9 0 7
Total: 0 1 0.9 0 7
WARNING: The median and mean for the processing time are not within a normal deviation
These results are probably not that reliable.
WARNING: The median and mean for the waiting time are not within a normal deviation
These results are probably not that reliable.
WARNING: The median and mean for the total time are not within a normal deviation
These results are probably not that reliable.
Percentage of the requests served within a certain time (ms)
50% 0
66% 0
75% 2
80% 2
90% 2
95% 3
98% 3
99% 3
100% 7 (longest request)
```
- 第一章 入门指引
- 1.1 环境依赖
- 1.2 编译安装
- 1.2.1 编译参数
- 1.2.2 常见错误
- 1.3 快速起步
- 1.3.1 创建TCP服务器
- 1.3.2 创建UDP服务器
- 1.3.3 创建Web服务器
- 1.3.4 创建WebSocket服务器
- 1.3.5 设置定时器
- 1.3.6 执行异步任务
- 1.3.7 创建同步TCP客户端
- 1.3.8 创建异步TCP客户端
- 1.3.9 网络通信协议设计
- 1.3.10 使用异步客户端
- 1.3.11 多进程共享数据
- 1.4 编程须知
- 1.4.1 sleep/usleep的影响
- 1.4.2 exit/die函数的影响
- 1.4.3 while循环的影响
- 1.4.4 stat缓存清理
- 1.4.5 mt_rand随机数
- 1.5 版本更新记录
- 1.5.1 4.2.2
- 1.5.2 4.2.1
- 1.5.3 4.2.0
- 1.5.4 4.1.2
- 1.5.5 4.1.1
- 1.5.6 4.1.0
- 1.5.7 4.0.4
- 1.5.8 4.0.3
- 1.5.9 4.0.2
- 1.5.10 4.0.1
- 1.5.11 4.0.0
- 1.6 向下不兼容改动
- 1.7 新特性使用
- 1.7.1 2.1.2 进程池模块的使用
- 1.7.2 1.9.24 调度支持 Stream 模式
- 1.7.3 1.9.24 异步客户端自动解析域名
- 1.7.4 1.9.17 支持异步安全重启特性
- 1.7.5 1.9.14 使用异步客户端超时机制
- 1.7.6 1.8.0 使用内置Http异步客户端
- 1.7.7 1.7.16 使用迭代器遍历Server所有连接
- 1.7.8 1.7.5 在Server中使用swoole_table
- 1.7.9 1.7.5 swoole_client支持sendfile接口
- 1.7.10 1.7.4 SSL隧道加密TCP-Server
- 1.7.11 1.7.4 task进程中使用毫秒定时器
- 1.7.12 1.7.3 固定包头+包体协议自动分包
- 1.7.13 1.7.3 onTask直接return取代finish函数
- 1.7.14 1.7.2 swoole_process多进程模块的使用
- 1.7.15 1.7.2 task进程使用消息队列
- 1.8 项目路线图
- 1.9 php.ini选项
- 1.10 内核参数调整
- 1.12 衍生开源项目
- 1.12.1 框架
- 1.12.2 工具
- 1.12.3 分布式
- 1.12.4 通信协议
- 1.13 用户与案例
- 1.13.1 物联网项目
- 1.13.2 网络游戏
- 1.13.3 腾讯(Tencent)
- 1.13.4 百度(Baidu.com)
- 1.13.5 阅文集团
- 1.13.6 BiliBili(哔哩哔哩)
- 1.13.7 车轮互联(chelun.com)
- 1.13.8 (捞月狗) 游戏社区
- 1.14 提交错误报告
- 1.15 常见问题
- 1.15.1 升级swoole版本的常见问题
- 1.15.2 生成可分发的二进制swoole版本
- 1.15.3 在phpinfo中有在php -m中没有
- 1.15.4 Connection refused是怎么回事
- 1.15.5 Resource temporarily unavailable [11]
- 1.15.6 Cannot assign requested address [99]
- 1.15.7 swoole与node.js相比有哪些优势
- 1.15.8 swoole与golang相比有哪些优势
- 1.15.9 pcre.h: No such file or directory
- 1.15.10 my_global.h: No such file or directory
- 1.15.11 undefined symbol: __sync_bool_compare_and_swap_4
- 1.15.12 学习Swoole需要掌握哪些基础知识
- 1.15.13 同步阻塞与异步非阻塞适用场景
- 1.15.14 PHP7环境下出现zend_mm_heap corrupted
- 1.15.15 swoole项目起源和名字由来
- 1.15.16 swFactoryProcess_finish (ERROR 1004): send %d byte failed, because session#%d is closed / swFactoryProcess_finish (ERROR 1005): connection[fd=%d] does not exists
- 第二章 Server
- 2.1 函数列表
- 2.1.1 swoole_server::__construct
- 2.1.2 swoole_server->set
- 2.1.3 swoole_server->on
- 2.1.4 swoole_server->addListener
- 2.1.5 swoole_server->addProcess
- 2.1.6 swoole_server->listen
- 2.1.7 swoole_server->start
- 2.1.8 swoole_server->reload
- 2.1.9 swoole_server->stop
- 2.1.10 swoole_server->shutdown
- 2.1.11 swoole_server->tick
- 2.1.12 swoole_server->after
- 2.1.13 swoole_server->defer
- 2.1.14 swoole_server->clearTimer
- 2.1.15 swoole_server->close
- 2.1.16 swoole_server->send
- 2.1.17 swoole_server->sendfile
- 2.1.18 swoole_server->sendto
- 2.1.19 swoole_server->sendwait
- 2.1.20 swoole_server->sendMessage
- 2.1.21 swoole_server->exist
- 2.1.22 swoole_server->pause
- 2.1.23 swoole_server->resume
- 2.1.24 swoole_server->getClientInfo
- 2.1.25 swoole_server->getClientList
- 2.1.26 swoole_server->bind
- 2.1.27 swoole_server->stats
- 2.1.28 swoole_server->task
- 2.1.29 swoole_server->taskwait
- 2.1.30 swoole_server->taskWaitMulti
- 2.1.31 swoole_server->taskCo
- 2.1.32 swoole_server->finish
- 2.1.33 swoole_server->heartbeat
- 2.1.34 swoole_server->getLastError
- 2.1.35 swoole_server->getSocket
- 2.1.36 swoole_server->protect
- 2.1.37 swoole_server->confirm
- 2.2 属性列表
- 2.2.1 swoole_server::$setting
- 2.2.2 swoole_server::$master_pid
- 2.2.3 swoole_server::$manager_pid
- 2.2.4 swoole_server::$worker_id
- 2.2.5 swoole_server::$worker_pid
- 2.2.6 swoole_server::$taskworker
- 2.2.7 swoole_server::$connections
- 2.2.8 swoole_server::$ports
- 2.3 配置选项
- 2.3.1 reactor_num
- 2.3.2 worker_num
- 2.3.3 max_request
- 2.3.4 max_conn (max_connection)
- 2.3.5 task_worker_num
- 2.3.6 task_ipc_mode
- 2.3.7 task_max_request
- 2.3.8 task_tmpdir
- 2.3.9 dispatch_mode
- 2.3.10 dispatch_func
- 2.3.11 message_queue_key
- 2.3.12 daemonize
- 2.3.13 backlog
- 2.3.14 log_file
- 2.3.15 log_level
- 2.3.16 heartbeat_check_interval
- 2.3.17 heartbeat_idle_time
- 2.3.18 open_eof_check
- 2.3.19 open_eof_split
- 2.3.20 package_eof
- 2.3.21 open_length_check
- 2.3.22 package_length_type
- 2.3.23 package_length_func
- 2.3.24 package_max_length
- 2.3.25 open_cpu_affinity
- 2.3.26 cpu_affinity_ignore
- 2.3.27 open_tcp_nodelay
- 2.3.28 tcp_defer_accept
- 2.3.29 ssl_cert_file
- 2.3.30 ssl_method
- 2.3.31 ssl_ciphers
- 2.3.32 user
- 2.3.33 group
- 2.3.34 chroot
- 2.3.35 pid_file
- 2.3.36 pipe_buffer_size
- 2.3.37 buffer_output_size
- 2.3.38 socket_buffer_size
- 2.3.39 enable_unsafe_event
- 2.3.40 discard_timeout_request
- 2.3.41 enable_reuse_port
- 2.3.42 enable_delay_receive
- 2.3.43 open_http_protocol
- 2.3.44 open_http2_protocol
- 2.3.45 open_websocket_protocol
- 2.3.46 open_mqtt_protocol
- 2.3.47 open_websocket_close_frame
- 2.3.48 reload_async
- 2.3.49 tcp_fastopen
- 2.3.50 request_slowlog_file
- 2.3.51 enable_coroutine
- 2.3.52 max_coroutine
- 2.4 监听端口
- 2.4.1 可选参数
- 2.4.2 可选回调
- 2.4.3 连接迭代器
- 2.5 预定义常量
- 2.6 事件回调函数
- 2.6.1 onStart
- 2.6.2 onShutdown
- 2.6.3 onWorkerStart
- 2.6.4 onWorkerStop
- 2.6.5 onWorkerExit
- 2.6.6 onConnect
- 2.6.7 onReceive
- 2.6.8 onPacket
- 2.6.9 onClose
- 2.6.10 onBufferFull
- 2.6.11 onBufferEmpty
- 2.6.12 onTask
- 2.6.13 onFinish
- 2.6.14 onPipeMessage
- 2.6.15 onWorkerError
- 2.6.16 onManagerStart
- 2.6.17 onManagerStop
- 2.7 高级特性
- 2.7.1 改变Worker进程的用户/组
- 2.7.2 回调函数中的 reactor_id 和 fd
- 2.7.3 Length_Check 和 EOF_Check 的使用
- 2.7.4 Worker与Reactor通信模式
- 2.7.5 TCP-Keepalive死连接检测
- 2.7.6 TCP服务器心跳维持方案
- 2.7.7 多端口监听的使用
- 2.7.8 捕获Server运行期致命错误
- 2.7.9 swoole_server的两种运行模式介绍
- 2.7.10 swoole_server中对象的4层生命周期
- 2.7.11 在worker进程内监听一个Server端口
- 2.7.12 在php-fpm/apache中使用task功能
- 2.8 常见问题
- 2.8.1 为什么不要send完后立即close
- 2.8.2 如何在回调函数中访问外部的变量
- 2.8.3 swoole_server中内存管理机制
- 2.8.4 是否可以共用1个redis或mysql连接
- 2.8.5 关于onConnect/onReceive/onClose顺序
- 2.8.6 4种PHP回调函数风格
- 2.8.7 不同的Server程序实例间如何通信
- 2.8.8 错误信息:ERROR (9006)
- 2.8.9 eventLoop has already been created. unable to create swoole_server
- 2.9 压力测试
- 2.9.1 并发10万TCP连接的测试
- 2.9.2 PHP7+Swoole/Nginx/Golang性能对比
- 2.9.3 全球Web框架权威性能测试 Techempower Web Framework Benchmarks
- 第三章 Client
- 3.1 方法列表
- 3.1.1 swoole_client::__construct
- 3.1.2 swoole_client->set
- 3.1.3 swoole_client->on
- 3.1.4 swoole_client->connect
- 3.1.5 swoole_client->isConnected
- 3.1.6 swoole_client->getSocket
- 3.1.7 swoole_client->getSockName
- 3.1.8 swoole_client->getPeerName
- 3.1.9 swoole_client->getPeerCert
- 3.1.10 swoole_client->send
- 3.1.11 swoole_client->sendto
- 3.1.12 swoole_client->sendfile
- 3.1.13 swoole_client->recv
- 3.1.14 swoole_client->close
- 3.1.15 swoole_client->sleep
- 3.1.16 swoole_client->wakeup
- 3.1.17 swoole_client->enableSSL
- 3.2 回调函数
- 3.2.1 onConnect
- 3.2.2 onError
- 3.3.3 onReceive
- 3.3.4 onClose
- 3.3.5 onBufferFull
- 3.3.6 onBufferEmpty
- 3.3 属性列表
- 3.3.1 swoole_client->errCode
- 3.3.2 swoole_client->sock
- 3.3.3 swoole_client->reuse
- 3.4 并行
- 3.4.1 swoole_client_select
- 3.4.2 TCP客户端异步连接
- 3.4.3 SWOOLE_KEEP建立TCP长连接
- 3.5 常量
- 3.6 配置选项
- 3.6.1 ssl_verify_peer
- 3.6.2 ssl_host_name
- 3.6.3 ssl_cafile
- 3.6.4 ssl_capath
- 3.6.5 package_length_func
- 3.7 常见问题
- 第四章 Coroutine
- 4.1 Coroutine
- 4.1.1 Coroutine::getuid
- 4.1.2 Coroutine::create
- 4.1.3 Coroutine::resume
- 4.1.4 Coroutine::suspend
- 4.1.5 Coroutine::fread
- 4.1.6 Coroutine::fgets
- 4.1.7 Coroutine::fwrite
- 4.1.8 Coroutine::sleep
- 4.1.9 Coroutine::gethostbyname
- 4.1.10 Coroutine::getaddrinfo
- 4.1.11 Coroutine::exec
- 4.1.12 Coroutine::readFile
- 4.1.13 Coroutine::writeFile
- 4.1.14 Coroutine::stats
- 4.1.15 Coroutine::getBackTrace
- 4.1.16 Coroutine::listCoroutines
- 4.2 Coroutine\Channel
- 4.2.1 Coroutine\Channel->__construct
- 4.2.2 Coroutine\Channel->push
- 4.2.3 Coroutine\Channel->pop
- 4.2.4 Coroutine\Channel->stats
- 4.2.5 Coroutine\Channel->close
- 4.2.6 Coroutine\Channel->length
- 4.2.7 Coroutine\Channel->isEmpty
- 4.2.8 Coroutine\Channel->isFull
- 4.2.9 Coroutine\Channel->$capacity
- 4.2.10 Coroutine\Channel->$errCode
- 4.3 Coroutine\Client
- 4.3.1 Coroutine\Client->connect
- 4.3.2 Coroutine\Client->send
- 4.3.3 Coroutine\Client->recv
- 4.3.4 Coroutine\Client->close
- 4.3.5 Coroutine\Client->peek
- 4.4 Coroutine\Http\Client
- 4.4.1 属性列表
- 4.4.2 Coroutine\Http\Client->get
- 4.4.3 Coroutine\Http\Client->post
- 4.4.4 Coroutine\Http\Client->upgrade
- 4.4.5 Coroutine\Http\Client->push
- 4.4.6 Coroutine\Http\Client->recv
- 4.4.7 Coroutine\Http\Client->addFile
- 4.4.8 Coroutine\Http\Client->addData
- 4.4.9 Coroutine\Http\Client->download
- 4.5 Coroutine\Http2\Client
- 4.5.1 Coroutine\Http2\Client->__construct
- 4.5.2 Coroutine\Http2\Client->set
- 4.5.3 Coroutine\Http2\Client->connect
- 4.5.4 Coroutine\Http2\Client->send
- 4.5.5 Coroutine\Http2\Client->write
- 4.5.6 Coroutine\Http2\Client->recv
- 4.5.7 Coroutine\Http2\Client->close
- 4.6 Coroutine\Redis
- 4.6.1 方法列表
- 4.6.2 属性列表
- 4.7 Coroutine\Socket
- 4.7.1 Coroutine\Socket::__construct
- 4.7.2 Coroutine\Socket->bind
- 4.7.3 Coroutine\Socket->listen
- 4.7.4 Coroutine\Socket->accept
- 4.7.5 Coroutine\Socket->connect
- 4.7.6 Coroutine\Socket->send
- 4.7.7 Coroutine\Socket->recv
- 4.7.8 Coroutine\Socket->sendto
- 4.7.9 Coroutine\Socket->recvfrom
- 4.7.10 Coroutine\Socket->getsockname
- 4.7.11 Coroutine\Socket->getpeername
- 4.7.12 Coroutine\Socket->close
- 4.8 Coroutine\MySQL
- 4.8.1 属性列表
- 4.8.2 Coroutine\MySQL->connect
- 4.8.3 Coroutine\MySQL->query
- 4.8.4 Coroutine\MySQL->prepare
- 4.8.5 Coroutine\MySQL\Statement->execute
- 4.8.6 Coroutine\MySQL\Statement->fetch
- 4.8.7 Coroutine\MySQL\Statement->fetchAll
- 4.8.8 Coroutine\MySQL\Statement->nextResult
- 4.8.9 Coroutine\MySQL->execFile
- 4.9 Coroutine\PostgreSQL
- 4.9.1 Coroutine\PostgreSQL->connect
- 4.9.2 Coroutine\PostgreSQL->query
- 4.9.3 Coroutine\PostgreSQL->fetchAll
- 4.9.4 Coroutine\PostgreSQL->affectedRows
- 4.9.5 Coroutine\PostgreSQL->numRows
- 4.9.6 Coroutine\PostgreSQL->fetchObject
- 4.9.7 Coroutine\PostgreSQL->fetchAssoc
- 4.9.8 Coroutine\PostgreSQL->fetchArray
- 4.9.9 Coroutine\PostgreSQL->fetchRow
- 4.9.10 Coroutine\PostgreSQL->metaData
- 4.10 Runtime::enableCoroutine
- 4.10.1 文件操作
- 4.10.2 睡眠函数
- 4.10.3 开关选项
- 4.11 Server
- 4.12 并发调用
- 4.12.1 Defer 机制
- 4.12.2 子协程+通道
- 4.13 实现原理
- 4.13.1 协程与线程
- 4.13.2 发送数据协程调度
- 4.13.3 协程内存开销
- 4.13.4 4.0 协程实现原理
- 4.14 常见问题
- 4.14.1 运行中出现 Fatal error: Maximum function nesting level of '1000' reached, aborting!
- 4.14.2 为什么只能在回调函数中使用协程客户端
- 4.14.3 支持协程的回调方法列表
- 4.14.4 错误信息: XXXX client has already been bound to another coroutine
- 4.14.5 Swoole4 协程与 PHP 的 Yield/Generator 协程有什么区别
- 4.15 编程须知
- 4.15.1 在多个协程间共用同一个协程客户端
- 4.15.2 禁止使用协程 API 的场景 (Swoole4以下版本)
- 4.15.3 使用类静态变量/全局变量保存上下文
- 4.16 退出协程
- 4.17 扩展组件
- 4.17.1 MongoDB
- 第五章 Async
- 5.1 异步文件系统IO
- 5.1.1 swoole_async_readfile
- 5.1.2 swoole_async_writefile
- 5.1.3 swoole_async_read
- 5.1.4 swoole_async_write
- 5.1.5 swoole_async_dns_lookup
- 5.1.6 swoole_async::exec
- 5.2 EventLoop
- 5.2.1 swoole_event_add
- 5.2.2 swoole_event_set
- 5.2.3 swoole_event_isset
- 5.2.4 swoole_event_write
- 5.2.5 swoole_event_del
- 5.2.6 swoole_event_exit
- 5.2.7 swoole_event_defer
- 5.2.8 swoole_event_cycle
- 5.2.9 swoole_event_wait
- 5.2.10 swoole_event_dispatch
- 5.3 异步毫秒定时器
- 5.3.1 swoole_timer_tick
- 5.3.2 swoole_timer_after
- 5.3.3 swoole_timer_clear
- 5.4 异步MySQL客户端
- 5.4.1 swoole_mysql->__construct
- 5.4.2 swoole_mysql->on
- 5.4.3 swoole_mysql->connect
- 5.4.4 swoole_mysql->escape
- 5.4.5 swoole_mysql->query
- 5.4.6 swoole_mysql->begin
- 5.4.7 swoole_mysql->commit
- 5.4.8 swoole_mysql->rollback
- 5.4.9 swoole_mysql->close
- 5.5 异步Redis客户端
- 5.5.1 swoole_redis->__construct
- 5.5.2 swoole_redis->on
- 5.5.3 swoole_redis->connect
- 5.5.4 swoole_redis->__call
- 5.5.5 swoole_redis->close
- 5.6 异步Http/WebSocket客户端
- 5.6.1 swoole_http_client->__construct
- 5.6.2 swoole_http_client->set
- 5.6.3 swoole_http_client->setMethod
- 5.6.4 swoole_http_client->setHeaders
- 5.6.5 swoole_http_client->setCookies
- 5.6.6 swoole_http_client->setData
- 5.6.7 swoole_http_client->addFile
- 5.6.8 swoole_http_client->get
- 5.6.9 swoole_http_client->post
- 5.6.10 swoole_http_client->upgrade
- 5.6.11 swoole_http_client->push
- 5.6.12 swoole_http_client->execute
- 5.6.13 swoole_http_client->download
- 5.6.14 swoole_http_client->close
- 5.7 异步Http2.0客户端
- 5.7.1 swoole_http2_client->__construct
- 5.7.2 swoole_http2_client->get
- 5.7.3 swoole_http2_client->post
- 5.7.4 swoole_http2_client->setHeaders
- 5.7.5 swoole_http2_client->setCookies
- 第六章 Memory
- 6.1 Lock
- 6.1.1 swoole_lock->__construct
- 6.1.2 swoole_lock->lock
- 6.1.3 swoole_lock->trylock
- 6.1.4 swoole_lock->unlock
- 6.1.5 swoole_lock->lock_read
- 6.1.6 swoole_lock->trylock_read
- 6.1.7 swoole_lock->lockwait
- 6.2 Buffer
- 6.2.1 swoole_buffer->__construct
- 6.2.2 swoole_buffer->append
- 6.2.3 swoole_buffer->substr
- 6.2.4 swoole_buffer->clear
- 6.2.5 swoole_buffer->expand
- 6.2.6 swoole_buffer->write
- 6.2.7 swoole_buffer->read
- 6.2.8 swoole_buffer->recycle
- 6.3 Table
- 6.3.1 swoole_table->__construct
- 6.3.2 swoole_table->column
- 6.3.3 swoole_table->create
- 6.3.4 swoole_table->set
- 6.3.5 swoole_table->incr
- 6.3.6 swoole_table->decr
- 6.3.7 swoole_table->get
- 6.3.8 swoole_table->exist
- 6.3.9 swoole_table->del
- 6.3.10 常量列表
- 6.3.11 swoole_table->count
- 6.4 Atomic
- 6.4.1 swoole_atomic->__construct
- 6.4.2 swoole_atomic->add
- 6.4.3 swoole_atomic->sub
- 6.4.4 swoole_atomic->get
- 6.4.5 swoole_atomic->set
- 6.4.6 swoole_atomic->cmpset
- 6.4.7 swoole_atomic->wait
- 6.4.8 swoole_atomic->wakeup
- 6.5 mmap
- 6.5.1 swoole_mmap::open
- 6.6 Channel
- 6.6.1 Channel->__construct
- 6.6.2 Channel->push
- 6.6.3 Channel->pop
- 6.6.4 Channel->stats
- 6.7 Serialize
- 6.7.1 swoole_serialize::pack
- 6.7.2 swoole_serialize::unpack
- 第七章 Process
- 7.1 swoole_process::__construct
- 7.2 swoole_process->start
- 7.3 swoole_process->name
- 7.4 swoole_process->exec
- 7.5 swoole_process->write
- 7.6 swoole_process->read
- 7.7 swoole_process->setTimeout
- 7.8 swoole_process->setBlocking
- 7.9 swoole_process->useQueue
- 7.10 swoole_process->statQueue
- 7.11 swoole_process->freeQueue
- 7.12 swoole_process->push
- 7.13 swoole_process->pop
- 7.14 swoole_process->close
- 7.15 swoole_process->exit
- 7.16 swoole_process::kill
- 7.17 swoole_process::wait
- 7.18 swoole_process::daemon
- 7.19 swoole_process::signal
- 7.20 swoole_process::alarm
- 7.21 swoole_process::setAffinity
- 第八章 HttpServer
- 8.1 swoole_http_server
- 8.1.1 swoole_http_server->on
- 8.1.2 swoole_http_server->start
- 8.2 swoole_http_request
- 8.2.1 swoole_http_request->$header
- 8.2.2 swoole_http_request->$server
- 8.2.3 swoole_http_request->$get
- 8.2.4 swoole_http_request->$post
- 8.2.5 swoole_http_request->$cookie
- 8.2.6 swoole_http_request->$files
- 8.2.7 swoole_http_request->rawContent
- 8.2.8 swoole_http_request->getData
- 8.3 swoole_http_response
- 8.3.1 swoole_http_response->header
- 8.3.2 swoole_http_response->cookie
- 8.3.3 swoole_http_response->status
- 8.3.4 swoole_http_response->gzip
- 8.3.5 swoole_http_response->redirect
- 8.3.6 swoole_http_response->write
- 8.3.7 swoole_http_response->sendfile
- 8.3.8 swoole_http_response->end
- 8.3.9 swoole_http_response->detach
- 8.3.10 swoole_http_response::create
- 8.4 配置选项
- 8.4.1 upload_tmp_dir
- 8.4.2 http_parse_post
- 8.4.3 document_root
- 8.4.4 http_compression
- 8.5 常见问题
- 8.5.1 CURL发送POST请求服务器端超时
- 8.5.2 使用Chrome访问服务器会产生2次请求
- 8.5.3 GET/POST请求的最大尺寸
- 第九章 WebSocket
- 9.1 回调函数
- 9.1.1 onHandShake
- 9.1.2 onOpen
- 9.1.3 onMessage
- 9.2 函数列表
- 9.2.1 swoole_websocket_server->push
- 9.2.2 swoole_websocket_server->exist
- 9.2.3 swoole_websocket_server::pack
- 9.2.4 swoole_websocket_server::unpack
- 9.2.5 swoole_websocket_server->disconnect
- 9.3 预定义常量
- 9.4 常见问题
- 9.5 配置选项
- 9.6 swoole_websocket_frame
- 第十章 Process\Pool
- 10.1 Process\Pool::__construct
- 10.2 Process\Pool->on
- 10.3 Process\Pool->listen
- 10.4 Process\Pool->write
- 10.5 Process\Pool->start
- 10.6 Process\Pool->getProcess
- 第十一章 Redis\Server
- 11.1 方法
- 11.1.1 setHandler
- 11.1.2 format
- 11.2 常量
- 第十二章 高级
- 12.1 Swoole的实现
- 12.2 Reactor线程
- 12.3 Manager进程
- 12.4 Worker进程
- 12.5 Reactor、Worker、TaskWorker的关系
- 12.6 Task/Finish特性的用途
- 12.7 在php-fpm或apache中使用swoole
- 12.8 Swoole异步与同步的选择
- 12.9 TCP/UDP压测工具
- 12.10 swoole服务器如何做到无人值守100%可用
- 12.11 MySQL的连接池、异步、断线重连
- 12.12 PHP中哪些函数是同步阻塞的
- 12.13 守护进程程序常用数据结构
- 12.13.1 队列(Queue)
- 12.13.2 堆(Heap)
- 12.13.3 定长数组(SplFixedArray)
- 12.14 使用jemalloc优化swoole内存分配性能
- 12.15 C开发者如何使用Swoole
- 12.16 C++开发者如何使用Swoole
- 12.17 使用systemd管理swoole服务
- 12.18 网卡中断设置
- 12.19 将Swoole静态编译内嵌到PHP
- 12.20 异步回调程序内存管理
- 12.21 日志等级控制
- 12.22 使用 asan 内存检测
- 12.23 Windows编译
- 第十三章 其他
- 13.1 函数列表
- 13.1.1 swoole_set_process_name
- 13.1.2 swoole_version
- 13.1.3 swoole_strerror
- 13.1.4 swoole_errno
- 13.1.5 swoole_get_local_ip
- 13.1.6 swoole_clear_dns_cache
- 13.1.7 swoole_get_local_mac
- 13.1.8 swoole_cpu_num
- 13.3 Swoole技术会议
- 13.4 捐赠Swoole项目
- 13.5 加入Swoole开发组
- 13.6 附录:Linux信号列表
- 13.7 附录:Linux错误信息(errno)列表
- 13.8 附录:TCP连接的状态
- 13.9 附录:tcpdump抓包工具的使用
- 13.10 附录:strace工具的使用
- 13.11 附录:gdb工具的使用
- 13.12 附录:lsof工具的使用
- 13.13 附录:perf工具的使用
- 13.14 附录:编译PHP扩展的相关工具
- 13.15 备用:已移除的历史特性
- 13.15.1 swoole_server->handler
- 13.15.2 task_worker_max
- 13.15.3 swoole_server->addtimer
- 13.15.4 swoole_server->deltimer
- 13.15.5 onTimer
- 13.15.6 swoole_timer_add
- 13.15.7 swoole_timer_del
- 13.15.8 swoole_get_mysqli_sock
- 13.15.9 swoole_mysql_query
- 13.15.10 onMasterConnect
- 13.15.11 onMasterClose
- 13.15.12 Nginx/Golang/Swoole/Node.js的性能对比
- 13.15.13 Coroutine::call_user_func
- 13.15.14 Coroutine::call_user_func_array
- 13.15.15 Coroutine\Channel::select
- 13.16 历史:版本更新记录(1.x)
- 13.16.1 1.10.3
- 13.16.2 1.10.2
- 13.16.3 1.10.1
- 13.16.4 1.10.0
- 13.16.5 1.9.23
- 13.16.6 1.9.22
- 13.16.7 1.9.19
- 13.16.8 1.9.18
- 13.16.9 1.9.17
- 13.16.10 1.9.16
- 13.16.11 1.9.15
- 13.16.12 1.9.14
- 13.16.13 1.9.12
- 13.16.14 1.9.11
- 13.16.15 1.9.9
- 13.16.16 1.9.7
- 13.16.17 1.9.6
- 13.16.18 1.9.5
- 13.16.19 1.9.4
- 13.16.20 1.9.3
- 13.16.21 1.9.2
- 13.16.22 1.9.1
- 13.16.23 1.9.0
- 13.16.24 1.8.13
- 13.16.25 1.8.12
- 13.16.26 1.8.11
- 13.16.27 1.8.10
- 13.16.28 1.8.9
- 13.16.29 1.8.8
- 13.16.30 1.8.7
- 13.16.31 1.8.6
- 13.16.32 1.8.5
- 13.16.33 1.8.4
- 13.16.34 1.8.3
- 13.16.35 1.8.2
- 13.16.36 1.8.1
- 13.16.37 1.8.0
- 13.16.38 1.7.22
- 13.16.39 1.7.21
- 13.16.40 1.7.20
- 13.16.41 1.7.19
- 13.16.42 1.7.18
- 13.16.43 1.7.17
- 13.16.44 1.7.16
- 13.16.45 1.7.15
- 13.16.46 1.7.14
- 13.16.47 1.7.13
- 13.16.48 1.7.12
- 13.16.49 1.7.11
- 13.16.50 1.7.10
- 13.16.51 1.7.9
- 13.16.52 1.7.8
- 13.16.53 1.7.7
- 13.16.54 1.7.6
- 13.16.55 1.7.5
- 13.16.56 v1.5
- 13.16.57 v1.6
- 13.16.58 v1.7
- 13.17 历史:版本更新记录(2.x)
- 13.17.1 2.0.1-Alpha
- 13.17.2 2.0.5
- 13.17.3 2.0.9
- 13.17.4 1.9.21
- 13.17.5 2.0.10
- 13.17.6 2.0.11
- 13.17.7 2.0.12
- 13.17.8 2.0.13
- 13.17.9 2.1.1
- 13.17.10 2.1.2
- 13.17.11 2.2.0
- 13.17.12 3.0.0
- 13.20 参与开源项目指引