Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

« Previous Version 7 Next »

Problem

  • Design APIs for a client app to respond quickly (100 ms or less), code running in a web-client (browser).

  • Manage the response latency : factors such as current load, network infra, size of a request payload, etc.

  • We prefer the owrk done by the frontend and not by the backend (which could be lon-running and done in seconds).

Solution

  • Use HTTP polling which is useful to client-side code :

    1. Make asynchronous call to the API;

    2. API responds synchronously as quickly as possible (http 202 - OK);

    3. Client can poll to check for the result : reponse holds a location reference pointing to an endpoint;

    4. API offloads processing to another component (message queue, …);

    5. API returns HTTP 200. Once the work is complete, endpoint can redirect to another resource URL.

image-20240822-192547.png

Asynchornous Request-Reply In Practice

API call with Azure Function which can listen to changes in Azure resources : decouple backend processing from a frontend host where backend processing needs to be asynchronous, but the frontend still needs a clear response.

  • No labels