Streamline ASMX Web Services with Multiple Long-Term Operations

I am writing an ASP.NET web service using C # where there is a DoLookup () function. For each call to the DoLookup () function, I need my code to execute two separate requests: one to another web service on the remote host, and the other to the local database. Both queries must complete before I can compile the results and return them as an answer to the DoLookup method. The problem I'm dealing with is that I want to make it as efficient as possible, both in terms of response time and resource usage on the web server. We expect up to several thousand requests per hour. Here's a rough C # -shaped overview of what I still have:

public class SomeService : System.Web.Services.WebService
{
    public SomeResponse DoLookup()
    {
        // Do the lookup at the remote web service and get the response 
        WebResponse wr = RemoteProvider.DoRemoteLookup();   

        // Do the lookup at the local database and get the response
        DBResponse dbr = DoDatabaseLookup();

        SomeResponse resp = new SomeResponse( wr, dbr);

        return resp;
    }
}

, . , DoRemoteLookup() (RemoteProvider BeginRemoteLookup/EndRemoteLookup) BeginExecuteNonQuery/EndExecuteNonQuery.

() : - , , ?

, , , (1 2 ), - , . . -, , , . , , - , , , , .

.

+3
4

AutoResetEvents, . AutoResetEvents.Set() .

WaitAll() . , .

, , Set() , . , , , -.

MSDN , AutoResetEvent.

+2

. - XML, - -.

:

. - XML - XML Windows Communication Foundation (WCF).


BTW, , , , ASP.NET . , .

+1

, -, , -

bool webLookupDone = false;
bool databaseLookupDone = false;

private void FinishedDBLookupCallBack()
{
    databaseLookupDone = true;
    if(webLookupDone)
    {
        FinishMethod();
    }
}

private void FinishedWebLookupCallBack()
{
    webLookupDone = true;
    if(databaseLookupDone)
    {
        FinishMethod();
    }
}
0

, , . , , .

, .

: . , .

, , , , , .. .

. , IO Threadpool , , , .net.

- . , ( 1-2 , ). 12 ( machine.config .) I.e. 12 ( ). , - , Begin , , , -, -, .

0
source

Source: https://habr.com/ru/post/1717383/


All Articles