Synchronous and asynchronous responses
12.11.2021 • Barbora Bačenková • Stories
We all do it sometimes, but usually, it doesn’t really help. It helps to know what is actually happening between a simple click on the screen and the response we want.
Do you click the button more than once?
There are two most common approaches:
SYNCHRONOUS
- popular for application developers - it's easier for them
- the response is in the same open connection as the request (only one API is needed)
- it's for getting data from the source system (GET method)
- even if the source system is overloaded it can reply in few seconds
Recommended when:
ASYNCHRONOUS
- the first API returns a unique ID directly after the request
- the second API returns the same ID with the calculated result
- more work for application developers
- storing data in the target system (PUT / POST methods)
- it can take longer to get an answer
- data duplicity is a potential risk
Recommended when:
Why this extra effort? Because a lot of users are not patient.
Everyone of us admits we did it at least once.
This extra effort is worth it - and speed is almost the same.
Previous Post
Middleware JWT authorization