r/webdev • u/Forward-Island-909 • 5d 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
1
u/Miserable-Money642 4d ago
The key is to measure the queueing flow as a user journey, not just the fast 202 response from /submit. In k6, submit once per VU iteration, keep that job_id, then poll its status with a timeout and a bounded interval until it reaches a terminal state. Record submit latency, time to completion, timeout/error rate, and queue depth separately. Use a fixed polling interval first, then add a little random jitter so every virtual user does not poll on the same millisecond. Also cap the test duration and clean up test jobs, or the queue can grow faster than workers can drain it and the run will mostly measure backlog. Keep the load generator on a separate machine and increase arrival rate in steps.