Re: Surprising threading issue

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Sure, I'd be happy to. Basically, in a web farm, there are multiple machines executing your code. Each machine runs independently of the others, unless you make them aware of each other, which is rarely done. So, if you write code to limit your use of a remote web service such that the code relies on timing in a single process and that process is executing on multiple machines, you end up circumventing the logic. If you farm the application on 2 machines, you will hit the web service twice as much because they both will be running independently of each other. A web garden is a way to have IIS instantiate multiple processes to service your application, thus exposing the same situation without the need for multiple servers. To configure this, set the Max Worker Processes setting for the application pool for your site.

Clearly, the next question is how to manage this. You need to centralize something. Typically, a web application has a central database, so that is a natural start. When you make a request to the remote web server, you can record the fact that the request was made and include logic in your class to check the database before it makes a call to see if it can and if not, how long it is going to have to wait. The most straight forward design would be to create a table that will have a row per request that is to be made. Each attempt to make a request does:

1. Get the row with the highest request date/time
2. Calculate when the next allowed request date/time is (previous highest request date/time plus minimum request interval, if in the past, use current date/time)
3. Wait until the calculated next allowed request date/time arrives
4. Make the request

Of course, if your site gets overloaded, you probably want to put in some throttling logic so that if there are so many outstanding requests that it is unreasonable to expect completion any time soon (the calculated next allowed request Date/Time) is too far off in the future, just tell the user the site is too busy or something.

Two other options are to create a Windows service and using remoting to centralize access to the remote web service or create a web service that is not load balanced that does the same thing. Both of these options create single points of failure in the architecture, unless you load balance them using the same mechanism as before, so they do not make the entire solution any more robust in my opinion.

I hope this helps and is in a more "layman" language.

Regards,
Dan Ruehle

"GeezerButler" <kurtrips@xxxxxxxxx> wrote in message news:ca1e98f1-0eb8-4f50-ae4b-e2a201c4b730@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Dec 29, 10:24 am, "Dan Ruehle" <d...@xxxxxxxxxxxxx> wrote:
All of this will work, but I think you are overlooking something. If you
set your Application Pool to a web garden of 2 or more processes or ever web
farm your application, using singleton or static member or whatever will not
help. You will need to serialize your use of the web service via a database
or singleton back end Windows service or web service. That may not be in
the plan now, but it will be a huge design change if required in the future.

Thanks for bringing that up however unfortunately I don't understand
most of it :(
Right now my app is on a single machine but going forward I'm going to
upgrade to this. http://www.tsohost.co.uk/clustered-hosting.php
So, does clustered hosting have something to do with what you
mentioned above?
If it does, can you elaborate in a little more layman language?

.



Relevant Pages

  • Re: Asynchronous Web Service Call
    ... I think I understand your request so here goes.... ... How is the request handled from a consumer perpective? ... stage later when the web service process is complete, ... The background of my question adresses server to ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Re: An existing connection was forcibly closed by the remote host
    ... Within my web service proxy class I overrode the GetWebRequestmethod and modified it as shown below. ... HttpWebRequest request = base.GetWebRequestas ... If the size of the request message I was using is greater than the size of the packets the host could receive and the host is configured receive chunked messages then I guess I can assume when we sent a message larger than the packet size without sending it chunked their server terminated the session because it was waiting for another TCP message??? ... at System.Net.Sockets.NetworkStream.Read(Bytebuffer, Int32 offset, Int32 size) ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Re: Have thread end if not finished in X seconds
    ... As we have grown we needed real time over the internet validation--the perfect way to do this is with a web service and new systems are using the web service fine. ... the old systems are only able to support real time validation via TCP/IP requests. ... This TCP/IP server has a main sub that listens for TCP/IP requests and when it hears one it launches a thread to answer and handle that request. ... The main thread will wake up, and from there we can kill the worker thread in the main thread. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Redirect results in lost soap envelope. Changes method from POST to GET
    ... I created a web site, site A, that redirects to another web site, site ... where a simple web service is hosted. ... POST 401 text/html http://siteB/redirect_test/service.asmx ... If the 301 status code is received in response to a request other than ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: Accessing a Web Service using a Query String
    ... basically a query string that has the asmx address for the page where the ... Accessing a Web Service using a Query String ... > May be you should add the HttpGet request protocol for the Web services ... An unhandled exception occurred during the execution of the ...
    (microsoft.public.dotnet.framework.webservices)