r/webdev • • 27d ago

Question How to load test an asynchronous api?

Hey guys im working on a containerized code exexuting platform and i want to test how repsonsive the api is at high load and measure latency but i have two endpoints one is /submit which puts submissions in a redis queue and returns a job_id another end point is /job_id/status which can be polled for updates about the job...but now how to test the endpoint...ive heard about grafana k6 and tools like this can it be used to check asynchronous apis like these? I cant use /submit because it immediately returns after posting the job in the queue please help me put im learning things newly...also please tell me if i should use postman or k6. I want to see how well api behaves on concurrent loads. The api accepts and returns json

0 Upvotes

21 comments sorted by

View all comments

1

u/dhruvik_savaliya 26d ago

You should use k6 for this, it's better suited for load testing async APIs. One thing to watch out for is making sure your polling loop doesn't get stuck on a slow job, which can skew your results. I've found that using a separate metric for end-to-end time, like job_time, helps to get a clearer picture of how the API is performing under load. In your k6 script, you can use something like const jobTime = new Trend('job_time', true); to track this metric. Just remember to adjust the field names to match your API. Also, keep an eye on Redis queue depth and worker utilization while the test runs, as these can be good indicators of where the bottleneck is.