Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6800429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:58:04+00:00 2026-05-26T18:58:04+00:00

according to this article , WCF with named pipes is the best choice for

  • 0

according to this article, WCF with named pipes is the best choice for IPC, and it is around 25 % faster than .Net Remoting.

I have the following code that compares WCF with named pipes with .Net Remoting:

[ServiceContract]
internal interface IRemote
{
    [OperationContract]
    string Hello(string name);
}

[ServiceBehavior]
internal class Remote : MarshalByRefObject, IRemote
{
    public string Hello(string name)
    {
        return string.Format("Hello, {0}!", name);
    }
}

class Program
{
    private const int Iterations = 5000;

    static void Main(string[] args)
    {
        TestWcf(Iterations);
        TestRemoting(Iterations);

        TestWcf(Iterations);
        TestRemoting(Iterations);

        TestWcf(Iterations);
        TestRemoting(Iterations);

        Console.ReadKey();
    }

    private static void TestRemoting(int iterations)
    {
        var domain = AppDomain.CreateDomain("TestDomain");

        var proxy =
            (IRemote)
            domain.CreateInstanceFromAndUnwrap(Assembly.GetEntryAssembly().Location, "ConsoleApplication6.Remote");

        Console.WriteLine("Remoting: {0} ms.", Test(proxy, iterations));
    }

    private static void TestWcf(int iterations)
    {
        var address = "net.pipe://localhost/test";

        var host = new ServiceHost(typeof (Remote));
        host.AddServiceEndpoint(typeof (IRemote), new NetNamedPipeBinding(), address);
        host.Open();

        var proxy = ChannelFactory<IRemote>.CreateChannel(new NetNamedPipeBinding(), new EndpointAddress(address));

        Console.WriteLine("Wcf: {0} ms.", Test(proxy, iterations));

        host.Close();
    }

    private static double Test(IRemote proxy, int iterations)
    {
        var start = DateTime.Now;

        for (var i = 0; i < iterations; i++)
        {
            proxy.Hello("Sergey");
        }

        var stop = DateTime.Now;

        return (stop - start).TotalMilliseconds;
    }
}

A got the following results for 5000 iterations:

Wcf: 14143 ms.
Remoting: 2232 ms.
Wcf: 14289 ms.
Remoting: 2130 ms.
Wcf: 14126 ms.
Remoting: 2112 ms.

Wcf is around 7 times slower than .Net Remoting in this test.

I tried to:

  • set the security mode to None;
  • set the InstanceContextMode to Single/PerCall;
  • set the ConcurrencyMode to Single/Multiple;

but the results are the same.

Does anybody know what I do wrong? Why WCF is so slow?

Is there a way to speed up this code?

Thanks in advance.

EDIT:

I have modified the test a little bit. The contract is the same.

The first test looks like this (Wcf test):

class Program
{
    private const int Iterations = 5000;

    static void Main(string[] args)
    {
        var address = "net.pipe://localhost/test";

        var host = new ServiceHost(typeof(Remote));
        host.AddServiceEndpoint(typeof(IRemote), new NetNamedPipeBinding(NetNamedPipeSecurityMode.None), address);
        host.Open();

        var proxy = ChannelFactory<IRemote>.CreateChannel(new NetNamedPipeBinding(NetNamedPipeSecurityMode.None), new EndpointAddress(address));

        TestWcf(proxy, Iterations);
        TestWcf(proxy, Iterations);
        TestWcf(proxy, Iterations);
        TestWcf(proxy, Iterations);
        TestWcf(proxy, Iterations);

        Console.ReadKey();

        host.Close();
    }

    private static void TestWcf(IRemote proxy, int iterations)
    {
        var start = DateTime.Now;

        for (var i = 0; i < iterations; i++)
        {
            proxy.Hello("Sergey");
        }

        var stop = DateTime.Now;

        Console.WriteLine("Wcf: {0} ms.", (stop - start).TotalMilliseconds);
    }
}

Here are the results:

Wcf: 2564 ms.
Wcf: 1026 ms.
Wcf: 986 ms.
Wcf: 990 ms.
Wcf: 992 ms.

The second test looks like this (.Net Remoting test):

class Program
{
    private const int Iterations = 5000;

    static void Main(string[] args)
    {
        var domain = AppDomain.CreateDomain("TestDomain");

        var proxy =
            (IRemote)
            domain.CreateInstanceFromAndUnwrap(Assembly.GetEntryAssembly().Location, "ConsoleApplication6.Remote");

        TestRemoting(proxy, Iterations);
        TestRemoting(proxy, Iterations);
        TestRemoting(proxy, Iterations);
        TestRemoting(proxy, Iterations);
        TestRemoting(proxy, Iterations);

        Console.ReadKey();
    }

    private static void TestRemoting(IRemote proxy, int iterations)
    {
        var start = DateTime.Now;

        for (var i = 0; i < iterations; i++)
        {
            proxy.Hello("Sergey");
        }

        var stop = DateTime.Now;

        Console.WriteLine("Remoting: {0} ms.", (stop - start).TotalMilliseconds);
    }
}

Here are the results:

Remoting: 261 ms.
Remoting: 224 ms.
Remoting: 252 ms.
Remoting: 243 ms.
Remoting: 234 ms.

As you can see, .Net Remoting is faster again. The tests were ran outside the debugger.

Why is this so?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:58:04+00:00Added an answer on May 26, 2026 at 6:58 pm

    Debuggers are not real measure when try to compare the performance , here is what I did and got WCF Kicking out Remoting from the ring 😉

    1) Also modified your test to run it from same program/exe

      namespace ConsoleApplication6
    {
      [ServiceContract]
      internal interface IRemote
      {
        [OperationContract]
        string Hello(string name);
      }
    
      [ServiceBehavior]
      internal class Remote : MarshalByRefObject, IRemote
      {
        public string Hello(string name)
        {
          return string.Format("Hello, {0}!", name);
        }
      }
    
      class Program
      {
        private const int Iterations = 5000;
    
        static void Main(string[] p)
        {
          TestWcf();
          TestRemoting();
        }
    
    
        static void TestWcf()
        {
          var address = "net.pipe://localhost/test";
    
          var host = new ServiceHost(typeof(Remote));
          host.AddServiceEndpoint(typeof(IRemote), new NetNamedPipeBinding(NetNamedPipeSecurityMode.None), address);
          host.Open();
    
          var proxy = ChannelFactory<IRemote>.CreateChannel(new NetNamedPipeBinding(NetNamedPipeSecurityMode.None), new EndpointAddress(address));
    
          TestWcf(proxy, Iterations);
          TestWcf(proxy, Iterations);
          TestWcf(proxy, Iterations);
          TestWcf(proxy, Iterations);
          TestWcf(proxy, Iterations);
    
          Console.WriteLine("WCF done");
    
          host.Close();
        }
    
        private static void TestWcf(IRemote proxy, int iterations)
        {
          var start = DateTime.Now;
    
          for (var i = 0; i < iterations; i++)
          {
            proxy.Hello("Sergey");
          }
    
          var stop = DateTime.Now;
    
          Console.WriteLine("Wcf: {0} ms.", (stop - start).TotalMilliseconds);
        }
    
        static void TestRemoting()
        {
          var domain = AppDomain.CreateDomain("TestDomain");
    
          var proxy =
              (IRemote)
              domain.CreateInstanceFromAndUnwrap(Assembly.GetEntryAssembly().Location, "ConsoleApplication6.Remote");
    
          TestRemoting(proxy, Iterations);
          TestRemoting(proxy, Iterations);
          TestRemoting(proxy, Iterations);
          TestRemoting(proxy, Iterations);
          TestRemoting(proxy, Iterations);
          Console.WriteLine("Remoting done");
          Console.ReadKey();
        }
    
        private static void TestRemoting(IRemote proxy, int iterations)
        {
          var start = DateTime.Now;
    
          for (var i = 0; i < iterations; i++)
          {
            proxy.Hello("Sergey");
          }
    
          var stop = DateTime.Now;
    
          Console.WriteLine("Remoting: {0} ms.", (stop - start).TotalMilliseconds);
        }
      }
    
    }
    

    2) Compile it in release mode and ran it outside debugger.

    here is my output
    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

according to this article: http://net.tutsplus.com/tutorials/other/top-20-mysql-best-practices/ using ORDER BY RAND() is a bad idea because:
According to this article about writing shell extensions in .Net, inheriting the shell interfaces
I implemented Dynamic DataSource Routing for Spring+Hibernate according to this article . I have
According to this article Google Chrome 15 has a fullscreen JavaScript API. I have
According to this article rebasing is not necessary for .NET assemblies due to JIT
According this article , generic JPA DAO(Data Access Object) is a pretty nice pattern.
According to this article , it says: Use a delegate in the following circumstances:
According to this article , it's possible to get multiline XML comments -- instead
I am doing a tutorial according to this article . This is basic Hello
I've got a PHP-fpm setup on nginx setup according to this article: http://interfacelab.com/nginx-php-fpm-apc-awesome/ PHP

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.