DevNet Associate (DEVASC) v1.0Software Development and DesignEasy
A developer is designing a new microservice that needs to notify other services in real-time about critical events, such as a new order being placed. Which mechanism is most appropriate for this scenario to ensure timely and efficient communication?
- AImplementing webhooks to push notifications
- BStoring events in a database for other services to query
- CUsing a daily batch file transfer
- DPolling a REST API endpoint every 5 seconds
Show answer & explanationAnswer & explanation
Correct answer: A. Implementing webhooks to push notifications
Webhooks provide a real-time, push-based notification mechanism, which is ideal for immediate event propagation. Other options are either pull-based, less timely, or not designed for real-time inter-service communication.
Why the other options are wrong
- B. While services could query the database, this is a pull mechanism and less efficient than push notifications for real-time scenarios.
- C. Batch file transfers are asynchronous and typically used for large data volumes, not real-time events.
- D. Polling is inefficient and introduces latency, not suitable for real-time updates.
Webhook
A webhook is an automated message sent from apps when an event occurs. It's an HTTP callback or HTTP push API, providing data to other applications in real-time.
- Real-time notification mechanism
- HTTP POST request to a specified URL
- Event-driven communication
- Reduces polling overhead
Memory trick: Webhooks push messages, ensuring everyone's in the loop instantly.