Slim 4 - Performance Testing
source link: https://odan.github.io/2019/12/20/slim4-performance-testing.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Daniel's Dev Blog
Developer, Trainer, Open Source Contributor
Blog About me DonateSlim 4 - Performance Testing
20 Dec 2019
Apache Bench (ab) is a great tool to test the performance of your API.
The problem is that your first test might give this strange result:
$ ab -n 1 'http://localhost/my-slim-app'
> 5.008 seconds
Of course the loading time in the browser is extremely fast, but when testing the loading time with AB you should not get a loading time < 5 seconds.
Using the switch -k
(Use Keep-Alive) helps to solve the problem.
$ ab -n 1 -k 'http://localhost/my-slim-app'
> 0.100 seconds
There are two other options:
Add Connection: close
to the response, e.g.
$response = $response->withHeader('Connection', 'close');
Change the HTTP version to 1.0
, e.g.
$response = $response->withProtocolVersion('1.0');
Read more
© 2020 Daniel Opitz | Twitter
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK