HTTP connection settings

Verified Code examples on this page have been automatically tested and verified.

You can use an AgentgatewayPolicy to apply HTTP connection settings to the agentgateway proxy. These settings include idle connection timeouts, the maximum number of connections that an upstream service can receive, and more. Note that these options are applied to HTTP/1 or HTTP/2 requests only when indicated.

Before you begin

  1. Set up an agentgateway proxy.
  2. Install the httpbin sample app.

Maximum buffer size

Fine-tune connection speeds for read and write operations by setting a connection buffer limit (maxBufferSize). You can use this setting for both HTTP/1 and HTTP/2 connections.

HTTP/1.1 settings

Use these settings to control header limits and idle connection behavior for HTTP/1.1 connections.

Idle timeouts

Set an idle timeout for HTTP/1 traffic to terminate the connection to a downstream or upstream service if there are no active streams.

Max headers

Set the maximum number of headers allowed in HTTP/1.1 requests.

  1. Create an AgentgatewayPolicy that applies the HTTP/1.1 connection configuration to the proxy.

    kubectl apply -f- <<EOF
    apiVersion: agentgateway.dev/v1alpha1
    kind: AgentgatewayPolicy
    metadata:
      name: http1
      namespace: agentgateway-system
    spec:
      targetRefs:
      - kind: Gateway
        name: agentgateway-proxy
        group: gateway.networking.k8s.io
      frontend:
        http:
          http1MaxHeaders: 15
    EOF
    SettingDescription
    http1MaxHeadersThe maximum number of headers allowed in HTTP/1.1 requests. Requests that exceed the limit receive a 431 response.
  2. Port-forward the gateway proxy on port 15000.

    kubectl port-forward deployment/agentgateway-proxy -n agentgateway-system 15000
  3. Get the config dump and verify that the policy is set as you configured it.

    Example jq command:

    curl -s http://localhost:15000/config_dump | jq '[.policies[] | select(.policy.frontend != null and .policy.frontend.hTTP != null and .policy.frontend.hTTP.http1IdleTimeout != null)] | .[0]'

    Example output:

    http://localhost:15000/config_dump
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    
    {
      "key": "frontend/agentgateway-system/http1:frontend-http:agentgateway-system/agentgateway-proxy",
      "name": {
        "kind": "AgentgatewayPolicy",
        "name": "http1",
        "namespace": "agentgateway-system"
      },
      "target": {
        "gateway": {
         "gatewayName": "agentgateway-proxy",
         "gatewayNamespace": "agentgateway-system",
         "listenerName": null
       }
     },
     "policy": {
       "frontend": {
         "hTTP": {
           "maxBufferSize": null,
           "http1MaxHeaders": 15,
           "http1IdleTimeout": null,
           "http2WindowSize": null,
           "http2ConnectionWindowSize": null,
           "http2FrameSize": null,
           "http2KeepaliveInterval": null,
           "http2KeepaliveTimeout": null
         }
       }
     }
    }
  1. Optional: Clean up and remove the AgentgatewayPolicy.
kubectl delete AgentgatewayPolicy http1 -n agentgateway-system

HTTP/2 settings

Use these settings to tune HTTP/2 flow control, which governs how much data can be in-flight at the stream and connection levels.

Flow control

  1. Create an AgentgatewayPolicy that applies HTTP/2 flow control configuration to the proxy.

    kubectl apply -f- <<EOF
    apiVersion: agentgateway.dev/v1alpha1
    kind: AgentgatewayPolicy
    metadata:
      name: http2-flow
      namespace: agentgateway-system
    spec:
      targetRefs:
      - kind: Gateway
        name: agentgateway-proxy
        group: gateway.networking.k8s.io
      frontend:
        http:
          http2WindowSize: 1048576
          http2ConnectionWindowSize: 4194304
          http2FrameSize: 65536
    EOF
    SettingDescription
    http2WindowSizeControls how many bytes can be in-flight on a single HTTP/2 stream before the sender must wait for a WINDOW_UPDATE acknowledgment. Setting this to 1 means the client can only send 1 byte at a time per stream, essentially halting all throughput. The default is 65,535 bytes (64KB).
    http2ConnectionWindowSizeThe initial window size for connection-level flow control for received data. This settings controls the total bytes in-flight across all streams on a single connection combined.
    http2FrameSizeThe maximum size of a single HTTP/2 DATA frame the gateway accepts. The HTTP/2 protocol minimum (and default) is 16,384 bytes. 17000 is a modest bump above that default, allowing slightly larger frames and potentially fewer round-trips for larger payloads.
  2. Port-forward the gateway proxy on port 15000.

    kubectl port-forward deployment/agentgateway-proxy -n agentgateway-system 15000
  3. Get the config dump and verify that the policy is set as you configured it.

    Example jq command:

    curl -s http://localhost:15000/config_dump | jq '[.policies[] | select(.policy.frontend != null and .policy.frontend.hTTP != null and .policy.frontend.hTTP.http2WindowSize != null)] | .[0]'

    Example output:

    http://localhost:15000/config_dump
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    
    {
      "key": "frontend/agentgateway-system/http2-flow:frontend-http:agentgateway-system/agentgateway-proxy",
      "name": {
        "kind": "AgentgatewayPolicy",
        "name": "http2-flow",
        "namespace": "agentgateway-system"
      },
      "target": {
        "gateway": {
         "gatewayName": "agentgateway-proxy",
         "gatewayNamespace": "agentgateway-system",
         "listenerName": null
       }
     },
     "policy": {
       "frontend": {
         "hTTP": {
           "maxBufferSize": null,
           "http1MaxHeaders": null,
           "http1IdleTimeout": null,
           "http2WindowSize": 1048576,
           "http2ConnectionWindowSize": 4194304,
           "http2FrameSize": 65536,
           "http2KeepaliveInterval": null,
           "http2KeepaliveTimeout": null
         }
       }
     }
    }
  1. Optional: Clean up and remove the AgentgatewayPolicy.
kubectl delete AgentgatewayPolicy http2-flow -n agentgateway-system

Keepalive

Manage idle and stale connections with HTTP/2 keepalive.

Agentgateway assistant

Ask me anything about agentgateway configuration, features, or usage.

Note: AI-generated content might contain errors; please verify and test all returned information.

Tip: one topic per conversation gives the best results. Use the + button in the chat header to start a new conversation.

Switching topics? Starting a new conversation improves accuracy.
↑↓ navigate select esc dismiss

What could be improved?

Your feedback helps us improve assistant answers and identify docs gaps we should fix.

Need more help? Join us on Discord: https://discord.gg/y9efgEmppm

Want to use your own agent? Add the Solo MCP server to query our docs directly. Get started here: https://search.solo.io/.