Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Best way to run a long process in ASP

We have a process that can take 10 or 15 minutes. We are trying to figure
out the best way to call it from ASP. Currently we are calling a DLL from
ASP and the DLL runs the process, but we are having problems when it takes a
really long time. What is the best way to do something like this so we can
provide feedback to the user while it processes?

Thanks,
Dennis
[395 byte] By [Dennis Bronstein] at [2007-11-9 17:49:01]
# 1 Re: Best way to run a long process in ASP
Dennis Bronstein wrote:
> We have a process that can take 10 or 15 minutes. We are trying to figure
> out the best way to call it from ASP. Currently we are calling a DLL from
> ASP and the DLL runs the process, but we are having problems when it takes a
> really long time. What is the best way to do something like this so we can
> provide feedback to the user while it processes?
>
> Thanks,
> Dennis
>
>
This may be too simplistic but have you tried:

Call Response.Write("Processing please wait...")
Call Response.Flush

' Do your dll processing

Call Response.Write("Here is your data?")
solex at 2007-11-11 23:17:21 >
# 2 Re: Best way to run a long process in ASP
The problem is that when the DLL runs a really long time, it starts over as
soon as it's finished, like the ASP page is being refreshed and calling it
again. It doesn't restart at a specific time interval, just right when it
finishes. But I can run the DLL for the same data from a VB app and it
works just fine, so the problem is definitely on the ASP/web side.

Thanks,
Dennis

"solex" <solex@nowhere.com> wrote in message
news:3e66766e$1@tnews.web.dev-archive.com...
> Dennis Bronstein wrote:
> > We have a process that can take 10 or 15 minutes. We are trying to
figure
> > out the best way to call it from ASP. Currently we are calling a DLL
from
> > ASP and the DLL runs the process, but we are having problems when it
takes a
> > really long time. What is the best way to do something like this so we
can
> > provide feedback to the user while it processes?
> >
> > Thanks,
> > Dennis
> >
> >
> This may be too simplistic but have you tried:
>
>
> Call Response.Write("Processing please wait...")
> Call Response.Flush
>
> ' Do your dll processing
>
> Call Response.Write("Here is your data?")
>
Dennis Bronstein at 2007-11-11 23:18:18 >
# 3 Re: Best way to run a long process in ASP
Dennis Bronstein wrote:
> The problem is that when the DLL runs a really long time, it starts over as
> soon as it's finished, like the ASP page is being refreshed and calling it
> again. It doesn't restart at a specific time interval, just right when it
> finishes. But I can run the DLL for the same data from a VB app and it
> works just fine, so the problem is definitely on the ASP/web side.

Dennis,

I cannot point to the problem but I can only surmise that there is a
timeout period for object invocations and your DLL had reached the
timeout period

If there is nothing you could do about the lenght of time (meaning that
you have optimized it the best you can) then I suggest that you run this
process asynchronously and that you email the results to the user. In
my opinion a 10-15 minute wait for a web-application is unreasonable.

Dan
solex at 2007-11-11 23:19:21 >
# 4 Re: Best way to run a long process in ASP
Dan, that's not an acceptable solution to the users. They don't mind
waiting for the processing to finish, but they want to stay within the
application.

Dennis

"solex" <solex@nowhere.com> wrote in message
news:3e676dae$1@tnews.web.dev-archive.com...
> Dennis Bronstein wrote:
> > The problem is that when the DLL runs a really long time, it starts over
as
> > soon as it's finished, like the ASP page is being refreshed and calling
it
> > again. It doesn't restart at a specific time interval, just right when
it
> > finishes. But I can run the DLL for the same data from a VB app and it
> > works just fine, so the problem is definitely on the ASP/web side.
>
> Dennis,
>
> I cannot point to the problem but I can only surmise that there is a
> timeout period for object invocations and your DLL had reached the
> timeout period
>
> If there is nothing you could do about the lenght of time (meaning that
> you have optimized it the best you can) then I suggest that you run this
> process asynchronously and that you email the results to the user. In
> my opinion a 10-15 minute wait for a web-application is unreasonable.
>
> Dan
>
>
Dennis Bronstein at 2007-11-11 23:20:22 >
# 5 Re: Best way to run a long process in ASP
Dennis Bronstein wrote:
> Dan, that's not an acceptable solution to the users. They don't mind
> waiting

What does the DLL do and has it been optimized?
solex at 2007-11-11 23:21:21 >
# 6 Re: Best way to run a long process in ASP
It uploads a text file with addresses, calls an external web service to
validate each one, and then writes the validated addresses to another text
file. It runs into problems when it hits about 20,000 addresses. It has
been fully optimized, the problem is that it has to make the call for each
address separately, so that's 20,000 calls to the web service.

"solex" <solex@nowhere.com> wrote in message
news:3e67b9fe$1@tnews.web.dev-archive.com...
> Dennis Bronstein wrote:
> > Dan, that's not an acceptable solution to the users. They don't mind
> > waiting
>
> What does the DLL do and has it been optimized?
>
Dennis Bronstein at 2007-11-11 23:22:25 >
# 7 Re: Best way to run a long process in ASP
Dennis Bronstein wrote:
> It uploads a text file with addresses, calls an external web service to
> validate each one, and then writes the validated addresses to another text
> file. It runs into problems when it hits about 20,000 addresses. It has
> been fully optimized, the problem is that it has to make the call for each
> address separately, so that's 20,000 calls to the web service.
>
Dennis,

I'm sorry that I cannot give you an answer to your question but can only
make a suggestion. Change the Web Service (if possible) to have
mulitple interfaces, the first one would be the one you currently use
which validates individual addresses, the second interface would take a
well-formatted stream that would validated the batch and send back a
formatted stream.

Good Luck!

Dan
solex at 2007-11-11 23:23:25 >
# 8 Re: Best way to run a long process in ASP
Dan, it's a third-party service we have no control over. When he have more
money, we are going to upgrade to their higher-end service that does batch
validation, but that is probably 3 months away. So we're stuck for now.

Thanks for your help,

Dennis

"solex" <solex@nowhere.com> wrote in message
news:3e68a7fe$1@tnews.web.dev-archive.com...
> Dennis Bronstein wrote:
> > It uploads a text file with addresses, calls an external web service to
> > validate each one, and then writes the validated addresses to another
text
> > file. It runs into problems when it hits about 20,000 addresses. It has
> > been fully optimized, the problem is that it has to make the call for
each
> > address separately, so that's 20,000 calls to the web service.
> >
> Dennis,
>
> I'm sorry that I cannot give you an answer to your question but can only
> make a suggestion. Change the Web Service (if possible) to have
> mulitple interfaces, the first one would be the one you currently use
> which validates individual addresses, the second interface would take a
> well-formatted stream that would validated the batch and send back a
> formatted stream.
>
> Good Luck!
>
> Dan
>
Dennis Bronstein at 2007-11-11 23:24:28 >
# 9 Re: Best way to run a long process in ASP
One last suggestion...

Is it possible to validate the addreses in advance of the call thereby eliminating
the search on all 20,000 plus addresses? I guess my suggestion would be
to store a timestamp with the record stating the last time it has been "validated."
Have a scheduled task run every(insert time inverval here) to validate those
who have fallen "out of scope".

Eg.
Jane Doe 3/1/2003
John Smith 3/11/2003 New Entry Today
Bob Smith 3/2/2003

I have a process that runs every day to validate each address who is past
10 days old.

The process runs on the 11th at 1:00 am and finds Jane Doe: and the Web Service
Validates the Address for Jane Doe. The Application updates the date to
3/11/2003 from 3/1/2003.

If it finds any whose addresses aren't valid it processes them the same way
you would when found not valid.

Now when a user makes a request of the system on 3/12/2003 It only has to
process Bob Smith at the time of run, instead of Both Jane and Bob and John.

This concept requires that you have a "out of Scope" date for each record
you have.

Your code then would only need to manage those whose timestamps have gone
beyond the acceptable alloted time.

Even if customers accept a 10-15 minute wait: shouldn't we do something to
prevent it?

Regards,
Q*bert

"Dennis Bronstein" <dbronstein@yahoo.com> wrote:
>Dan, it's a third-party service we have no control over. When he have more
>money, we are going to upgrade to their higher-end service that does batch
>validation, but that is probably 3 months away. So we're stuck for now.
>
>Thanks for your help,
>
>Dennis
>
>
>"solex" <solex@nowhere.com> wrote in message
>news:3e68a7fe$1@tnews.web.dev-archive.com...
>> Dennis Bronstein wrote:
>> > It uploads a text file with addresses, calls an external web service
to
>> > validate each one, and then writes the validated addresses to another
>text
>> > file. It runs into problems when it hits about 20,000 addresses. It
has
>> > been fully optimized, the problem is that it has to make the call for
>each
>> > address separately, so that's 20,000 calls to the web service.
>> >
>> Dennis,
>>
>> I'm sorry that I cannot give you an answer to your question but can only
>> make a suggestion. Change the Web Service (if possible) to have
>> mulitple interfaces, the first one would be the one you currently use
>> which validates individual addresses, the second interface would take
a
>> well-formatted stream that would validated the batch and send back a
>> formatted stream.
>>
>> Good Luck!
>>
>> Dan
>>
>
>
Q*bert at 2007-11-11 23:25:31 >
# 10 Re: Best way to run a long process in ASP
The addresses are in files the users upload. So there is no way to stamp
them or validate them on a scheduled process. The user selects their file
to upload, the addresses are validated, and the validated ones are written
out to a new file, and the "bad" ones that can't be validated are writted to
a separate file.

Of course we want to prevent a 10-15 minute wait, but as of right now, there
isn't any way around validating each address individually.

Dennis

"Q*bert" <luke_davis_76@hotmail.com> wrote in message
news:3e6e1cc1@tnews.web.dev-archive.com...
>
> One last suggestion...
>
> Is it possible to validate the addreses in advance of the call thereby
eliminating
> the search on all 20,000 plus addresses? I guess my suggestion would be
> to store a timestamp with the record stating the last time it has been
"validated."
> Have a scheduled task run every(insert time inverval here) to validate
those
> who have fallen "out of scope".
>
> Eg.
> Jane Doe 3/1/2003
> John Smith 3/11/2003 New Entry Today
> Bob Smith 3/2/2003
>
> I have a process that runs every day to validate each address who is past
> 10 days old.
>
> The process runs on the 11th at 1:00 am and finds Jane Doe: and the Web
Service
> Validates the Address for Jane Doe. The Application updates the date to
> 3/11/2003 from 3/1/2003.
>
> If it finds any whose addresses aren't valid it processes them the same
way
> you would when found not valid.
>
> Now when a user makes a request of the system on 3/12/2003 It only has to
> process Bob Smith at the time of run, instead of Both Jane and Bob and
John.
>
>
> This concept requires that you have a "out of Scope" date for each record
> you have.
>
>
> Your code then would only need to manage those whose timestamps have gone
> beyond the acceptable alloted time.
>
> Even if customers accept a 10-15 minute wait: shouldn't we do something to
> prevent it?
>
>
> Regards,
> Q*bert
>
> "Dennis Bronstein" <dbronstein@yahoo.com> wrote:
> >Dan, it's a third-party service we have no control over. When he have
more
> >money, we are going to upgrade to their higher-end service that does
batch
> >validation, but that is probably 3 months away. So we're stuck for now.
> >
> >Thanks for your help,
> >
> >Dennis
> >
> >
> >"solex" <solex@nowhere.com> wrote in message
> >news:3e68a7fe$1@tnews.web.dev-archive.com...
> >> Dennis Bronstein wrote:
> >> > It uploads a text file with addresses, calls an external web service
> to
> >> > validate each one, and then writes the validated addresses to another
> >text
> >> > file. It runs into problems when it hits about 20,000 addresses. It
> has
> >> > been fully optimized, the problem is that it has to make the call for
> >each
> >> > address separately, so that's 20,000 calls to the web service.
> >> >
> >> Dennis,
> >>
> >> I'm sorry that I cannot give you an answer to your question but can
only
> >> make a suggestion. Change the Web Service (if possible) to have
> >> mulitple interfaces, the first one would be the one you currently use
> >> which validates individual addresses, the second interface would take
> a
> >> well-formatted stream that would validated the batch and send back a
> >> formatted stream.
> >>
> >> Good Luck!
> >>
> >> Dan
> >>
> >
> >
>
Dennis Bronstein at 2007-11-11 23:26:27 >
# 11 Re: Best way to run a long process in ASP
What would I do:
- I would make a service that gets requests from the Web Server through Message
Queue or even database
- The ASP page uploads the file (if I understood right) - this means seconds
or something like that - and then order the service to run the dll
- the service informs the asp that it executed the task, or the status of
the job, through Message Queue or database
- one ASP page with autorefresh checks the status of the job
So, you can assign lower priority to the service and it is run in background
and stuff like that

"Dennis Bronstein" <dbronstein@yahoo.com> wrote:
>We have a process that can take 10 or 15 minutes. We are trying to figure
>out the best way to call it from ASP. Currently we are calling a DLL from
>ASP and the DLL runs the process, but we are having problems when it takes
a
>really long time. What is the best way to do something like this so we
can
>provide feedback to the user while it processes?
>
>Thanks,
>Dennis
>
>
Marian Olteanu at 2007-11-11 23:27:30 >
# 12 Re: Best way to run a long process in ASP
My suggestion:
1. Use the ASP app to start the separate app, that actually does something.
2. Return to the client asap, and have there a web page with auto-refresh
on, like every 5 or 10 secs.
3. Make the worker app to write status info for example to a file
4. Display the status info in the auto-refreshed page.
5. When status is ready, return a page w/o auto-refresh

tr
tr at 2007-11-11 23:28:29 >
# 13 Re: Best way to run a long process in ASP
I've handled this in the past with a similar process. Here's how I did it
(Note: this has only been tested in IE):

First, at the top of the page:

<%
Response.Buffer = False
Server.ScriptTimeout = 99999
%>
<html>
<head>
<script language="JavaScript">
function setStatus(sMsg){
document.all.status.innerText = sMsg;
}
function hideStatus(sMsg){
document.all.status.style.display='none';
}
</script>
<body onload="hideStatus()">
<div id="status">Please be patient...0% complete</div>
<%
'''' next create the component & start the long process
Dim objComponent

set objComponent = server.CreateObject("your.object")

objComponent.Start

%>
<!-- display results -->
</body>
</html>

Now, in the component:

Private m_SC as ScriptingContext

Public Sub OnStartPage(objSC as ScriptingContext)
'''' this is called when Server.CreateObject is called
'''' so we can get a reference to the ScriptingContext
'''' (non MTS environment)
Set m_SC = objSC
End Sub
Public Sub Start()
Dim i as Integer, iCount as Integer

For i = 1 to iCount
SetStatus i / iCount
next i

End Sub
Private Sub SetStatus(sinPercent as Single)
Dim sMsg as String
Static sLastMsg As String

sMsg = "Please be patient..." & format(sinPercent, "0%") & " complete"

''''this will prevent updating the status if the percent complete
'''' is the same.
if sMsg <> sLastMsg then
sLastMsg = sMsg

m_SC.Response.Write "<script language='JavaScript'>setStatus('" &
sMsg & "');</script>" & vbCrLf
end if
End Sub
Private Sub Class_Terminate()
Set m_SC = Nothing
End Sub

Basically it works by writing a line to the web page that executes some JS
to update a <DIV> element. I also used an animated gif that simulated a
progress bar.

Hope this helps,
Mike

(take off the underscores to e-mail me)

"Dennis Bronstein" <dbronstein@yahoo.com> wrote:
>It uploads a text file with addresses, calls an external web service to
>validate each one, and then writes the validated addresses to another text
>file. It runs into problems when it hits about 20,000 addresses. It has
>been fully optimized, the problem is that it has to make the call for each
>address separately, so that's 20,000 calls to the web service.
>
>"solex" <solex@nowhere.com> wrote in message
>news:3e67b9fe$1@tnews.web.dev-archive.com...
>> Dennis Bronstein wrote:
>> > Dan, that's not an acceptable solution to the users. They don't mind
>> > waiting
>>
>> What does the DLL do and has it been optimized?
>>
>
>
Mike at 2007-11-11 23:29:31 >
# 14 Re: Best way to run a long process in ASP
Dennis,
This definately seems like an ASP timeout error,
look at the following article:
http://support.microsoft.com/default.aspx?scid=kb;en-us;268364

Also, you can control timeout better with MTS--since you are using a component,
use MTS to trap the error and validate that it is definately a timeout problem
and nothing else. Here is an article that explains this better.
http://support.microsoft.com/default.aspx?scid=kb;EN-US;182036

Good luck.
May at 2007-11-11 23:30:31 >