CabalPHP

CabalPHP 是一个基于Swoole的轻量、高效、全异步开源框架。

?> 作者已经在生产环境使用,腾讯云两台4H8G(CabalPHP+Redis两个服务)支持日活跃3000W+PV的统计业务,依靠Task进程异步将统计数据写入腾讯云MySQL。

!> 框架并发场景已经得到验证,复杂业务场景尚未验证。
至少我们发现了其他框架没发现的 Swoole MySQL协程大量请求场景下的BUG。 ^_^

欢迎大家加入QQ交流群:36900937

亮点

  • 全异步单机超高性能,轻松分布式部署
  • 支持HTTP、TCP、websocket等多种协议
  • 完善数据库引擎,简单高效(其他swoole框架几乎没有哦)
  • 易于学习,开发效率高,简单高效的数据库引擎
  • 自动生成API接口文档
  • 使用IDE(Sublime Text/VSCode/PhpStorm等)有完整的代码提示

适用场景

  • 微服务架构的RPC服务开发
  • 前后分离的应用(RESTful)API接口开发
  • 即时通讯服务端开发
  • 传统的Web网站,服务端渲染SEO友好

性能及压力测试

环境:

  • 腾讯云 容器服务
  • 镜像: 基于 php:7.1-alpine 的swoole镜像
  • 1cores
  • 256MiB - 512MiB
  • php 7.1.12
  1. # ab -c 2000 -n 10000 http://172.16.1.79:9501/
  2. This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
  3. Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
  4. Licensed to The Apache Software Foundation, http://www.apache.org/
  5. Benchmarking 172.16.1.79 (be patient)
  6. Completed 1000 requests
  7. Completed 2000 requests
  8. Completed 3000 requests
  9. Completed 4000 requests
  10. Completed 5000 requests
  11. Completed 6000 requests
  12. Completed 7000 requests
  13. Completed 8000 requests
  14. Completed 9000 requests
  15. Completed 10000 requests
  16. Finished 10000 requests
  17. Server Software: swoole-http-server
  18. Server Hostname: 172.16.1.79
  19. Server Port: 9501
  20. Document Path: /
  21. Document Length: 284 bytes
  22. Concurrency Level: 2000
  23. Time taken for tests: 1.658 seconds
  24. Complete requests: 10000
  25. Failed requests: 3
  26. (Connect: 0, Receive: 0, Length: 3, Exceptions: 0)
  27. Write errors: 0
  28. Total transferred: 4330003 bytes
  29. HTML transferred: 2840003 bytes
  30. Requests per second: 6031.43 [#/sec] (mean)
  31. Time per request: 331.596 [ms] (mean)
  32. Time per request: 0.166 [ms] (mean, across all concurrent requests)
  33. Transfer rate: 2550.40 [Kbytes/sec] received
  34. Connection Times (ms)
  35. min mean[+/-sd] median max
  36. Connect: 0 37 154.4 2 1005
  37. Processing: 27 252 68.8 260 547
  38. Waiting: 0 250 69.2 259 546
  39. Total: 79 289 165.9 267 1369
  40. Percentage of the requests served within a certain time (ms)
  41. 50% 267
  42. 66% 284
  43. 75% 303
  44. 80% 314
  45. 90% 347
  46. 95% 365
  47. 98% 1252
  48. 99% 1279
  49. 100% 1369 (longest request)

示例

捐助

先捐助些优秀的代码吧!

来源(书栈小编注)

https://github.com/cabalphp/cabalphp.github.io