Print Page | Close Window

slow Remote Procedure Call

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=928
Printed Date: 10-Jun-2026 at 8:47pm


Topic: slow Remote Procedure Call
Posted By: lars-erik
Subject: slow Remote Procedure Call
Date Posted: 03-Sep-2008 at 5:06am

The first time I am running a remote procedure call, it is really slow. It takes about a minute - but it always succeeds. Then subsequent calls are really fast (2 sec).

I notice that if I wait 15-20 minutes, and tries the RPC call again, it is slow again. I guess it has something to do with proxy or firewall, but I am completely clueless.
 
I am using:  InvokeServerMethod.
Maybe I should just use InvokeServerMethodAsync, and just assume that it succeeds.
Can anyone explain how to use the "pUserstate" argument of the method InvokeServerMethodAsync ?



Replies:
Posted By: davidklitzke
Date Posted: 03-Sep-2008 at 10:32am
Are you using Remoting or WCF?
 
Are you using a BOS?  If so, are using IIS, Windows Service, or Console Server?
 
Do all RPC calls exhibit this behavior, or is it just one or a few?
 
Here is some documentation on InvokeServerMethodAsync
 
Asynchronous version of RPC call (#467)
 

PersistenceManager now contains an overloaded InvokeServerMethodAsync method which allows for asynchronous invocation of a server-side method.  This method works similarly to the synchronous InvokeServerMethod, except that the method return data is available in the event arguments passed to the InvokeServerMethodCompleted event.  An outstanding request can be canceled using the CancelAsync method.

 

    private void MakeAsyncCall() {

      PersistenceManager pm = PersistenceManager.DefaultManager;

      // Setup completion handler

pm.InvokeServerMethodCompleted +=

new EventHandler<InvokeServerMethodCompletedEventArgs>(InvokeServerMethodCompletedHandler);

      // Make async call

      Guid myToken = Guid.NewGuid();

      pm.InvokeServerMethodAsync(new ServerRpcPersistenceDelegate(Order.GetNumberOfOrdersSlow), myToken,

         new DateTime(1995, 1, 1), new DateTime(1999, 1, 1));

    }

    private void InvokeServerMethodCompletedHandler(object sender, InvokeServerMethodCompletedEventArgs e) {

      Guid token = (Guid)e.UserState;

      if (!e.Cancelled) {

        MessageBox.Show("my async result = " + Convert.ToInt32(e.Result).ToString());

      }

    }

 

 There is also a Tech Tip which you might find relevant:

 

http://www.ideablade.com/techtip_Extract_Maximum_Data_Retrieval_Performance.htm - http://www.ideablade.com/techtip_Extract_Maximum_Data_Retrieval_Performance.htm

 



Posted By: lars-erik
Date Posted: 05-Sep-2008 at 12:42am

I found the cause.

My rpc-method "DirectoryExists" is very slow. All it does is to call System.IO.Directory.Exists .
I have now replaced it with a win32 call (findfirstfile) - and it runs fast.
Thanks for the description of Asynchronous version of RPC anyway.



Print Page | Close Window