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
The connection stays open, so your caller waits for the whole job.
QUEUE
THE WORKER WAITS
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.