Comments (3)
- 首先 mix 现在是采用的阻塞同步模式,在这种模式中,一个请求只会在同一个进程,只有在 onRequest 结束后,这个进程才能接收其他请求,而 mix 的组件都有实现 onRequestStart onRequestEnd 事件,组件会在这两个事件中清理类属性的值,所以没有变量污染问题,反而,因为是全局变量,组件常驻于内存,无需初始化,才有比其他框架高很多的性能。
- 当 mix 开启协程时 (我还在开发),一个进程会同时处理N个请求,这个时候组件就会有变量污染问题了,但是我为组件开发了协程隔离机制,会在不同的协程内生成不同的组件,但用户确感知不到,因为使用的方法与阻塞同步不变,所以你就会有上面的这种困惑。
from mix.
@onanying 感谢您的耐心解答。对于第一点,我看到swoole是基于epoll实现IO复用的,那么同一个进程里接收多个客户端请求,这时候其实也是阻塞执行的?可以这么理解吗?然后第二点这个特性很期待!
from mix.
@onanying 感觉想明白了:epoll属于同步非阻塞,所以swoole里单个进程内部依然是同步非阻塞。只要记得把用过的全局变量清理掉,就不会有变量污染问题。这么说来MixPHP运行在php-fpm和swoole里,都是同步方式的。
from mix.
Related Issues (20)
- Redis-subscribe 支持 prefix 否? HOT 1
- 没有对mysql保留关键字做反引号处理 HOT 1
- 2.2版本 UDP服务器会重复执行处理接收到的数据 HOT 2
- 官网无法访问 HOT 2
- 数据量较多时,json_decode可能会失败 HOT 7
- PDO执行使用问号占位符的原生SQL报错 HOT 2
- 建议项目遵从语义化版本来维护版本号 HOT 1
- PHP用ip curl post请求 会卡1秒 HOT 5
- 新版本性能严重下降 HOT 6
- table方法传入表名order报错 HOT 1
- 验证器场景设置optional未生效 HOT 3
- Coroutine中同时使用Channel和Database pool导致出错 HOT 5
- mix-skeleton使用context()->get('guzzle') 报错 HOT 1
- php8RC3-swoole4.5.6 运行出错 HOT 1
- or and 查找抛出异常 HOT 1
- Upgrade to Zipkin 2.0 HOT 1
- log组件报错 HOT 1
- 推送模式卡死 HOT 1
- 如何正确的提交 PR
- V3 启动事务后 lastInsertId 值不正确 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 mix.