Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Swooleのフレームワークをくらべてみた

 Swooleのフレームワークをくらべてみた

PHPerKaig2019の発表資料です

uzullaさんのPHPerKaigi2018「大統一PHP」
https://speakerdeck.com/uzulla/da-tong-php
で紹介されているSwooleという非同期かつ、Coroutineの仕組みをもったPHPのextensionがあります。
Swooleを用いたフレームワークはいくつかあります。
今回、EasySwoole(v2,v3)、Swoft、Laravel-Swooleの3つの比べてみた結果をお話しします。
それぞれのフレームワークのISUCON8予選のベンチマークの結果をお伝えします(恒例)
No.1 Swooleフレームワークはどれだ!

CyberAgent SGE Engineer

March 31, 2019
Tweet

More Decks by CyberAgent SGE Engineer

Other Decks in Technology

Transcript

  1. • גࣜձࣾαΠόʔΤʔδΣϯτ • 4(&౷ׅຊ෦ٕज़౷ׅࣨࣨ௕ • ࢠձࣾࣾ$50 • גࣜձࣾ$SBGU&HH • גࣜձࣾδʔΫϨετ

    • גࣜձࣾαϜβοϓ • നҪɹӳ • ΤϯδχΞ • #MPH IUUQBNFCMPKQHPPEPP ͓લɺ୭Α • 5XJUUFS !HPPEPP • %2 ͙ͪ͢Ή '# 
 ϓΫϦϙ ཱྀܳਓ
  2. ಛ௃  &BTZ4XPPMF •Built-in HTTP, TCP, WebSocket,Udp Coroutine Server •Global

    dependency injection container •PSR-7 based HTTP message implementation •RESTful supported •HTTP,TCP, WebSocket, Udp middleware support •Mysql, Redis, RPC, HTTP Coroutine Clients •High performance router •Universal connection pools •Remote Console W
  3. &BTZ4XPPMFͷϑΥϧμߏ੒ ࠷খݶ Project ├ App         │ ├ HttpController │ │ ├ BooksController.php │ │ └

    Router.php │ ├ Model │ │ └ BookModel.php │ └ Utility │   └ Pool │     ├ MysqlObject.php │     └ MysqlPool.php ├ Views │ └ index.twig ├ Log ├ Temp ├ vendor ├ Static │ ├ css │ └ js ├ easyswoole ├ production.php └ dev.php  &BTZ4XPPMF
  4. &BTZ4XPPMFͷϑΥϧμߏ੒ ࠷খݶ Project ├ App         │ ├ HttpController │ │ ├ BooksController.php │ │ └

    Router.php │ ├ Model │ │ └ BookModel.php │ └ Utility │   └ Pool │     ├ MysqlObject.php │     └ MysqlPool.php ├ Views │ └ index.twig ├ Log ├ Temp ├ vendor ├ Static │ ├ css │ └ js ├ easyswoole ├ production.php └ dev.php  &BTZ4XPPMF ίϯτϩʔϥʔ
  5. &BTZ4XPPMFͷϑΥϧμߏ੒ ࠷খݶ Project ├ App         │ ├ HttpController │ │ ├ BooksController.php │ │ └

    Router.php │ ├ Model │ │ └ BookModel.php │ └ Utility │   └ Pool │     ├ MysqlObject.php │     └ MysqlPool.php ├ Views │ └ index.twig ├ Log ├ Temp ├ vendor ├ Static │ ├ css │ └ js ├ easyswoole ├ production.php └ dev.php  &BTZ4XPPMF ϧʔλʔ
  6. &BTZ4XPPMFͷϑΥϧμߏ੒ ࠷খݶ Project ├ App         │ ├ HttpController │ │ ├ BooksController.php │ │ └

    Router.php │ ├ Model │ │ └ BookModel.php │ └ Utility │   └ Pool │     ├ MysqlObject.php │     └ MysqlPool.php ├ Views │ └ index.twig ├ Log ├ Temp ├ vendor ├ Static │ ├ css │ └ js ├ easyswoole ├ production.php └ dev.php  &BTZ4XPPMF Ϟσϧ
  7. &BTZ4XPPMFͷϑΥϧμߏ੒ ࠷খݶ Project ├ App         │ ├ HttpController │ │ ├ BooksController.php │ │ └

    Router.php │ ├ Model │ │ └ BookModel.php │ └ Utility │   └ Pool │     ├ MysqlObject.php │     └ MysqlPool.php ├ Views │ └ index.twig ├ Log ├ Temp ├ vendor ├ Static │ ├ css │ └ js ├ easyswoole ├ production.php └ dev.php  &BTZ4XPPMF %#ͷίωΫγϣ ϯϓʔϧ
  8. &BTZ4XPPMFͷϑΥϧμߏ੒ ࠷খݶ Project ├ App         │ ├ HttpController │ │ ├ BooksController.php │ │ └

    Router.php │ ├ Model │ │ └ BookModel.php │ └ Utility │   └ Pool │     ├ MysqlObject.php │     └ MysqlPool.php ├ Views │ └ index.twig ├ Log ├ Temp ├ vendor ├ Static │ ├ css │ └ js ├ easyswoole ├ production.php └ dev.php  &BTZ4XPPMF ςϯϓϨʔτϑΝΠϧ
  9. &BTZ4XPPMFͷϑΥϧμߏ੒ ࠷খݶ Project ├ App         │ ├ HttpController │ │ ├ BooksController.php │ │ └

    Router.php │ ├ Model │ │ └ BookModel.php │ └ Utility │   └ Pool │     ├ MysqlObject.php │     └ MysqlPool.php ├ Views │ └ index.twig ├ Log ├ Temp ├ vendor ├ Static │ ├ css │ └ js ├ easyswoole ├ production.php └ dev.php  &BTZ4XPPMF ੩తϑΝΠϧ
  10. &BTZ4XPPMFͷϑΥϧμߏ੒ ࠷খݶ Project ├ App         │ ├ HttpController │ │ ├ BooksController.php │ │ └

    Router.php │ ├ Model │ │ └ BookModel.php │ └ Utility │   └ Pool │     ├ MysqlObject.php │     └ MysqlPool.php ├ Views │ └ index.twig ├ Log ├ Temp ├ vendor ├ Static │ ├ css │ └ js ├ easyswoole ├ production.php └ dev.php  &BTZ4XPPMF ىಈ༻ϑΝΠϧ
  11. &BTZ4XPPMFͷϑΥϧμߏ੒ ࠷খݶ Project ├ App         │ ├ HttpController │ │ ├ BooksController.php │ │ └

    Router.php │ ├ Model │ │ └ BookModel.php │ └ Utility │   └ Pool │     ├ MysqlObject.php │     └ MysqlPool.php ├ Views │ └ index.twig ├ Log ├ Temp ├ vendor ├ Static │ ├ css │ └ js ├ easyswoole ├ production.php └ dev.php  &BTZ4XPPMF $POpHϑΝΠϧ ؀ڥ͝ͱ
  12. •Base on Swoole extension •Built-in HTTP, TCP, WebSocket Coroutine Server

    •Powerful AOP (Aspect Oriented Programming) •Flexible and comprehensive annotations framework •Global dependency injection container •PSR-7 based HTTP message implementation •PSR-14 based event manager •PSR-15 based middleware •PSR-16 based cache design •Scalable high performance RPC •Holistic service governance, fallback, load balance, service registration and discovery •Database ORM •Universal connection pools •Mysql, Redis, RPC, HTTP Coroutine Clients •Coroutine driver client and blocking driver client seamlessly switch automatically •Coroutine and asynchronous task delivery •Custom user processes •RESTful supported •Internationalization (i18n) supported •High performance router •Fast and flexible parameter validator •Alias mechanism •Powerful log component •Cross-platform application auto- reload mechanism https://github.com/swoft-cloud/swoft ͷREADMEͷӳ༁ Ҿ༻ɿ  4XPGU
  13. •Built-in HTTP, TCP, WebSocket Coroutine Server •Powerful AOP (Aspect Oriented

    Programming) •Database ORM •Universal connection pools •Flexible and comprehensive annotations framework •Global dependency injection container •PSR-7 based HTTP message implementation ಛ௃  4XPGU
  14. 4XPGUͷϑΥϧμߏ੒ ࠷খݶ Project ├ app         │ ├ Controllers │ │ └ BooksController.php │ └

    Models │   └ Entity │    └ Books.php ├ config │ ├ beans │ │ └ base.php │ └ properties │   ├ app.php │   └ db.php ├ public ├ runtime │ ├ logs │ ├ uploadfiles │ └ sessions ├ resources │ └ views │   └ books │     └ view.php └ bin   ├ bootstrap.php   └ swoft  4XPGU
  15. 4XPGUͷϑΥϧμߏ੒ ࠷খݶ Project ├ app         │ ├ Controllers │ │ └ BooksController.php │ └

    Models │   └ Entity │    └ Books.php ├ config │ ├ beans │ │ └ base.php │ └ properties │   ├ app.php │   └ db.php ├ public ├ runtime │ ├ logs │ ├ uploadfiles │ └ sessions ├ resources │ └ views │   └ books │     └ view.php └ bin   ├ bootstrap.php   └ swoft ίϯτϩʔϥʔ Ϟσϧ  4XPGU
  16. 4XPGUͷϑΥϧμߏ੒ ࠷খݶ Project ├ app         │ ├ Controllers │ │ └ BooksController.php │ └

    Models │   └ Entity │    └ Books.php ├ config │ ├ beans │ │ └ base.php │ └ properties │   ├ app.php │   └ db.php ├ public ├ runtime │ ├ logs │ ├ uploadfiles │ └ sessions ├ resources │ └ views │   └ books │     └ view.php └ bin   ├ bootstrap.php   └ swoft ౎౓ಡΈࠐ·ΕΔ ઃఆϑΝΠϧ ˞FOW͕༏ઌ CFBOੜ੒࣌ʹಡΈࠐ·ΕΔ ϑΝΠϧ  4XPGU
  17. 4XPGUͷϑΥϧμߏ੒ ࠷খݶ Project ├ app         │ ├ Controllers │ │ └ BooksController.php │ └

    Models │   └ Entity │    └ Books.php ├ config │ ├ beans │ │ └ base.php │ └ properties │   ├ app.php │   └ db.php ├ public ├ runtime │ ├ logs │ ├ uploadfiles │ └ sessions ├ resources │ └ views │   └ books │     └ view.php └ bin   ├ bootstrap.php   └ swoft ੩తϑΝΠϧஔ͖৔ DTTɺKT  4XPGU
  18. 4XPGUͷϑΥϧμߏ੒ ࠷খݶ Project ├ app         │ ├ Controllers │ │ └ BooksController.php │ └

    Models │   └ Entity │    └ Books.php ├ config │ ├ beans │ │ └ base.php │ └ properties │   ├ app.php │   └ db.php ├ public ├ runtime │ ├ logs │ ├ uploadfiles │ └ sessions ├ resources │ └ views │   └ books │     └ view.php └ bin   ├ bootstrap.php   └ swoft Ұ࣌ϑΝΠϧஔ͖৔  4XPGU
  19. 4XPGUͷϑΥϧμߏ੒ ࠷খݶ Project ├ app         │ ├ Controllers │ │ └ BooksController.php │ └

    Models │   └ Entity │    └ Books.php ├ config │ ├ beans │ │ └ base.php │ └ properties │   ├ app.php │   └ db.php ├ public ├ runtime │ ├ logs │ ├ uploadfiles │ └ sessions ├ resources │ └ views │   └ books │     └ view.php └ bin   ├ bootstrap.php   └ swoft UFNQMBUFϑΝΠϧ  4XPGU
  20. 4XPGUͷϑΥϧμߏ੒ ࠷খݶ Project ├ app         │ ├ Controllers │ │ └ BooksController.php │ └

    Models │   └ Entity │    └ Books.php ├ config │ ├ beans │ │ └ base.php │ └ properties │   ├ app.php │   └ db.php ├ public ├ runtime │ ├ logs │ ├ uploadfiles │ └ sessions ├ resources │ └ views │   └ books │     └ view.php └ bin   ├ bootstrap.php   └ swoft ىಈ༻ϑΝΠϧ  4XPGU
  21.  ىಈ  -BSBWFM4XPPMF $ php artisan swoole:http start ॳظઃఆͩͱ൪ϙʔτͰ଴ͪड͚·͢

     OHJOYͷઃఆ proxy_pass http://127.0.0.1:1215 QSPYZ@QBTTͰઃఆ͠·͢ https://github.com/swooletw/laravel-swoole/wiki
  22. %FGBVMU 4MJN &BTZ4XPPMF W &BTZ4XPPMF W 4XPGU -BSBWFM -BSBWFM 4XPPMF

    ճ໨       ̎ճ໨       ճ໨       ճ໨       ̑ճ໨       ฏۉ       ˞ϩδοΫมߋͳ͠ͷঢ়ଶ 1)1 4XPPMF
  23. %FGBVMU 4MJN &BTZ4XPPMF W &BTZ4XPPMF W 4XPGU -BSBWFM -BSBWFM 4XPPMF

    ճ໨       ̎ճ໨       ճ໨       ճ໨       ̑ճ໨       ฏۉ       ˞ϩδοΫมߋͳ͠ͷঢ়ଶ 1)1 4XPPMF ϑϨʔϜϫʔΫͷ ҧ͍͸ޡࠩͰ͢ʂ &BTZ4XPPMF W ͷ࣮૷ɿ 4XPGUͷ࣮૷ɿ https://github.com/shirai-suguru/isucon8-swoft https://github.com/shirai-suguru/isucon8-easyswoole &BTZ4XPPMF W ͷ࣮૷ɿ https://github.com/shirai-suguru/isucon8-easyswoole-v3 -BSBWFMͷ࣮૷ɿ https://github.com/shirai-suguru/isucon8-laravel -BSBWFM4XPPMFͷ࣮૷ɿ https://github.com/shirai-suguru/isucon8-laravel-swoole