Web Garden and multithreading query

T

techie

I've got an ASP.NET application that runs Word macros after a user submits
it to the website. A web service written in C# does the work. Many users
can submit Word documents at any one time. However, the application only
processes 1 Word document at a time.

I had a problem during testing when several users submitted 10 documents
each at the same time. At a point (user1: 7 docs; user2: 4 docs; user3: 7
docs; user4: 5docs) the server reported the following error after clicking
'Validate': HTTP status code 504 - no response from remotes server. Server
responded after trying again 5 minutes later. However, despite the error
message emails were received for these documents.

My application adds to the thread pool like this:

// Call asynchronously method that does work that takes time
WaitCallback doWork = new WaitCallback( StartBackgroundService );

// Then return true if successfully started.
return ThreadPool.QueueUserWorkItem( doWork, allocateInfo );

I want to avoid the 'HTTP status code 504 - no response from remotes server'
error message. Therefore, I increased the Maximum number of worker
processes to 50. Then when I tested submitting documents one after the
other in quick succession, I found the number of worker threads increase to
50 on the webserver. I haven't yet got the users to test submitting many
documents at the same time yet.

From what I understand of a Web Garden is that it is a thread pool and the
threads share their workload out with one another. Does this increase the
availability of the website, i.e. avoid any timeout errors like above? If
the thread pool reaches its maximum size of 50 what happens when users
submit more documents? How is the thread pool maintained at 50? Is one
thread killed and another started or is one recycled automatically? I have
increased the timeout of threads to 300 minutes because some large Words
documents take a long time to process.

Basically my question is, does increasing the size of the Web Garden
increase the availability of a website for concurrent users? State is not
important for me because this site performs back-end processing. A front
end web site send the document to the back end site.
 
G

Guest

This sounds like a good opportunity to implement MSMQ to avoid these kinds of
problems.
 
A

Alvin Bruney - ASP.NET MVP

i'd go with that suggestion. you shouldn't increase the threadpool to 50.
That will cause resource contention IMO

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET
 
S

Scott Allen

I want to avoid the 'HTTP status code 504 - no response from remotes server'
error message. Therefore, I increased the Maximum number of worker
processes to 50. Then when I tested submitting documents one after the
other in quick succession, I found the number of worker threads increase to
50 on the webserver. I haven't yet got the users to test submitting many
documents at the same time yet.

You should only see as many worker processes as you have CPUs - I'm
not sure if you are talking about worker processes or worker threads.

From what I understand of a Web Garden is that it is a thread pool and the
threads share their workload out with one another.

No - webgardens are a way to dedicate a worker process to run on a
specific CPU in a multi-proc machine. The advantage is this: when the
operating system schedules a thread in the process to run, it will
execute on the same CPU it saw during it's last time slice and will
probably be able to use some cached data in the CPU.
Basically my question is, does increasing the size of the Web Garden
increase the availability of a website for concurrent users?

I think in your case I'd look for a queuing mechanism, as suggested by
others. Word automation is notoriously ugly for server side work.
 
T

techie

Scott Allen said:
You should only see as many worker processes as you have CPUs - I'm
not sure if you are talking about worker processes or worker threads.

I'm getting confused with worker threads. The webserver has 2 CPUs.
Therefore I've now set the Maximum number of worker processes to 2. There
is a noticeable improvement in performance from being at 1.

The webserver hosts 7 sites all of which share the same DefaultAppPool.
Should there be 7 different app pools, one for each site? Currently all 7
sites share the same app pool that now has 2 worker processes.
No - webgardens are a way to dedicate a worker process to run on a
specific CPU in a multi-proc machine. The advantage is this: when the
operating system schedules a thread in the process to run, it will
execute on the same CPU it saw during it's last time slice and will
probably be able to use some cached data in the CPU.


I think in your case I'd look for a queuing mechanism, as suggested by
others. Word automation is notoriously ugly for server side work.

In my case there isn't a need to use any other queuing mechanism such as
MSMQ. My application already processes submissions one at a time, i.e.
queuing is already implemented.
 
O

Ollie Riches

Also to add to everyone elses comments:

In general you should avoid creating threads in any asp.net or web service
application because this reduces the number of threads available to process
in coming requests,

You should try and avoid running an asp.net website on the same machine as
the web service it is using, why? - becuase they will both compete against
each other for system resources (threads, memory etc)

HTH

Ollie Riches
 
M

michaelcoleman72

Ollie - Limiting the number of threads created is a good thing, as it
may tax your system eventually... but creating asynch threads doesn't
take away from the thread pool used by the worker process. It is my
understanding they are from a differernt pool.

Regards
Coleman
 
T

techie

I haven't tried this suggestion yet.

I think I could use caching because the error is probably being caused by
too many simultaneous requests to the same web page. The webserver is
unable to respond to all concurrent requests at the same and hence the
timeout message. I'm a bit new to ASP.NET but I've read that you can
implement caching by adding the following line at the top of your .aspx
page:

<%OutputCache Duration="600" VaryByParam="*"%>

If I do this, does the server always serve the same page irrespective of the
Word file the user submits to the website? Ideally the server will cache a
number of versions of the same page, depending on my input, and the logic is
still executed each time. (My input is a MS Word file which is bound to
differ for every submission).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top