Skip to content

HttpConnectionManager max_requests_per_connection behaving different from the documented behaviour #19045

Closed

Description

@kfaseela

Title: HttpConnectionManager max_requests_per_connection behaving different from the documented behaviour

Description:

I have an Istio use case on long lived connections, which I am trying to test by applying envoy filter with max_requests_per_connection=3, with default drain timeout of 5sec. This is not working as per the behaviour explained at https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/network/http_connection_manager/v3/http_connection_manager.proto#envoy-v3-api-field-extensions-filters-network-http-connection-manager-v3-httpconnectionmanager-drain-timeout

A simple HTTP2 client sends GETs in a loop, when GOAWAY is received from server, it ignores it and keeps using connection.
Expected result: After 3 GET requests, server initiates connection drain, it sends a first GOAWAY message with “Promised-Stream-ID: 2147483647”, and if connection is not closed prior 5 seconds, it sends a second GOAWAY with “Promised-Stream-ID: 5 (2 x max_requests_per_connectionx - 1)”, and closes connection 1 second later.

Result: Not OK, after 3 GET requests server just sends the first GOAWAY message, as GETs are received continuously, no GOAWAY with “Promised-Stream-ID: 5 (2 x max_requests_per_connectionx - 1)” is sent and connection is never closed.

As per the drain_timeout document:
During the grace period, Envoy will continue to accept new streams. After the grace period, a final GOAWAY frame is sent and Envoy will start refusing new streams
But from the captured pkg, the final GOAWAY does not send, and envoy also does not refuse new streams. So this looks like an issue to me.

Repro steps:

  1. Apply the below EnvoyFilter:
kind: EnvoyFilter
metadata:
  name: lb-downstream
  namespace: istio-system
spec:
  workloadSelector:
    labels:
      istio: ingressgateway
  configPatches:
  - applyTo: NETWORK_FILTER
    match:
      context: GATEWAY
      listener:
        filterChain:
          filter:
            name: "envoy.filters.network.http_connection_manager"
    patch:
      operation: MERGE
      value:
        typed_config:
          "@type": "type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager"
          common_http_protocol_options:
            max_requests_per_connection: 3   # can be set as per SM user's need


2) Use the below script to keep sending http2 requests to the server, and ignore the response. (Note that the GETs are sent continuously without waiting for the drain timeout window, and in such cases, we see that the connection is never closed)

#!/usr/bin/python
import time
from hyper import HTTP20Connection
count = 0
conn = HTTP20Connection('localhost:80')
while True:
  id = conn.request('GET', '/server1/
  time.sleep(2)

Logs:

Attaching the Wireshark capture for the scenario.

max_connections_pcap

Activity

  1. added
    triage
    on Nov 18, 2021
  2. added and removed
    triage
    on Nov 19, 2021
  3. rojkov commented on Nov 19, 2021

    @rojkov
    Member

    Thank you for the great description!

    cc @alyssawilk @htuch

  4. YaoZengzeng commented on Nov 20, 2021

    @YaoZengzeng
    Member

    The cause of the problem appears to be that the new coming streams will keep resetting drain_timer_ which result it never timeout, ref https://github.com/envoyproxy/envoy/blob/main/source/common/http/conn_manager_impl.cc#L293 .

    I'd like to fix it:)

  5. kfaseela commented on Nov 20, 2021

    @kfaseela
    ContributorAuthor

    @YaoZengzeng : Thanks for the response, and would be really helpful if you are planning to fix it. :)

  6. kfaseela commented on Nov 20, 2021

    @kfaseela
    ContributorAuthor

    Thank you for the great description!

    cc @alyssawilk @htuch

    Thank you @rojkov :) This is my first activity in the community, and happy to receive a nice response!

  7. added a commit that references this issue on Nov 29, 2021
    b432368
  8. added 2 commits that reference this issue on Jun 21, 2022
    17f836b
    52a65ab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions