WCF vs GRPC Performance in .NET

WCF vs GRPC Performance in .NET

This code can allow you to test WCF vs GRPC Performance:

https://github.com/npetrov001/TestWCFvsGRPC


GRPC Test Running with 100 threads showing ~ 45,000 requests per second on 8-core VM

There are 2 sets of Client / Server projects implemented as visual WinForms applications with simple UI that runs tests and shows stats:

GRPC - C# .NET 8

WCF - C# .NET Framework 4.8

These videos describe the project and results:

1) Project Structure - https://youtu.be/bI5YREd_XTM

2) Local Test Results - https://youtu.be/Xnd9QD2RBFg

3) Remote Test Results - https://youtu.be/uTWG5tHgIqs


Local Test Results:

1) WCF can get ~ 2,500 requests / sec in a single thread.

2) WCF only scales to ~ 6,800 requests / sec with 4 CPUs.

3) WCF only scales to ~ 8,200 requests / sec with 8 CPUs.

- so WCF does not scale with # of CPUs very well.

4) GRPC can get ~ 4,000 requests / sec in a single thread.

5) GRPC scales to ~ 20,000 - 25,000 requests / sec with 4 CPUs.

6) GRPC scales to ~ 40,000 - 45,000 requests / sec with 8 CPUs.

- so GRPC actually scales with # of CPUs reasonably well.


Overall, locally on a single thread, GRPC can send messages ~ 1.6x faster than WCF and for large # of requests with 8 cores, it can handle traffic ~ 5x better.


Remote Test Results:

1) WCF remote requests go at 2x ping latency.

2) GRPC remote requests go at 1x ping latency.

- WCF protocol likely needs a double request / response.

3) WCF remote requests are throttled on per-process basis, so if parallel communication channels are needed, multiple processes are required.

4) GRPC remote requests are not throttled, and scale much better across threads within the same process.


Overall, for small messages (tested with 1kb) GRPC performs ~ 2x better.


Summary:

GRPC is better. On the server-side it can scale with # of CPU cores and on the client side it will perform ~ 2x faster in typical Client-Server over-the-internet communications. GRPC communication can also be multi-threaded on the client-side, while WCF communication is throttled per-process in multi-threaded clients.

PRAVEEN VERMA

SSE@CBA | Ex-NEC | .NET CORE, REACT, AZURE

4 个月

Thanks for sharing this benchmarks.

回复
Arash Laylazi

Web Architect (Analyst, Designer, Developer, Adviser, Instructor), Radically Cat-Lover

5 个月

I?think?it?would?be?better?to?benchmark?using?Core?WCF. https://github.com/CoreWCF/CoreWCF .NET framework is a living dead!

??Vince Zalamea

Software Engineer

5 个月

BasicHttpBinding uses XML. Why not use a custom binding using HTTP Transport with binary encoding? This would be more comparable to gRPC. var?customBinding?=?new?CustomBinding(); customBinding.Elements.Add(new?BinaryMessageEncodingBindingElement()); customBinding.Elements.Add(new?HttpTransportBindingElement?{?MaxReceivedMessageSize?=?int.MaxValue?}); ????????????

Saba Gotsiridze

Senior .Net Developer

5 个月

Great comparison! Have you looked into Core WCF? It enables existing WCF services to move to .NET Core, offering improved features while still maintaining a familiar architecture, but it's not as fast as gRPC.

Chris Mace

Founder | Building better mortgage tech | Helping lenders do 4x more loans without the staff | 2x Founder | 1x Exit | “Making mortgage companies profitable again” ??

5 个月

My man Nikolai Petrov dropping bombs on things nobody will understand :) (most people)

要查看或添加评论,请登录

Nikolai Petrov的更多文章

社区洞察

其他会员也浏览了