Last chance to speak on stage at GraphQL Summit! Submit your GraphQL Summit proposal by June 29. 🌴
Docs
Try Apollo Studio

Traffic shaping

Configuring traffic shaping


The Apollo Router provides support for traffic shaping.

Currently features are limited, but are expected to grow over time:

  • Sub-query deduplication - Identical, in-flight, non-mutation sub-queries are compressed into a single request.
  • Variables deduplication - Subgraph requests body is compressed to deduplicate variables.
  • Compression - Subgraph requests body and responses body are compressed in the specified compression algorithm (gzip, br, deflate).

Configuration

To configure traffic shaping add the traffic_shaping plugin to your router.yaml:

router.yaml
traffic_shaping:
variables_deduplication: true # Enable the variables deduplication optimization
all:
query_deduplication: true # Enable query deduplication for all subgraphs.
compression: br # Enable brotli compression for all subgraphs
subgraphs:
products:
query_deduplication: false # Disable query deduplication for products.
compression: gzip # Enable gzip compression only for subgraph products

Note that configuration in the subgraphs section will take precedence over that in the all section.

Sub-query deduplication

Deduplication will cause any identical, in-flight, non-mutation sub-queries to be merged into a single request. This can reduce network bandwidth and CPU at your subgraph.

Note that only in flight requests are deduplicated.

Variables deduplication

Variables deduplication will cause any identical variables in the sub-request body to be merged into an unique list of variables. This can reduce network bandwidth and CPU at your subgraph.

Compression

You can enable compression on subgraph requests and responses. Available compression algorithms are: gzip, br, deflate.

Edit on GitHub
Previous
Header propagation
Next
Subgraph Error Inclusion