I have WCF service. I have done some testing with basichttp binding and tcp binding.
In a console client i created hundreds of threads and hit the service with tcp and http binding. Turned out TCP is twice faster than http.
Then i made a web client that runs on IIS and hits the service.
Turned out that http is faster then TCP.
How does this happen? isnt TCP supposed to be faster than basichttp? COde is like the one below. similar.
stopwatch start here
Thread[] ts = new Thread[100];
for(int i= 0; i< ts.lenght;i++){
ts[i] = new Thread(foo); // replace with bar for the second test.
ts[i].start();
}
for(int i 0;i< ts.lenght;i++){
ts[i].join();
}
stopwatch stop here.
public static void foo(){
MyServiceClient myclient = new MyServiceClient("netTcpBinding");
myclient.GetResult(1);
}
public static void bar(){
MyServiceClient myclient = new MyServiceClient("basicHttpBinding");
myclient.GetResult(1);
}
Did you know that WCF has throttling turned on by default. Before you run these tests, you should turn it off by using this bit of config in your web.config’s serviceModel section:
The defaults vary by version but are around 16, 10, 100 or something along those lines in .NET 4. Those lower defaults are applied even if you have no throttling entry in your web.config / app.config.
Good luck.