Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is synchronous communication in microservices?
Synchronous communication means one service sends a request and waits for the response before continuing. It's like making a phone call and waiting for the other person to answer before talking.
Click to reveal answer
beginner
What is asynchronous communication in microservices?
Asynchronous communication means one service sends a request and continues working without waiting for a response. It's like sending a letter or email and doing other things while waiting for a reply.
Click to reveal answer
intermediate
Name one advantage of synchronous communication.
An advantage is simplicity: the caller knows immediately if the request succeeded or failed, making error handling straightforward.
Click to reveal answer
intermediate
Name one advantage of asynchronous communication.
It improves system scalability and responsiveness because services don't wait and can handle many requests in parallel.
Click to reveal answer
beginner
Give a real-life example of synchronous and asynchronous communication.
Synchronous: Talking on the phone where you wait for a reply. Asynchronous: Sending a text message or email where you don't wait for an immediate response.
Click to reveal answer
In synchronous communication, what does the caller do after sending a request?
ASends multiple requests at once
BWaits for the response before continuing
CContinues working without waiting
DIgnores the response
✗ Incorrect
In synchronous communication, the caller waits for the response before moving on.
Which communication style is better for handling many requests at the same time?
ASynchronous
BNeither
CBoth are equally good
DAsynchronous
✗ Incorrect
Asynchronous communication allows handling many requests without waiting, improving scalability.
Which of these is a downside of synchronous communication?
ACaller must wait and can be blocked
BHard to know if request succeeded
CMessages can get lost easily
DRequires complex message queues
✗ Incorrect
Synchronous calls block the caller until a response arrives, which can slow down the system.
What is a common tool used for asynchronous communication in microservices?
AMessage queues like RabbitMQ or Kafka
BHTTP REST API
CDirect database calls
DSynchronous socket connections
✗ Incorrect
Message queues enable asynchronous communication by decoupling sender and receiver.
If a service needs an immediate answer to proceed, which communication style is preferred?
AAsynchronous
BEither works
CSynchronous
DNone
✗ Incorrect
Synchronous communication is preferred when the caller needs an immediate response.
Explain the difference between synchronous and asynchronous communication in microservices with simple examples.
Think about how you communicate with friends: sometimes you wait for an answer, sometimes you don't.
You got /4 concepts.
Describe one advantage and one disadvantage of synchronous communication in microservices.
Consider how waiting for a reply can help or slow you down.
You got /2 concepts.
Practice
(1/5)
1. Which statement best describes synchronous communication in microservices?
easy
A. The caller waits for the response before continuing.
B. The caller sends a request and continues without waiting.
C. The services communicate only through message queues.
D. The services never exchange data directly.
Solution
Step 1: Understand synchronous communication
Synchronous communication means the caller waits for the response before moving on.
Step 2: Compare options
The caller waits for the response before continuing. matches this definition exactly, while others describe asynchronous or unrelated concepts.
Final Answer:
The caller waits for the response before continuing. -> Option A
Quick Check:
Synchronous = Wait for reply [OK]
Hint: Synchronous means wait for reply before next step [OK]
Common Mistakes:
Confusing synchronous with asynchronous communication
Thinking synchronous means no waiting
Assuming message queues are always synchronous
2. Which of the following is the correct way to describe asynchronous communication in microservices?
easy
A. The caller blocks until the response is received.
B. The caller uses a direct function call to get the result.
C. The services must be on the same server.
D. The caller sends a request and processes the response later.
Solution
Step 1: Define asynchronous communication
Asynchronous means the caller sends a request and does not wait; it handles the response later.
Step 2: Evaluate options
The caller sends a request and processes the response later. correctly describes this behavior. Options A and D describe synchronous calls, and C is unrelated.
Final Answer:
The caller sends a request and processes the response later. -> Option D
Quick Check:
Asynchronous = Send and continue [OK]
Hint: Async means send request, handle reply later [OK]
Common Mistakes:
Mixing up blocking and non-blocking calls
Assuming async requires same server
Thinking async means no response
3. Consider this pseudocode for a microservice call:
response = callServiceSync(request)
print("Done")
What will be the output order?
medium
A. "Done" prints before the service responds.
B. "Done" prints after the service responds.
C. The code throws an error because of missing callback.
D. The code runs asynchronously without waiting.
Solution
Step 1: Analyze synchronous call behavior
The function callServiceSync waits for the service response before returning.
Step 2: Determine print timing
Since the call blocks, "Done" prints only after the response is received.
Final Answer:
"Done" prints after the service responds. -> Option B
Quick Check:
Synchronous call blocks, then prints [OK]
Hint: Sync calls block; print happens after response [OK]
But the system blocks until the response arrives. What is the likely mistake?
medium
A. print statement should be after waitForResponse().
B. sendRequestAsync() is actually synchronous.
C. Calling waitForResponse() immediately blocks the flow.
D. The request object is malformed.
Solution
Step 1: Understand asynchronous call flow
sendRequestAsync should not block, but waitForResponse() forces waiting.
Step 2: Identify blocking cause
Calling waitForResponse() immediately after sends blocks the flow, negating async benefits.
Final Answer:
Calling waitForResponse() immediately blocks the flow. -> Option C
Quick Check:
Immediate wait blocks async [OK]
Hint: Waiting right after async call blocks it [OK]
Common Mistakes:
Assuming async call is sync
Misplacing print statement
Blaming request format instead of flow
5. You design a microservice system where user requests must get immediate confirmation, but heavy processing can be delayed. Which communication pattern fits best?
hard
A. Use synchronous communication for confirmation and asynchronous for processing.
B. Use only synchronous communication for all tasks.
C. Use only asynchronous communication for all tasks.
D. Use synchronous communication for processing and asynchronous for confirmation.
Solution
Step 1: Analyze requirements
Immediate confirmation requires waiting for a quick response (synchronous).
Step 2: Handle heavy processing
Heavy tasks can be done later without blocking user, so asynchronous fits.
Step 3: Match communication patterns
Combining synchronous for confirmation and asynchronous for processing meets both needs efficiently.
Final Answer:
Use synchronous communication for confirmation and asynchronous for processing. -> Option A
Quick Check:
Immediate reply = sync, heavy work = async [OK]
Hint: Immediate reply sync, heavy work async combo [OK]