200-901 Question 52
Single answerA developer is designing an API for a new web application. The application has real-time collaboration features where updates need to be pushed to clients immediately as they occur. Which API style is most appropriate for this use case?
- A
REST with a polling mechanism
- B
Synchronous RPC
- C
Asynchronous API using Webhooks or WebSockets
- D
REST with standard HTTP methods
Show answer and explanation
Correct answer: C
Explanation
Real-time collaboration features require a mechanism where updates are pushed to clients as they occur without delay. Asynchronous APIs, such as those using Webhooks or WebSockets, are specifically designed for such use cases as they allow the server to send updates to the client immediately. Other API styles, like REST with polling or synchronous RPC, are less efficient or inappropriate for real-time scenarios due to latency and dependency on client-initiated requests.
- A. Incorrect.
REST with a polling mechanism is not efficient for real-time updates because it relies on the client repeatedly sending requests to check for updates, which can introduce latency and unnecessary network overhead.
- B. Incorrect.
Synchronous RPC is not suitable for real-time updates because it requires the client to wait for the server's response, which does not align well with the need for immediate updates.
- C. Correct.
Asynchronous API using Webhooks or WebSockets is the best choice for real-time updates as it allows the server to push updates to the client immediately without the client needing to poll repeatedly.
- D. Incorrect.
REST with standard HTTP methods is a common API style but is not inherently optimized for real-time updates. It would still rely on mechanisms like polling to achieve similar functionality.