Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to performance test an endpoint?

I changed some caching logic in an endpoint and I want to performance test it. The server is on Heroku. How can I test this endpoint? What tools are out there that I can use?

I know of ab apache tools. What else?

ab doesn't actually seem to hit the endpoint. It doesn't seem to make a real request when I make the request to localhost. Any ideas?

like image 710
Jwan622 Avatar asked Oct 25 '25 08:10

Jwan622


1 Answers

Where are you running ab? You can't direct it to hit localhost unless you're running it on the same host that terminates client connections to the API endpoint.

If you're looking for tools to performance test an API, I can recommend looking at these:

  • Wrk: https://github.com/wg/wrk - allows you to script your tests in Lua
  • the Grinder: http://grinder.sourceforge.net - allows you to script your tests in Python/Jython
  • k6: https://k6.io - allows you to script your tests in Javascript

Full disclosure: I'm involved in the k6 project. All the above are open source tools and they all allow you to write test cases in real code, which is something I think is very useful. If you don't want/need to write test case in real code, there are several other tools you can use:

  • Vegeta: https://github.com/tsenart/vegeta
  • Hey: https://github.com/rakyll/hey
  • Apachebench you already know

Then there are some tools that are more complex, more suitable for testing web sites than simple or automated API end point testing (in my opinion), like Jmeter, Gatling, Tsung. And some tools that are suitable for API testing but where, due to bad performance, the measurements are a bit off, like Artillery, Siege and Locust.

like image 64
Ragnar Avatar answered Oct 28 '25 04:10

Ragnar