Remora / Remora.Discord

A data-oriented C# Discord library, focused on high-performance concurrency and robust design.
GNU Lesser General Public License v3.0
246 stars 44 forks source link

Support for gateway compression #317

Open VelvetToroyashi opened 9 months ago

VelvetToroyashi commented 9 months ago

Description

Remora.Discord does not currently support gateway compression.

This reduces bytes sent over the wire, and can allow for potentially more data to be processed as a result.

Why This is Needed

Discord bots deal with exponentially more data as they scale, and one of the common bottlenecks is ingress bandwidth. It's important to support compression both for network constraints and to be in parity with the API. Right now, the compress field is hard-coded to false, as the underlying IPayloadTransportService does not have support for any form of (de-)compression.

Alternatives Considered

Currently, I am writing my own payload transport service to handle this, and will PR something similar to Remora when I have time, if this is not picked up by someone else before that happens.

Additional Details

Ideally, we'll also support transport compression (which compresses the entire stream, instead of "select packets") as well; however these two are mutually exclusive, and would require some extra validation on the client to ensure both of these are not set simultaneously.