Test Swoole Coroutine feature
$ composer install
$ docker-compose up -d
Swoole Http Server runs with one worker only.
If you hit the server with '/?reg_num=
One Swoole server listens on port 8080
. It uses mongoDB to perform the slow query.
Hitting the server with:
http://127.0.0.1:8080/?reg_num=2
takes ~10s due to simulated slow queryhttp://127.0.0.1:8080/?reg_num=1
Without another active (and blocking) request it is fast, but
if a request with a slow query is active then this request is blocked until the other one is finishedSecond Swoole server listens on port 8081
. It uses PDO to perform the slow query.
There are two db backends available: Postgres and MySql
In the server-pdo.php
file you can set $useMySql = false;
to let the server use Postgres
instead of MySql.
Hitting the server with:
http://127.0.0.1:8081/?reg_num=2
takes ~10s due to simulated slow queryhttp://127.0.0.1:8081/?reg_num=1