dotnet / dotnet/aspnetcore

SignalR performance: Json is faster than MessagePack

Open
#31,793 9 comments 0 reactions 0 assignees View on GitHub
area-networking area-signalr feature-httpsys investigate
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### 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](https://user-images.githubusercontent.com/82504943/114687679-4952c500-9d14-11eb-9880-a5edac42da18.png)

### 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
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.