Cook Computing

Migrating to Indigo from Remoting

November 6, 2003 Written by Charles Cook

Yosi Taguri has some notes on the Joe Long's PDC session WSV203 "Indigo": Connected Application Technology Roadmap. I was pleased to read the following:

crossprocess communication will be extremly fast in indigo.

because crossprocess remoting calls are slow right now compared to what you can achieve using COM and the project I am working on now makes heavy use of Remoting to connect code running in ASP.NET with the main application server. I guess LRPC/LPC will be used. LRPC (Lightweight Remote Procedure Call) is based the undocumented LPC (Local Procedure Call) protocol is used by COM for cross-process calls. Clemens Vasters describes how it achieves such high performance:

LRPC/LPC maps all marshaled data into a shared memory area and then tunnels the caller's active kernel thread into the callee's process space (!). There it picks up the marshaled data and dispatches it on the called object and takes the same way back. With that, LRPC can indeed complete a cross-process call within a single OS time slice (in practice, not only in theory), if the action is compact and doesn't involve anything that gives up the time slice directly (Overlapped I/O, WaitForSingle/MultipleObject, Sleep).

According to the slides for WSV203 there should be only a small cost for us to migrate to Indigo from Remoting. For example, server object code will look like this:


// using System.Runtime.Remoting;
using System.ServiceModel;

[RemoteObject] 	// new attribute
public class MyService : MarshalByRefObject
{
  public void Foo()
  {
  }
}

Hosting code will look like this (old code commented out):


// using System.Runtime.Remoting;
using System.ServiceModel;

public class Host
{
  public static void Main()
  {
    // RemotingConfiguration.Configure("Server.Config");
    ServiceManager manager = new ServiceManager("http://indigo-svr");
    manager.Services.Add("/MyService", typeof(MyService));

    Console.WriteLine("Host ready to process remote messages.");
    Console.ReadLine();
  }
}

And client code will look like this (old code commented out):


// using System.Runtime.Remoting;
using System.ServiceModel;

public class Client
{
  public static void Main()
  {
    // RemotingConfiguration.Configure("Client.Config");
    // MyService svc = new MyService();
    MyService svc = ServiceManager.CreateProxy<MyService>();

    Svc.Foo();
  }
}