Http compression #
Pragma can gzip Http traffic on its gateways and on backend-to-backend partner calls. Compression is off by default and controlled by independent flags on each gateway and each backend client, so you can enable it only where payload size justifies the CPU cost.
Compression has two halves:
- Gateways accept gzip-compressed request bodies and gzip responses for callers that send
Accept-Encoding: gzip. - Backend clients gzip the request bodies they send: game-to-social partner calls, and game or social calls to a dedicated telemetry backend.
A client only compresses requests; the gateway it calls must have compression enabled to decompress them. Enable the receiving gateway before the client.
Enable compression on a gateway #
Set enableHttpCompression on the gateway’s config. Each gateway has its own flag: {Game,Social,Telemetry}{Player,Partner,Operator}GatewayConfig.
social:
serviceConfigs:
SocialPartnerGatewayConfig:
enableHttpCompression: true
| Setting | Default | Description |
|---|---|---|
enableHttpCompression | false | Decompress gzip request bodies and gzip responses for callers that send Accept-Encoding: gzip. Which responses are compressed follows Ktor’s defaults. Requires a restart to take effect. |
Enable compression on game-to-social calls #
Enable SocialPartnerGatewayConfig.enableHttpCompression on the social backend first, then enable compression on the game backend’s social client:
game:
serviceConfigs:
SocialBackendPartnerClientConfig:
enableHttpCompression: true
httpCompressionMinBodyBytes: 200
| Setting | Default | Description |
|---|---|---|
enableHttpCompression | false | Gzip request bodies sent to the social backend. Hot-reloadable. |
httpCompressionMinBodyBytes | 200 | Request bodies smaller than this are sent uncompressed, since gzip overhead outweighs the saving on small payloads. 0 compresses every body. Hot-reloadable. |
Enable compression on telemetry calls #
Compression applies only when game or social services send events to a dedicated telemetry backend. Without a dedicated backend, events route intra-cluster and are never compressed.
Enable TelemetryPartnerGatewayConfig.enableHttpCompression on the telemetry backend first, then enable compression on each backend’s telemetry client:
telemetry:
serviceConfigs:
TelemetryPartnerGatewayConfig:
enableHttpCompression: true
game:
serviceConfigs:
TelemetryBackendClientConfig:
enableHttpCompression: true
social:
serviceConfigs:
TelemetryBackendClientConfig:
enableHttpCompression: true
TelemetryBackendClientConfig supports the same enableHttpCompression and httpCompressionMinBodyBytes settings, with the same defaults, as SocialBackendPartnerClientConfig.
Security considerations #
- Response compression and BREACH: compressing responses that combine secrets with attacker-influenced input exposes them to BREACH-style attacks. Prefer enabling compression on partner gateways, which only serve trusted backends and game servers.
- Decompressed request size: there is no limit on the decompressed size of a request body. A small gzip body from an authenticated caller can expand to a large allocation on the receiving backend.
The Unreal and Unity SDKs don’t set Accept-Encoding or compress request bodies. Whether player gateway responses are compressed for SDK clients depends on whether the game engine’s Http stack adds Accept-Encoding: gzip on its own.
Measure payload sizes #
Partner calls record their request and response body sizes, tagged by fromBackendType and toBackendType. Use these to find the calls where compression is worth enabling. Both measure uncompressed body size, not bytes on the wire.
| Metric | Description |
|---|---|
pragma.client.partnerRpc.requestBytes | Uncompressed request body size per partner call. |
pragma.client.partnerRpc.responseBytes | Uncompressed response body size per partner call. |
The details dashboard shows both in the PartnerRpcHttpClient Payload Sizes row.