How to deal with time-consuming server operations?
-
Suppose I have a web application which accepts a small amount of data from the client (so the data transfer is not an issue), then performs some very lengthy operation (minutes or tens of minutes) on the server, and returns the result back to the user. My question is - what is the preferred method of dealing with long requests? If I use regular postback, the browser will wait for the response and time out prematurely. Increasing the timeout is not a solution, because I do not want the browser to get stuck and seem unresponsive for so long. One way I thought of is running the time-consuming operation in another thread. This way the server response is sent immediately, so there is no timeout problem. Then I use periodical page refresh to check if the thread finished its work - it displays either "Please wait" on each negative check or "Finished" with the results. The drawback of this approach is that the time intervals in which I check if the work is done are constant (say 10 secs), so even if the work happened to be very fast (finished immeditely), the user has to wait for at least 10 seconds before the first check requst is sent. Is there any way the server itself can inform when the operation is finished? Any help regarding this matter is appreciated, I suppose this must be a well-known issue so I'll be happy if you just point me the right way. H
-
Suppose I have a web application which accepts a small amount of data from the client (so the data transfer is not an issue), then performs some very lengthy operation (minutes or tens of minutes) on the server, and returns the result back to the user. My question is - what is the preferred method of dealing with long requests? If I use regular postback, the browser will wait for the response and time out prematurely. Increasing the timeout is not a solution, because I do not want the browser to get stuck and seem unresponsive for so long. One way I thought of is running the time-consuming operation in another thread. This way the server response is sent immediately, so there is no timeout problem. Then I use periodical page refresh to check if the thread finished its work - it displays either "Please wait" on each negative check or "Finished" with the results. The drawback of this approach is that the time intervals in which I check if the work is done are constant (say 10 secs), so even if the work happened to be very fast (finished immeditely), the user has to wait for at least 10 seconds before the first check requst is sent. Is there any way the server itself can inform when the operation is finished? Any help regarding this matter is appreciated, I suppose this must be a well-known issue so I'll be happy if you just point me the right way. H
This is the type of operation ajax was meant to handle. You can display some type of progress indicator on the page while waiting for the response with no need to continually refresh the page.
I know the language. I've read a book. - _Madmatt
-
Suppose I have a web application which accepts a small amount of data from the client (so the data transfer is not an issue), then performs some very lengthy operation (minutes or tens of minutes) on the server, and returns the result back to the user. My question is - what is the preferred method of dealing with long requests? If I use regular postback, the browser will wait for the response and time out prematurely. Increasing the timeout is not a solution, because I do not want the browser to get stuck and seem unresponsive for so long. One way I thought of is running the time-consuming operation in another thread. This way the server response is sent immediately, so there is no timeout problem. Then I use periodical page refresh to check if the thread finished its work - it displays either "Please wait" on each negative check or "Finished" with the results. The drawback of this approach is that the time intervals in which I check if the work is done are constant (say 10 secs), so even if the work happened to be very fast (finished immeditely), the user has to wait for at least 10 seconds before the first check requst is sent. Is there any way the server itself can inform when the operation is finished? Any help regarding this matter is appreciated, I suppose this must be a well-known issue so I'll be happy if you just point me the right way. H
-
Suppose I have a web application which accepts a small amount of data from the client (so the data transfer is not an issue), then performs some very lengthy operation (minutes or tens of minutes) on the server, and returns the result back to the user. My question is - what is the preferred method of dealing with long requests? If I use regular postback, the browser will wait for the response and time out prematurely. Increasing the timeout is not a solution, because I do not want the browser to get stuck and seem unresponsive for so long. One way I thought of is running the time-consuming operation in another thread. This way the server response is sent immediately, so there is no timeout problem. Then I use periodical page refresh to check if the thread finished its work - it displays either "Please wait" on each negative check or "Finished" with the results. The drawback of this approach is that the time intervals in which I check if the work is done are constant (say 10 secs), so even if the work happened to be very fast (finished immeditely), the user has to wait for at least 10 seconds before the first check requst is sent. Is there any way the server itself can inform when the operation is finished? Any help regarding this matter is appreciated, I suppose this must be a well-known issue so I'll be happy if you just point me the right way. H