Ask a questionAsk a question
 

AnswerWCF 4.0 client performance problem

  • Sunday, November 01, 2009 3:34 PMEl Marcus Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi all,
    my problem is the following: Using VS2010 B2 I experienced that a wcf client targetting fw 4.0 needs almost 10x more time to get response from a wcf service than a client built against fw 3.5sp1. To test it I simply added a WCF service to my solution with the default code, and a WPF project as the client. I tested it with manually built client code as well as with Add service reference... wizard generated code, there was no significant difference. In case of fw 3.5 the response arrived in 40 ms, in case of fw 4.0 it took more than 350 ms on average. We are working on a project where the client code is based on the fw 4.0, that's why any suggestion is welcome. Thanks in advance,
    m

Answers

  • Thursday, November 05, 2009 8:48 AMRiquel_DongModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi ,

    I opened WCF service in one Win7 computer via self-host(start debugging). Run two client test application in other computer(directly run via clicking its executable files in disk, without debugging). The following is my observation. Actually I think that .NET4 client application gets bigger improvement in performance.

    Test1:

    17303 .NET Framework 3.5 in VS20008    
    22052  .NET Framework 4 in VS2010( not client profile)


    Test2(this result is observed in several times, the performance of .NF 4.0 client can be compared with .NF3.5 client.)

    20507 .NET Framework 3.5 in VS20008
    8172   .NET Framework 4 in VS2010( not client profile)

    VS2010 is not final edition. It is the beta2 stage. When we start the client applications via start debugging, its performance is not good than VS2008. This is normal, because this is not final version.

    static void Main(string[] args)
            {
                Stopwatch swh = new Stopwatch();
                swh.Start();
                SimpleServiceClient sc = new SimpleServiceClient();
                sc.Open();
                for (int i = 0; i < 500; i++)
                {
                    if (i == 50 || i == 250 || i == 450)
                    {
                        Console.WriteLine(sc.SimpleMethod("my test  " + i.ToString()));
                    }
                    else
                    {
                        sc.SimpleMethod("my test  " + i.ToString());
                    }
                }
                sc.Close();
                swh.Stop();
                Console.WriteLine(swh.ElapsedMilliseconds.ToString() + " .NET Framework 3.5 client");
                Console.ReadLine();
            }


     
    Best regards,
    Riquel
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked As Answer byEl Marcus Friday, November 06, 2009 10:15 AM
    •  

All Replies

  • Monday, November 02, 2009 6:23 AMRamiro BerrellezaMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi El Marcus,

    What do you mean by  " I simply added a WCF service to my solution with the default code"? Also, how are you deploying your service, to IIS or to a custom service host? 

    Thanks,
    Ramiro

    Ramiro Berrelleza
  • Monday, November 02, 2009 8:44 AMEl Marcus Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Ramiro,
    my test solution cosists of 2 projects: a client app (wpf) and the wcf service. the debugger launches the wpf app, the wcf project is hosted by wcfsvchost automatically. (I also tried hosting the service by a simple console based program, got the same result) The default code is what the VS template generates (IService1.cs/Service1.cs...)  
    thanks again,
    m
  • Tuesday, November 03, 2009 6:30 PMRamiro BerrellezaMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi El Marcus,

    How are you creating your proxy client?  Are you using the "Add Service Reference" option from Visual Studio?

    Thanks,
    Ramiro
    Ramiro Berrelleza
  • Wednesday, November 04, 2009 8:21 AMRiquel_DongModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi El marcus,

    I didn't reproduce this situation. I host one WCF service in Win7 via self-host(one console application). I write two console applications as the WCF client by using Add service references to get proxy and configuration in VS2008(.NET Framework3.5) and in VS2010 Beta2(.NET Framework 4).

    The output is :

    6023 .NET Framework 3.5 client

    8186   .NET Framework 4 client

        class Program
        {      
            static void Main(string[] args)
            {
                Stopwatch swh=new Stopwatch();
                swh.Start();
                SimpleServiceClient sc = new SimpleServiceClient();
                sc.Open();
                for (int i = 0; i < 100; i++)
                {
                    Console.WriteLine(sc.SimpleMethod("my test  " + i.ToString()));
                }          
                sc.Close();
                swh.Stop();
                Console.WriteLine(swh.ElapsedMilliseconds.ToString() + " .NET Framework 3.5 client");
                Console.ReadLine();
            }
        }

        class Program
        {
            static void Main(string[] args)
            {
                Stopwatch swh = new Stopwatch();
                swh.Start();
                SimpleServiceClient sc = new SimpleServiceClient();
                sc.Open();
                for (int i = 0; i < 100; i++)
                {
                    Console.WriteLine(sc.SimpleMethod("my test  " + i.ToString()));
                }
                sc.Close();
                swh.Stop();
                Console.WriteLine(swh.ElapsedMilliseconds.ToString() + "   .NET Framework 4 client");
                Console.ReadLine();
            }
        }
    Best regards,
    Riquel
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Wednesday, November 04, 2009 9:32 AMEl Marcus Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Raquel,
    i tested with your code, got the following results: (the service was hosted by wcfsvchost.exe automatically during debugging)

    binding: net.tcp

    service 4 - client 4 --> 4974 ms
    service 4 client 3.5 --> 2302 ms
    service 3.5 - client 3.5 --> 1426 ms

    on my development machine, windows 7 64 bit, core2 6400, 4 GB RAM.

    Ramiro, yes first I used the wizard, after that i made the proxy manually.
    If you are interested in further tests (different bindings, 32/64 bit) please let me know.
    Thanks again,
    m  
  • Thursday, November 05, 2009 8:48 AMRiquel_DongModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi ,

    I opened WCF service in one Win7 computer via self-host(start debugging). Run two client test application in other computer(directly run via clicking its executable files in disk, without debugging). The following is my observation. Actually I think that .NET4 client application gets bigger improvement in performance.

    Test1:

    17303 .NET Framework 3.5 in VS20008    
    22052  .NET Framework 4 in VS2010( not client profile)


    Test2(this result is observed in several times, the performance of .NF 4.0 client can be compared with .NF3.5 client.)

    20507 .NET Framework 3.5 in VS20008
    8172   .NET Framework 4 in VS2010( not client profile)

    VS2010 is not final edition. It is the beta2 stage. When we start the client applications via start debugging, its performance is not good than VS2008. This is normal, because this is not final version.

    static void Main(string[] args)
            {
                Stopwatch swh = new Stopwatch();
                swh.Start();
                SimpleServiceClient sc = new SimpleServiceClient();
                sc.Open();
                for (int i = 0; i < 500; i++)
                {
                    if (i == 50 || i == 250 || i == 450)
                    {
                        Console.WriteLine(sc.SimpleMethod("my test  " + i.ToString()));
                    }
                    else
                    {
                        sc.SimpleMethod("my test  " + i.ToString());
                    }
                }
                sc.Close();
                swh.Stop();
                Console.WriteLine(swh.ElapsedMilliseconds.ToString() + " .NET Framework 3.5 client");
                Console.ReadLine();
            }


     
    Best regards,
    Riquel
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked As Answer byEl Marcus Friday, November 06, 2009 10:15 AM
    •  
  • Friday, November 06, 2009 10:15 AMEl Marcus Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Riquel!
    I tested outside the VS's debugger, you are right, the vs 2010 debugger caused this trouble. Thanks for your help!
    m