SERVICE CALLS
The email takes 3s.
So does your API.
SAME WORK. DIFFERENT WAITER.
Your API needs a slow service. The only question is who waits for it.
DIRECT CALL YOU WAIT
API
waiting
EMAIL
3 seconds
The connection stays open, so your caller waits for the whole job.
QUEUE THE WORKER WAITS
API
free now
QUEUE
holds it
WORKER
its own rate
The caller is free at once, but it no longer has the answer.
DIRECT CALL — you wait for it.
You get the answer.
QUEUE — you don't wait for it.
You don't get the answer.
The email takes 3s.
So does your API.
You'll want this one
on your slow endpoint.