SignalR performance: Json is faster than MessagePack

See original GitHub issue

Describe the bug

I’m facing an issue with SignalR. Our benchmark shows that json protocol is faster than messagepack when transfering a lot of data. We need to investigate why messagepack isn’t getting the same or better performance than json.

While signalR with json protocol bandwidth increases when using larger packets (following the performance of raw binary websocket implementation), signalR with messagepack seems to be capped. image

To Reproduce

Use the following code: https://github.com/Foxstream/SignalrMessagepackExample

Further technical details

It is a .NET 5.0 project with Microsoft.AspNetCore.SignalR.Client 5.0.5 and Microsoft.AspNetCore.SignalR.Protocols.MessagePack 5.0.5 packages. Running on Windows 10 20H2. It uses websocket transport protocol and HTTP.sys.

Using the .NET or the Javascript signalR client doesn’t seem to matter because it will result in similar performance issues.

Results on localhost

With messagepack (2000 packets of 256KB)
179 packets/s | Bandwidth=45938 KB/s
It took 11.14s

With json (2000 packets of 256KB)
343 packets/s | Bandwidth=87885 KB/s
It took 5.82s

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
BrennanConroycommented, Jul 29, 2021

HttpSys wraps the output stream directly and just writes the data inline as it gets it. Another server like Kestrel, wraps the output stream in a much more complicated way and essentially buffers the writes so they go out in bigger chunks.

Backlogging as we wont be doing anything in 6.0 here.

2reactions
davidfowlcommented, Apr 14, 2021

Any reason why the server is using HTTP.sys? Also, that’s pretty impressive, good job JSON 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Performance guide for Azure SignalR Service
MessagePack is smaller in size and delivered faster than JSON. MessagePack might not improve performance, though. The performance of Azure ...
Read more >
I used MessagePack in a real-time streaming app. ...
It supports compression too. Even if the resulting serialised size isn't always smaller than compressed JSON, from a performance standpoint it's a lot...
Read more >
How to make the fastest .NET Serializer with .NET 7 / C# 11 ...
Compared to MessagePack for C#, a fast binary serializer, the performance is several times faster for standard objects, and even 50~100 times  ......
Read more >
Getting Started With SignalR Using ASP.NET Core
It is smaller than JSON so it has better performance over the transmission. You can read more about MessagePack at the official website....
Read more >
SignalR vs gRPC: Understanding the Differences
Data serialization, JSON, MessagePack, Protocol Buffers, JSON. Performance, Slower than gRPC, Faster than SignalR. Language support .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found