Slow response time
Closed this issue · 4 comments
Describe the bug
I have done some comparaison between running nginx + fpm vs swoole with FostHtppCacheBundle.
on locale with fpm, I have response time never go over 18ms to serve a simple cached json result which is stored in a file on the disk.
On the other hand. for the same call on swoole it take 28ms minimum up to 40ms.
So fpm seem lot twice faster.
Do you know any tweek I can do to improve swoole response time?
Environment (please complete the following information):
- OS: Mac
- PHP Version: 7.3.13
- Symfony Version: 4.4
- Running in docker: No
- opcache: enabled
Could you please provide us more information, especially a swoole bundle configuration?
Also please try bellow configuration options:
swoole:
http_server:
running_mode: reactor
hmr: off
settings:
reactor_count: auto
worker_count: auto
with symfony production settings (APP_ENV=prod, APP_DEBUG=0)
On my laptop:
cpu: Intel(R) Core(TM) i7-5500U CPU @ 2.40GHz
ram: 8 GiB
linux kernel: 5.4.15-arch1-1
php: 7.4.2
swoole version: 4.4.12
Project: https://github.com/k911/swoole-bundle-symfony-demo/
Produces the following results:
APP_ENV=prod APP_DEBUG=0 ./bin/console swoole:server:run
[OK] Swoole HTTP Server started on http://0.0.0.0:9501
[OK] API Server started on http://0.0.0.0:9200
----------------- ------------------------------------------------------------
Configuration Values
----------------- ------------------------------------------------------------
env prod
debug false
running_mode reactor
worker_count 8
reactor_count 4
memory_limit 4 GiB
trusted_hosts 0.0.0.0, 127.0.0.1, localhost
trusted_proxies 127.0.0.1/8
public_dir /home/k911/Projects/k911/swoole-bundle-symfony-demo/public
----------------- ------------------------------------------------------------
// Quit the server with CONTROL-C.
Tool wrk
:
wrk -c100 -t4 -d10 http://localhost:9501
Running 10s test @ http://localhost:9501
4 threads and 100 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 19.95ms 17.03ms 141.61ms 63.67%
Req/Sec 1.40k 295.25 2.08k 59.50%
55723 requests in 10.02s, 14.56MB read
Requests/sec: 5558.53
Transfer/sec: 1.45MB
Tool siege
: (partial output)
HTTP/1.1 200 0.02 secs: 83 bytes ==> GET /
HTTP/1.1 200 0.01 secs: 83 bytes ==> GET /
HTTP/1.1 200 0.00 secs: 83 bytes ==> GET /
HTTP/1.1 200 0.02 secs: 83 bytes ==> GET /
HTTP/1.1 200 0.02 secs: 83 bytes ==> GET /
HTTP/1.1 200 0.02 secs: 83 bytes ==> GET /
HTTP/1.1 200 0.02 secs: 83 bytes ==> GET /
HTTP/1.1 200 0.00 secs: 83 bytes ==> GET /
HTTP/1.1 200 0.00 secs: 84 bytes ==> GET /
HTTP/1.1 200 0.00 secs: 83 bytes ==> GET /
HTTP/1.1 200 0.00 secs: 83 bytes ==> GET /
HTTP/1.1 200 0.01 secs: 82 bytes ==> GET /
HTTP/1.1 200 0.00 secs: 82 bytes ==> GET /
^C
Lifting the server siege...
Transactions: 3210 hits
Availability: 100.00 %
Elapsed time: 1.21 secs
Data transferred: 0.25 MB
Response time: 0.01 secs
Transaction rate: 2652.89 trans/sec
Throughput: 0.21 MB/sec
Concurrency: 24.31
Successful transactions: 3210
Failed transactions: 0
Longest transaction: 0.07
Shortest transaction: 0.00
Tool hey
:
hey -c 100 -cpus 4 -z 10s http://localhost:9501
Summary:
Total: 10.0237 secs
Slowest: 0.1913 secs
Fastest: 0.0008 secs
Average: 0.0231 secs
Requests/sec: 4313.5864
Response time histogram:
0.001 [1] |
0.020 [28874] |■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
0.039 [3558] |■■■■■
0.058 [4640] |■■■■■■
0.077 [4082] |■■■■■■
0.096 [1528] |■■
0.115 [377] |■
0.134 [100] |
0.153 [56] |
0.172 [14] |
0.191 [8] |
Latency distribution:
10% in 0.0016 secs
25% in 0.0037 secs
50% in 0.0115 secs
75% in 0.0389 secs
90% in 0.0651 secs
95% in 0.0765 secs
99% in 0.1003 secs
Details (average, fastest, slowest):
DNS+dialup: 0.0000 secs, 0.0008 secs, 0.1913 secs
DNS-lookup: 0.0000 secs, 0.0000 secs, 0.0295 secs
req write: 0.0000 secs, 0.0000 secs, 0.0201 secs
resp wait: 0.0229 secs, 0.0007 secs, 0.1912 secs
resp read: 0.0001 secs, 0.0000 secs, 0.0335 secs
Status code distribution:
[200] 43238 responses
hum using reactor config, FosHttpCache stoped working completely.
we are still investigating on our side.