Buffering
Fine-tune connection speeds for read and write operations.
About read and write buffer limits
By default, Gloo Gateway is set up with 1MiB of request read and write buffer for each gateway listener. For large requests that must be buffered and that exceed the default buffer limit, Gloo Gateway either disconnects the connection to the downstream service if headers were already sent, or returns a 500 HTTP response code. To make sure that large requests can be sent and received, you can specify the maximum number of bytes that can be buffered between the gateway and the downstream service.
You can configure a maximum payload size on a gateway (perConnectionBufferLimitBytes
) with the ListenerOption resource or on a route (perRequestBufferLimitBytes
) with the RouteOption resource. The smaller size takes precedence. For example, if a gateway sets the maximum payload size to 10MB and the route to 15MB, the gateway maximum size is enforced. However, if the route size is only 5MB (less than the gateway), then the route maximum size is enforced. To configure different maximum payload sizes for specific workloads, set a larger size on the gateway. Then, set smaller sizes for each workload’s route. Routes that do not specify a maximum payload size inherit the payload size from the gateway.
Before you begin
Follow the Get started guide to install Gloo Gateway, set up a gateway resource, and deploy the httpbin sample app.
Get the external address of the gateway and save it in an environment variable.
Set up connection buffer limits
Create a ListenerOption resource to define your connection buffer limit rules.
kubectl apply -f- <<EOF apiVersion: gateway.solo.io/v1 kind: ListenerOption metadata: name: bufferlimits namespace: gloo-system spec: targetRefs: - group: gateway.networking.k8s.io kind: Gateway name: http options: perConnectionBufferLimitBytes: 10485760 EOF
Verify that your configuration is applied by reviewing the Envoy configuration.
- Port forward the
gloo-gateway-http
deployment on port 19000.kubectl port-forward deploy/gloo-proxy-http -n gloo-system 19000 &
- Open the
config_dump
endpoint.open http://localhost:19000/config_dump
- Look for the
perConnectionBufferLimitBytes: 10485760
string in your Envoy configuration.
- Port forward the
Cleanup
You can remove the resources that you created in this guide.
kubectl delete listeneroption bufferlimits -n gloo-system