Search code examples
asynchronousdesign-patternsarchitectureweb-frontend

UI Design pattern / technology for monitoring when an async process finishes


My frontend kicks off an async process with an http POST.

By whatever means, (kafka, threading, database insert and another system monitoring the table), some process is completed after an unknown amount of time and finishes in some quantifiable way (you can make a http call and determine if its done or not).

Are there any design patterns/technologies for notifying the frontend without it having to make repeated requests to some service?


Solution

  • You can take a look on WebSockets, a bi-directional data channel that is generally used for real-time web applications.

    The way you can use would be straight-forward: when you make the HTTP Post request and the async process is started on the backend, you also open a websocket connection with the front-end, for that particular request. When the async process is finished, the backend will notify the front-end through the websocket.

    You can even use the same websocket connection to transport data for multiple requests (initiated by the same user), which is a kind of a multiplexing technique.

    If you need the overall system to be scalable, you should think about having a cluster of VMs that manage the websocket connections (fully separated from the backend of your application).