clockworklabs / SpacetimeDB

Multiplayer at the speed of light
https://spacetimedb.com
Other
4.2k stars 103 forks source link

Switch to/Provide option for gzip #1463

Open cloutiertyler opened 6 days ago

cloutiertyler commented 6 days ago

Puru:

Provide an option in WS API to send the response encoded in gzip via ?gzip or ?encoding=gzip

OR

Totally switch to gzip, which should be a non-breaking change(AFAIK).

From discord:

"Just outlining the general outline: If we wait for brotli in web, and it comes after 1 year, it'll take over 1 more to > spread across all the browsers( cough Safari firefox cough ) and have > enuf usage as well(Like safari being tied to mac updates so it'll be the slowest to get). After that, it would take time for Node to get it as well, after which we gotta wait for us bumping our TS SDK's minimum node version to the one which supports DecompressionStream(brotli) So we're looking at 2-3 years from now at a minimum. Which means 100KB for our SDK for the said period of time

If we switch to gzip or provide it as an option, we can have a non-breaking > change in the JS SDK(which internally starts using DecompressionStream('gzip') widely supported). We can also do this as a breaking change while bumping up a minimum node version, pre-1.0. And the bundle size can go down very easily to 5-10KBs, which is really good to have. Sizes don't matter in the long run, but it does if people start complaining and this causes others to try to use HTTP API instead, which is a failure of the SDK.

Something to think about pre-1.0"

cloutiertyler commented 6 days ago

Why wouldn't a total change to gzip be a breaking change?

PuruVJ commented 6 days ago

Isn’t gzip an implementation detail for the sdks? If so, it shouldn’t break anything

Unless people are manually using the binary version of ws api, in which case it would be breaking.

Further confirmation required from Phoebe/Mazdak

gefjon commented 6 days ago

Breaking in the sense that:

Not breaking in the sense that SDK users would need to change their code.

gefjon commented 6 days ago

Since Joshua has confirmed that GZip performs similarly to Brotli for our needs, assuming we can locate reliable Rust and C# (.NET and Unity) libraries for it, this seems like a totally reasonable and low-effort thing to do so long as we do it pre-1.0 so we don't break a stable API. I make no comment as to how high priority this should be.