Buffering
Fine-tune connection speeds for read and write operations.
About read and write buffer limits
By default, kgateway 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, kgateway 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.
Before you begin
-
Follow the Get started guide to install kgateway.
-
Follow the Sample app guide to create an API gateway proxy with an HTTP listener and deploy the httpbin sample app.
-
Get the external address of the gateway and save it in an environment variable.
export INGRESS_GW_ADDRESS=$(kubectl get svc -n kgateway-system http -o jsonpath="{.status.loadBalancer.ingress[0]['hostname','ip']}") echo $INGRESS_GW_ADDRESSkubectl port-forward deployment/http -n kgateway-system 8080:8080
Set up connection buffer limits
-
Create a ListenerPolicy resource to define your connection buffer limit rules.
kubectl apply -f- <<EOF apiVersion: gateway.kgateway.dev/v1alpha1 kind: ListenerPolicy metadata: name: bufferlimits namespace: kgateway-system spec: targetRef: group: gateway.networking.k8s.io kind: Gateway name: http perConnectionBufferLimitBytes: 10485760 EOF -
Verify that your configuration is applied by reviewing the Envoy configuration.
- Port forward the
gloo-gateway-httpdeployment on port 19000.kubectl port-forward deploy/http -n kgateway-system 19000 & - Open the
config_dumpendpoint.open http://localhost:19000/config_dump - Look for the
"per_connection_buffer_limit_bytes": 10485760string in your Envoy configuration.
- Port forward the
Cleanup
You can remove the resources that you created in this guide.kubectl delete listenerpolicy bufferlimits -n kgateway-system