Skip to content

SignalR performance: Json is faster than MessagePack #31793

Open
@foxstream528

Description

@foxstream528

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsarea-signalrIncludes: SignalR clients and serversfeature-httpsysinvestigate

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions