r/webdev • • Oct 17 '26

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

Show parent comment

1

u/sanbamboo Oct 18 '26

On the callback_url question: k6 can't receive incoming requests. It only acts as a client, there's no built-in HTTP server, so it can't sit there waiting for your API to call it back.

Two ways around it:

  1. Point callback_url at a tiny receiver you control (a few lines of Express or FastAPI) that stores job_id + the time the callback arrived, and exposes a GET for it. k6 submits, then polls that receiver instead of your API, so your /status endpoint stays out of the measurement.
  2. Skip the callback for the load test: submit, then poll /status with a short sleep, and record the time from submit to "done" in a custom Trend metric (k6/metrics). You get end-to-end processing time per job next to the normal http_req_duration of /submit.

Option 2 is less work, option 1 is closer to how real clients will use it.