1. A developer needs to implement server-sent real-time notifications in a web application so that connected browser clients receive updates whenever a backend event occurs. The API must support two-way communication where the client can also send messages to the server. Which Amazon API Gateway API type is the CORRECT choice for this requirement?
- A. REST API, using long polling on a GET endpoint.
- B. HTTP API, using server-sent events (SSE) via chunked transfer encoding.
- C. WebSocket API, using routes and integration backends to handle connect, disconnect, and custom message frames.✓ Correct
- D. REST API with caching enabled to push cached responses to connected clients.
Explanation
API Gateway WebSocket APIs maintain persistent, stateful connections between clients and the server. They support two-way communication: clients can send messages to the server (via custom routes) and the server can push messages to connected clients using the @connections management API. This directly satisfies both requirements. Option A REST API long polling is a workaround where clients repeatedly re-issue requests; it is not true real-time push and adds significant overhead. Option B HTTP API SSE supports server-to-client push only (one-way); the client cannot send messages over the SSE connection itself. Option D API Gateway caching stores responses to reduce backend load; it has no mechanism to push data to clients.