A user can perform an action on our web app which takes anywhere from 100ms to 10 seconds, I wish to return a result to the browser immediately and then show the results to the user once the task has finished processing. The action is syncing data from a third party and is implemented as a class library (DLL).
Normally it's suggested to use a queue like RabbitMQ or MSMQ and have a worker which writes the results to a database which is polled by an AJAX request from the browser to check for updates.
However the aim is to reduce the latency so it's as close to running the task synchronously as possible while being able to handle spikes in processing the long running task without affecting the rest of the website.
How should the backend be architected? In my mind, the process would be: starting the task, running the task with minimal latency, notifying the end user the task is finished (ASAP) and finally displaying results in the browser.
Examples
Generating sitemaps with http://www.xml-sitemaps.com/ uses chunked transfer encoding to send a <script>
tag every second to call a Javascript function to update the page with the latest status.
Checking SSL certificates with https://www.ssllabs.com/ssltest/ seems to refresh the whole page with an updated status.