italia / developers-italia-api

API for the developers.italia.it public software collection
https://api.developers.italia.it
GNU Affero General Public License v3.0
12 stars 7 forks source link

Check for performance in production #162

Open bfabio opened 2 years ago

bfabio commented 2 years ago

Local deploy is 3 orders of magnitude faster than production. Some slowdown is obviously to be expected cause of the network + TLS + ingress + database on another network, but that seems excessive.

Check if there are any major bottlenecks in production or any low hanging fruits we can improve.

Local benchmark

❯ ab -n 10000 http://localhost:3000/v1/logs This is ApacheBench, Version 2.3 <$Revision: 1901567 $> 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 1000 requests Completed 2000 requests Completed 3000 requests Completed 4000 requests Completed 5000 requests Completed 6000 requests Completed 7000 requests Completed 8000 requests Completed 9000 requests Completed 10000 requests Finished 10000 requests

Server Software:
Server Hostname: localhost Server Port: 3000

Document Path: /v1/logs Document Length: 11395 bytes

Concurrency Level: 1 Time taken for tests: 0.569 seconds Complete requests: 10000 Failed requests: 0 Total transferred: 115730000 bytes HTML transferred: 113950000 bytes Requests per second: 17579.85 [#/sec] (mean) Time per request: 0.057 [ms] (mean) Time per request: 0.057 [ms] (mean, across all concurrent requests) Transfer rate: 198683.23 [Kbytes/sec] received

Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.0 0 0 Processing: 0 0 0.0 0 0 Waiting: 0 0 0.0 0 0 Total: 0 0 0.0 0 0

Percentage of the requests served within a certain time (ms) 50% 0 66% 0 75% 0 80% 0 90% 0 95% 0 98% 0 99% 0 100% 0 (longest request)

Production

❯ ab -n 100 https://api.developers.italia.it/v1/logs This is ApacheBench, Version 2.3 <$Revision: 1901567 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking api.developers.italia.it (be patient).....done

Server Software: nginx/1.17.7 Server Hostname: api.developers.italia.it Server Port: 443 SSL/TLS Protocol: TLSv1.2,ECDHE-RSA-AES128-GCM-SHA256,2048,128 Server Temp Key: X25519 253 bits TLS Server Name: api.developers.italia.it

Document Path: /v1/logs Document Length: 9047 bytes

Concurrency Level: 1 Time taken for tests: 14.848 seconds Complete requests: 100 Failed requests: 0 Total transferred: 962237 bytes HTML transferred: 904700 bytes Requests per second: 6.73 [#/sec] (mean) Time per request: 148.485 [ms] (mean) Time per request: 148.485 [ms] (mean, across all concurrent requests) Transfer rate: 63.28 [Kbytes/sec] received

Connection Times (ms) min mean[+/-sd] median max Connect: 100 111 6.9 110 142 Processing: 31 37 2.9 37 53 Waiting: 30 36 2.9 35 52 Total: 131 148 9.2 147 195

Percentage of the requests served within a certain time (ms) 50% 147 66% 152 75% 155 80% 155 90% 159 95% 162 98% 168 99% 195 100% 195 (longest request)