Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

kafka-ch-dispatcher doesn't reuse outgoing connections #342

Closed
maschmid opened this issue Jan 29, 2021 · 11 comments · Fixed by #353
Closed

kafka-ch-dispatcher doesn't reuse outgoing connections #342

maschmid opened this issue Jan 29, 2021 · 11 comments · Fixed by #353
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@maschmid
Copy link
Contributor

Describe the bug
Having an MT Broker backed by KafkaChannels, and just a single application sending to the broker, I can see the number of TCP connections in kafka-ch-dispatcher rise with each event sent:

Most of these (around 4000) are connections to broker-filter:

oc rsh -n knative-eventing kafka-ch-dispatcher-8664d75457-sfcgg
cat /proc/net/tcp | grep "AF321EAC:0050" | wc -l
3959
oc get svc --all-namespaces -o wide   | grep 172.30.50.175
knative-eventing                                   broker-filter                              ClusterIP      172.30.50.175    <none>                                                                   80/TCP,9092/TCP                     39h     eventing.knative.dev/brokerRole=filter

Expected behavior
Outgoing connections should be pooled, with a reasonable maximum of connections to the same address (e.g. 100)

To Reproduce
Send many events to an mt-broker backed by KafkaChannel

Knative release version
0.19.2

Additional context

@maschmid maschmid added the kind/bug Categorizes issue or PR as related to a bug. label Jan 29, 2021
@slinkydeveloper
Copy link
Contributor

slinkydeveloper commented Feb 1, 2021

@maschmid
Copy link
Contributor Author

maschmid commented Feb 1, 2021

Is ConfigureConnectionArgs invoked anywhere in kafka-ch-dispatcher?

@slinkydeveloper
Copy link
Contributor

slinkydeveloper commented Feb 1, 2021

I don't think so, but let me check. In any case, are you modifying the map that contains those values?

@maschmid
Copy link
Contributor Author

maschmid commented Feb 1, 2021

OK, I think the problem might be that I have misunderstood the the semantics of defaults. We only set MaxIdleConnsPerHost, not MaxConnsPerHost , so if the connections were all still busy, they are still allowed to grow up for infinity...

@slinkydeveloper
Copy link
Contributor

We only set MaxIdleConnsPerHost, not MaxConnsPerHost , so if the connections were all still busy, they are still allowed to grow up for infinity...

If you set MaxConnsPerHost, does it grows indefinitely?

@maschmid
Copy link
Contributor Author

maschmid commented Feb 1, 2021

MaxConnsPerHost is 0 by default AFAIK, so it doesn't limit it. If we'd set it, it would block during Dial if the limit would be breached...

However, I am still trying to understand the difference between imc-dispatcher and kafka-consolidated-dispatcher.

In IMC, we have https://github.com/knative/eventing/pull/4465/files#diff-793cc23b5cb3cde6c57ad48d4e44b3252912e0e14ea50abb32fbd3904b053846R111 , which configures this from a cm, but I don't think we have the same in kafka-consolidated-dispatcher? (Which means, we just use golang defaults?)

@maschmid
Copy link
Contributor Author

maschmid commented Feb 1, 2021

I think I have a theory on why it this problem occuring in kafka dispatcher, but not imc-dispatcher.

As we don't set anything, we keep the golang defaults, which are

MaxIdleConns = 100
MaxIdleConnsPerHost = 0 , which means "DefaultMaxIdleConnsPerHost" is used per host, which == 2.

This actually causes much more connections to be busy, because with 2 idle connections per host it is hardly re-using any at all, so most of the connections are busy because they need to re-connect all the time.

(With IMC, we default to

MaxIdleConns = 1000
MaxIdleConnectionsPerHost = 100

@slinkydeveloper
Copy link
Contributor

Are you proposing we default to the same defaults of IMC?

@maschmid
Copy link
Contributor Author

maschmid commented Feb 2, 2021

Yes, but it's not just the defaults, it's also the ability to configure those values via a configmap, like we added to IMC dispatcher in https://github.com/knative/eventing/pull/4465/files#diff-793cc23b5cb3cde6c57ad48d4e44b3252912e0e14ea50abb32fbd3904b053846R109-R114

(at least I don't see anything like that in eventing-kafka 0.19)

@slinkydeveloper
Copy link
Contributor

@maschmid in imc dispatcher we removed the ability to configure those values through CM, now they're injected in as env vars knative/eventing#4543

In any case, I'll PR the new defaults

@slinkydeveloper
Copy link
Contributor

/assign

slinkydeveloper added a commit to slinkydeveloper/eventing-kafka that referenced this issue Feb 2, 2021
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
knative-prow-robot pushed a commit that referenced this issue Feb 2, 2021
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
knative-prow-robot pushed a commit to knative-prow-robot/eventing-kafka that referenced this issue Feb 2, 2021
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
knative-prow-robot added a commit that referenced this issue Feb 2, 2021
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

Co-authored-by: slinkydeveloper <francescoguard@gmail.com>
slinkydeveloper added a commit to slinkydeveloper/eventing-kafka that referenced this issue Feb 2, 2021
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

Co-authored-by: slinkydeveloper <francescoguard@gmail.com>
openshift-merge-robot referenced this issue in openshift-knative/eventing-kafka Feb 2, 2021
* Fix #347 (#354)

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

Co-authored-by: slinkydeveloper <francescoguard@gmail.com>

* Fix #342 (#355)

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

Co-authored-by: slinkydeveloper <francescoguard@gmail.com>

Co-authored-by: Knative Prow Robot <knative-prow-robot@google.com>
slinkydeveloper added a commit to slinkydeveloper/eventing-kafka that referenced this issue Feb 3, 2021
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
knative-prow-robot pushed a commit that referenced this issue Feb 4, 2021
* Fix #342

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

* Commit mistake

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
knative-prow-robot pushed a commit to knative-prow-robot/eventing-kafka that referenced this issue Feb 4, 2021
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
knative-prow-robot added a commit that referenced this issue Feb 5, 2021
* Fix #342

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

* Commit mistake

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

Co-authored-by: slinkydeveloper <francescoguard@gmail.com>
slinkydeveloper added a commit to slinkydeveloper/eventing-kafka that referenced this issue Feb 5, 2021
* Fix knative-extensions#342

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

* Commit mistake

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
(cherry picked from commit b7ca3d0)
openshift-merge-robot referenced this issue in openshift-knative/eventing-kafka Feb 5, 2021
* Fix #342

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

* Commit mistake

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
(cherry picked from commit b7ca3d0)
matzew pushed a commit to matzew/eventing-kafka that referenced this issue Apr 19, 2021
* Fix knative-extensions#347 (knative-extensions#354)

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

Co-authored-by: slinkydeveloper <francescoguard@gmail.com>

* Fix knative-extensions#342 (knative-extensions#355)

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

Co-authored-by: slinkydeveloper <francescoguard@gmail.com>

Co-authored-by: Knative Prow Robot <knative-prow-robot@google.com>
openshift-merge-robot referenced this issue in openshift-knative/eventing-kafka Apr 19, 2021
* Backport (#45)

* Fix #347 (#354)

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

Co-authored-by: slinkydeveloper <francescoguard@gmail.com>

* Fix #342 (#355)

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

Co-authored-by: slinkydeveloper <francescoguard@gmail.com>

Co-authored-by: Knative Prow Robot <knative-prow-robot@google.com>

* Use CE connection args available, instead of hardcoded values (#440)

Co-authored-by: Francesco Guardiani <francescoguard@gmail.com>
Co-authored-by: Knative Prow Robot <knative-prow-robot@google.com>
Co-authored-by: Ali Ok <aliok@redhat.com>
matzew pushed a commit to matzew/eventing-kafka that referenced this issue Sep 24, 2021
…o cluster pool (knative-extensions#342)

* Use dependencies instead of IMAGE_FORMAT and switch to cluster pool

Signed-off-by: Ahmed Abdalla <aabdelre@redhat.com>

* update the generate-ci script to match dptp latest changes

Signed-off-by: Ahmed Abdalla <aabdelre@redhat.com>

* put test image template in double quote

Signed-off-by: Ahmed Abdalla <aabdelre@redhat.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants