-
Notifications
You must be signed in to change notification settings - Fork 655
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
Check that at least one message has been consumed before breaking to … #155
base: master
Are you sure you want to change the base?
Conversation
…prevent hanging on messages that are larger than max_bytes
Can one of the admins verify this patch? |
@confluentinc It looks like @kjvalencik just signed our Contributor License Agreement. 👍 Always at your service, clabot |
@ewencp Is this something that is acceptable to merge? |
@kjvalencik This is a parameter that the normal Java clients actually enforce and refuse to return data if it exceeds the configured size. In fact, brokers are also supposed to filter messages that are too large, such that you need to coordinate settings across producer, broker, and consumer to get larger messages to make it through the full pipleine. This can potentially be pretty significant. If I configure the broker (or one topic on the broker) to accept larger messages, I can do things like produce a 1GB message. Then consumers that might not be expecting such large messages can easily run into memory issues. Of course the 1GB example is arbitrary, if you remove the size limit in order to return at least one message, then the client has to accept arbitrarily large messages. I'm not necessarily opposed to merging a change like this, but |
The issue I am having is that I have a couple of topics with wildly With the normal Java consumer, this is okay because health checks are not But, this isn't possible in kafka rest because pulling messages is the only There are a few possible solutions:
One last option would be to implement a max messages limit. Because of the way the query parameters provided max bytes is already using REST to buffer, this doesn't really differ much. However, it is a big departure from the Java client philosophy, so I wouldn't recommend it. Thanks!
|
Having looked into this area as part of my pull request I agree with @ewencp that it would be a bit of a significant change. With regards heartbeat, we're using the max bytes to our advantage. We have a heartbeat thread that makes a request to kafka-rest for messages with max bytes set to 1byte. This will never return a message (non of our messages are that small!) but keeps the consumer active. Would that work for you? Alan |
I had considered that work around. The issue with using that approach is it is a very expensive way to do a heartbeat (possibly due to one of these: #154, #162). Although, I haven't had a chance to investigate. We are already having significant cpu usage with the current load (consuming two CPU cores all of the time, with 15 seconds of lagtime between batches) and I am concerned that the additional load would be unreasonable. In regards to @gawth, I think my preferred change would be a dedicated, lightweight, heartbeat endpoint. This could also potentially decrease load because we would be able to have fewer calls to fetch. In the meantime, I'm content continuing to use a forked branch with this change. |
We've got a low number of topics at the moment so not been an issue for us for the number of health checks we need to do. How many topics/partitions are you dealing with? Ta, |
Also, running 9 instances of |
@gawth How would you feel about this change if it was updated to make Logic:
|
We just spent two days troubleshooting a slightly different problem caused by the same code. Yesterday we observed that the consumer lag on some partitions kept constantly growing. The REST client was requesting 32MB max_bytes, the REST proxy consumer was configured to read up to 64MB and the message that caused the problem was 40MB in size. The code change in this PR request would have fixed our issue. I also understand the concern that this code change may cause some existing clients to experience higher memory usage. However, as it stands right now the client has no way to determine if the topic has no more messages or it's just stuck on a larger message than max_bytes. At the very minimum an exception should be thrown and converted to 429 or some 5xx response code if (bytesConsumed == 0 && roughMsgSize > maxResponseBytes). |
|
Check that at least one message has been consumed before breaking to prevent hanging on messages that are larger than max_bytes.
Steps to reproduce:
Expected: Response contains one message.
Actual: Response contains no messages.