Local Remoting Performance
Introduction
I knew that using .NET Remoting would add some overhead compared to intra-process method calls. I ran a little experiment to see what the performance hit would be when using Remoting within the same computer.
Setup
I created a remotable object with some very simple methods. The methods take a single object as a parameter and either change a couple of properties on the object or try to change the object to a new instance. Some methods take the parameter objects by value and some are passed by reference.
I then created three flavors of parameter objects. The first only had two properties: a string and an int. The second object was a more complex object which had some properties which were instances of the first object and of itself. Finally, the third object ws even more complex, consisting of properties made of the two prior objects. The theory I was acting on was that serialization would be a big contributor to any overhead Remoting would add.
I ran two series of tests, one via Remoting, and one just calling the object directly. Each method was called 5000 times with each type of parameter object. The calls were timed to determine the average processing time per call.
Results
Not surpisingly, the meaningless methods take very little time to execute. Within a process (i.e. no Remoting) the methods take around .03 ms. The most complex object added only .01 ms to processing time.
Comparing those results to the processing times when using Remoting did reveal some overhead. Method calls using Remoting and the simple object added about .7 ms per call. The overhead increased to 2.3 ms with the most complicated parameter. Passing the parameters by ref or by value didn't make a notable difference.
Conclusion
As expected, Remoting adds some overhead, even without leaving a machine. The degree of overhead increases as the parameters to the remote methods become more complicated. On the whole, however, the overhead of local Remoting is minimal, probably less than a millisecond in common situations.
There are certainly some scenarios where local Remoting can be a good solution. Hopefully these numbers will help you evaluate when to use it.