New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kafka: add support for active brokers in Producers #169
Comments
@gm42 does sarama not handle this automatically? KeepAlice in sarama.Config could do the trick or not? |
@mantzas this is about checking that the Example use-case: when implementing the health check of a service one should ping on each of the subsystems' client for connectivity/health status. The mentioned issue (IBM/sarama#1341) suggests to check that the set of brokers is not empty, which seems like a good way to measure the health of the cluster since the |
@gm42 Do you propose to make this change in producers, consumers or both? |
@mantzas the change necessarily affects all of them: there is a There are in my opinion two approaches to this:
|
@gm42 I would go for the second option. But let me ask a question do understand better what your are proposing:
|
The feature is useful/necessary to implement service health checks (think of them in the Ref: https://docs.docker.com/compose/compose-file/#healthcheck and https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-a-liveness-http-request |
@gm42 I am aware of such checks as patron supports Kubernetes liveness and readiness checks. |
@mantzas the health check should not correspond to "HTTP port is open and listening" but to the status of underlying components. This is a strategy discussion and I am going to involve more people to see how we want to proceed. |
That's absolutely valid and can be another way to set the state to un-healthy but checking for connectivity is also very important. The reason for this is that some services can stay for a long time without consuming a message or producing one. Some services load data periodically so there will be spikes of messages and periods of nothing being produced there. It is more convenient for the teams maintaining those services to know that the service can not connect the the broker beforehand rather than once the errors start to hit. |
Yes, we actually might want to have both, eventually, as they cover different aspects. The health checks are part of the "fail early and consistently" approach which allows to be aware of problems also in situations of load testing and QA. |
@mantzas do we already have in Patron a concept of "dependable component"s? e.g. Patron computes the health check of the service based on all of its components, by asking each component if they are healthy. We could frame the discussion into that; I am going to read the Patron documentation, code and issues/PRs about this. |
My issue is not about liveness and readiness but that with Kafka consumer and producer which i did not get how you can achieve this. |
@mantzas it is explained here: #169 (comment) To use that freedom we would have to be able to do a "ping" on the consumer's client or producer's client, that's what is needed for the health check. "ping" is a correct analogy because when using Kafka there are network concerns to be covered and cluster/partitioning concerns (even if Kafka is network-accessible it might not be available to do message brokerage). The I can make a PR for both the Patron changes and including an example on how to use this for the health/readiness checks. |
@gm42 you mention the how, but I am interested in the why as per comment #169 (comment).
|
readiness != liveness. This check should only be part of the readiness
readiness probes do not affect the running service, let's start from that distinction. See the discussion in mozmeao/infra#660 (comment) (as an example), I think they do a sane choice there. They check dependencies only for the readiness probe. |
I will reduce the scope of this to simply the producers and make a small PR to implement this functionality; thanks to all parties for the interesting and open discussion 🎉 I have learnt a thing or two about best practices along the way! |
Is your feature request related to a problem? Please describe
It is necessary to check the healthiness of Kafka consumers/producers; in IBM/sarama#1341 it is mentioned that this could be done by checking that there are active brokers (they are checked periodically by the client anyways).
Describe the solution
The minimally invasive solution is to use https://godoc.org/github.com/Shopify/sarama#NewAsyncProducerFromClient in Patron and then expose the
Brokers()
method.This solution should work for both consumers and producers if we expose functionality of theClient
.We will focus on the producers only.
Additional context
This is related to #148, in the sense that more functionality of the Kafka client library is necessary.
The text was updated successfully, but these errors were encountered: