WCF vs GRPC Performance in .NET
Nikolai Petrov
Original Developer of BizRuleAnalyzer, LoanDebugger, FormDebugger & CodeWizard
This code can allow you to test WCF vs GRPC Performance:
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.
SSE@CBA | Ex-NEC | .NET CORE, REACT, AZURE
4 个月Thanks for sharing this benchmarks.
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!
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?}); ????????????
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.
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)