Este PR utiliza a extensão Swoole do PHP para criar um web server com Async IO.
Todas as classes do código fonte foram convertidas para esta extensão. Trocou-se o APCU pelo Swoole\Table
.
Para os testes de estresse, utilizou-se o K6 e no script.js
removeu-se os comandos de sleep
.
running (1m00.0s), 00/10 VUs, 158483 complete and 0 interrupted iterations
default ✓ [ 100% ] 10 VUs 1m0s
data_received..................: 87 MB 1.4 MB/s
data_sent......................: 70 MB 1.2 MB/s
http_req_blocked...............: avg=4.09µs min=1.17µs med=2.5µs max=12.35ms p(90)=3.73µs p(95)=5.01µs
http_req_connecting............: avg=18ns min=0s med=0s max=2.61ms p(90)=0s p(95)=0s
http_req_duration..............: avg=1.11ms min=196.11µs med=952.22µs max=36.08ms p(90)=1.84ms p(95)=2.3ms
{ expected_response:true }...: avg=1.11ms min=196.11µs med=952.22µs max=36.08ms p(90)=1.84ms p(95)=2.3ms
http_req_failed................: 0.00% ✓ 0 ✗ 475449
http_req_receiving.............: avg=52.71µs min=11.37µs med=27.08µs max=28.18ms p(90)=46.36µs p(95)=89.06µs
http_req_sending...............: avg=21.55µs min=5.97µs med=13.65µs max=20.52ms p(90)=21.58µs p(95)=32.26µs
http_req_tls_handshaking.......: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
http_req_waiting...............: avg=1.04ms min=165.84µs med=892.72µs max=35.69ms p(90)=1.75ms p(95)=2.17ms
http_reqs......................: 475449 7923.704607/s
iteration_duration.............: avg=3.76ms min=964.14µs med=3.41ms max=41.52ms p(90)=5.43ms p(95)=6.6ms
iterations.....................: 158483 2641.234869/s
vus............................: 10 min=10 max=10
vus_max........................: 10 min=10 max=10
Efetuando-se um teste de carga de leitura com ab
:
$ ab -n100000 -c1000 http://localhost:8080/api/v1/growth/brz/ngdp_r/2002
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests
Server Software: swoole-http-server
Server Hostname: localhost
Server Port: 8080
Document Path: /api/v1/growth/brz/ngdp_r/2002
Document Length: 67 bytes
Concurrency Level: 1000
Time taken for tests: 14.574 seconds
Complete requests: 100000
Failed requests: 0
Total transferred: 22200000 bytes
HTML transferred: 6700000 bytes
Requests per second: 6861.30 [#/sec] (mean)
Time per request: 145.745 [ms] (mean)
Time per request: 0.146 [ms] (mean, across all concurrent requests)
Transfer rate: 1487.51 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 37 202.2 1 3051
Processing: 1 100 253.4 34 3064
Waiting: 1 96 253.1 30 3062
Total: 1 137 331.8 36 3298
Percentage of the requests served within a certain time (ms)
50% 36
66% 45
75% 53
80% 59
90% 108
95% 1058
98% 1088
99% 1249
100% 3298 (longest request)
Por fim, o tamanho da imagem Docker aumentou de 2.38MB
para 5.26MB
.