百万并发下PHP协程+非阻塞框架设计实践--代维@PHPCon2016
2020-02-27 166浏览
- 1.PHP + @
- 2.About me • 2014 • Yac Windows • Memcache • PHP Redis PECL PHP7
- 3.1. Why & What 2. 3. Zan in Zan
- 4.Part 1 Why & What
- 5.Why?! • • •
- 6.What is Zan? Event Session Cookie Trace Env … Context go(callable) defer(callable) parallel($calls) getContext() setContext() … Filters Acl Trace … HTTP server App Console Core Resource Event Di Config Domain … Mysql Kv Nsq Syslog Nova … Terminators view html json jsonp jpg csv … Service Bo Vo Dao … TCP server syscall Response controller PHP MQ worker … Apps …… View Layout Components jsVar JsLoader CssLoader JsMinifier Form … composer ext vendors RPC(nova, thrift, pb, …) …… S O A
- 7.1 2 # composer global require youzan/zan-installer zan 3 4 # bin/httpd
- 8.Part 2 in Zan
- 9.Web IO Web IO Zan IO : PHP-FPM — Just like GolangJava:— Swoole With (PHP + yield)Golang:—Node.js:— Callback Event Session Cookie Trace Env … Context go(callable) defer(callable) parallel($calls) getContext() setContext() … Filters All Trace … Callback controller Service Bo Vo Dao … PHP syscall Response view html json jsonp jpg csv … Terminators …
- 10.callback vs
- 11.PHP • yield • Generator • •
- 12.start init coroutine task.start generator just wait the future coroutine result push current coroutine to stack stack pop async job async job callback generator send execute job and bind callback to wait async response send async response set working coroutine to generator async callback run task.continue end system call simple value
- 13.Syscall • go(Generator $coroutine) • defer(callable $cb) • deferRelease(Resource $res) • parallel($coroutines) • taskSleep($ms) • …
- 14.• • • SysCall
- 15.• callback • • RPC
- 16.UnitTest • • • task • case
- 17.Part 3 Zan
- 18.SqlMap • SQL • Sharding • Cache • • …
- 19.View extend extend • • • BigPipe & BigRender extend
- 20.2000 vs 2500000 :https://github.com/EVODelavega/phpkafka
- 21.Libs • Mysql • Redis • KV • TCP • HTTP • …
- 22.SOA Zan SOA ...
- 23.: 32 : c 300 n 1000000 64G( * 1+ * 1) HttpServer TcpServer TPS TPS 4 4 -> TCP -> TCP 14000 20000 60000 20ms 2500 75000 100000
- 24.chiyou@youzan.comZan:http://github.com/youzan/zan