EasySwoole Distributed基于 Swoole 的 PHP 協(xié)程開發(fā)框架
ESD 是一個免費開源的,快速、簡單的基于 Swoole4.3 最新特性的 PHP 協(xié)程開發(fā)框架。由 SwooleDistributed 與 EasySwoole 作者打造。ESD 可用于構建高性能的 Web 系統(tǒng)、API、中間件、基礎服務等等。
功能特性預覽:
-
協(xié)程框架:基于 Swoole 4.3的原生協(xié)程框架,自帶常駐內存以及 Swoole 其它功能的封裝。
-
多種混合協(xié)議通訊:HTTP 控制器與自定義路由 TCP、UDP、WEB_SOCKET 控制器
-
組件化:組件分為核心組件和應用組件,所有應用組件都是非必須的,開發(fā)者可以自定義,按需使用。
-
連接池:框架自帶 Mysql/Redis/ampq 高效連接池,且實現(xiàn)所有連接斷線重連。開發(fā)者不用關心連接,相應組件已經(jīng)實現(xiàn)。
-
切面編程:框架容器管理的所有對象,都可以使用 AOP。使用AOP 可以使用在不改變實例內部的情況下,對實例對象的行為進行控制。
-
分布式與微服務:提供分布式與微服務的插件組織
-
注解系統(tǒng):框架提供大量可使用的注解,比如注解路由,注解事務,注解緩存,注解驗證等。 框架均提供注解與非注解的使用方式。
-
Tracing 鏈路追蹤:通過加載Tracing插件可以實現(xiàn)服務鏈路性能的監(jiān)控,支持微服務
-
靈活的注解功能
-
全局的依賴注入容器
-
基于 PSR-7 的 HTTP 消息實現(xiàn)
-
事件管理器
-
緩存
-
協(xié)程、異步任務投遞
-
自定義用戶進程
-
協(xié)程和同步阻塞客戶端無縫自動切換
-
熱更新自動 Reload
-
強大的日志系統(tǒng)
組件化
ESD從設計之初就實現(xiàn)了組件化模式,達到模塊解耦和代碼復用的效果。
目前可用插件
- console-plugin https://github.com/esd-projects/console-plugin 控制臺插件
- postgresql-plugin https://github.com/esd-projects/postgresql-plugin postgreSQL插件(由bearlord提供)
- mqtt-plugin https://github.com/esd-projects/mqtt-plugin MQTT服務器、MQTT客戶端、MQTT路由
- redis-plugin https://github.com/esd-projects/redis-plugin redis插件
- easyroute-plugin https://github.com/esd-projects/easyroute-plugin 最方便的注解路由插件
- pack-plugin https://github.com/esd-projects/pack-plugin tcp,ws等自定義協(xié)議解析的pack插件
- tracing-plugin https://github.com/esd-projects/tracing-plugin 鏈路監(jiān)控插件
- aop-plugin https://github.com/esd-projects/aop-plugin 提供AOP支持的插件
- amqp-plugin https://github.com/esd-projects/amqp-plugin AMQP插件(由李丹陽提供)
- mysql-plugin https://github.com/esd-projects/mysql-plugin mysql插件
- annotations-scan-plugin https://github.com/esd-projects/annotations-scan-plugin 掃描注解插件
- whoops-plugin https://github.com/esd-projects/whoops-plugin whoops插件,http調試用
- session-plugin https://github.com/esd-projects/session-plugin session插件
- cache-plugin https://github.com/esd-projects/cache-plugin cache插件,緩存
- actuator-plugin https://github.com/esd-projects/actuator-plugin actuator插件提供健康檢查等框架默認端點服務
- security-plugin https://github.com/esd-projects/security-plugin 鑒權插件
- saber-plugin https://github.com/esd-projects/saber-plugin http客戶端插件,Saber
- autoreload-plugin https://github.com/esd-projects/autoreload-plugin 自動reload插件,用于開發(fā)
- validate-plugin https://github.com/esd-projects/validate-plugin 驗證插件,提供數(shù)據(jù)的驗證
- uid-plugin https://github.com/esd-projects/uid-plugin uid插件,長連接用于綁定fd與uid的關系
- topic-plugin https://github.com/esd-projects/topic-plugin 主題插件,長連接用于發(fā)送訂閱主題,符合MQTT規(guī)范
- scheduled-plugin https://github.com/esd-projects/scheduled-plugin 定時任務插件
- phpunit-plugin https://github.com/esd-projects/phpunit-plugin 單元測試插件
- blade-plugin https://github.com/esd-projects/blade-plugin blade渲染插件
- csvreader-plugin https://github.com/esd-projects/csvreader-plugin 讀取解析csv的插件
- process-rpc-plugin https://github.com/esd-projects/process-rpc-plugin 進程通訊插件
- saber-cloud-plugin https://github.com/esd-projects/saber-cloud-plugin 聲明試Web客戶端,提供微服務訪問
- circuitbreaker-plugin https://github.com/esd-projects/circuitbreaker-plugin 微服務的熔斷器插件
- consul-plugin-plugin https://github.com/esd-projects/consul-plugin consul插件,提供服務注冊,選舉
Docker運行環(huán)境(由anythink提供)
? docker run -it --rm -p 8080:8080 -v $PWD:/data registry.cn-beijing.aliyuncs.com/anythink/esd:latest
_____ ____ ____ ____ _ _
| ____/ ___|| _ \ | _ \ _ _ _ __ | |_(_)_ __ ___ ___
| _| \___ \| | | | | |_) | | | | '_ \| __| | '_ ` _ \ / _ \
| |___ ___) | |_| | | _ <| |_| | | | | |_| | | | | | | __/
|_____|____/|____/ |_| \_\\__,_|_| |_|\__|_|_| |_| |_|\___|
ESD framework Runtime Environment
version 1.5 author by anythink
root@f41132062911:/data#
docker run -it --rm -p 8080:8080 -v $PWD:/data registry.cn-beijing.aliyuncs.com/anythink/esd:latest
請在 ESD 根目錄運行容器,否則修改$PWD為代碼根路徑(windows需要用%cd%替換$PWD),如果修改了端口請把8080 修改為自己使用的端口. 鏡像啟動后的目錄即掛載到主機的代碼目錄,注意 Mac 系統(tǒng)無法使用 inotify 熱加載功能。 容器啟動后按照安裝步驟,運行框架。
性能
4核8G SSD盤 騰訊云高IO型I2服務器壓測,框架壓測包含路由
worker_num = 4
swoole ab壓測輸出hello 平均 5.9QPS萬
ESD框架 ab壓測輸出hello 平均 3.6QPS萬
SD框架 ab壓測輸出hello 平均 1.3QPS萬
壓測數(shù)據(jù)來自:A-Smile
