Context: From my javascript web UI, I launch a long-running (several minutes) operation that is conducted on the .NET2.0 backend. The call returns immediately with operation ID while the long-running operation run parallel. The operations are not CPU intensive, but conduct slow network calls. Once the operation is completed, I want to see the results in the web UI.
Question: How can I notify the client when the job is done?
Options I have considered:
Option 1: I launch the long-running operation asynchronously directly from JS and I expect the return value to be the endresult instead of an operation ID. My AJAX library takes care of everything, and life looks very easy and neat. The problem is that on the server side the thread is a ThreadPool thread which I now lock up for several minutes. You do not need too many long-running parallel requests to cause the ThreadPool to starve and bring the entire server to it knees even if there is sufficient processing power.
Option 2: With the operation ID, I start to poll the server if the operation is completed. However, this is a denial of service attack against my own server. Furthermore, there must be fair ajax solution to it. This is not a unique problem.