You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by Jason Gustafson <ja...@confluent.io> on 2015/08/11 22:19:50 UTC

[DISCUSS] Client-side Assignment for New Consumer

Hi Kafka Devs,

One of the nagging issues in the current design of the new consumer has
been the need to support a variety of assignment strategies. We've
encountered this in particular in the design of copycat and the processing
framework (KIP-28). From what I understand, Samza also has a number of use
cases with custom assignment needs. The new consumer protocol supports new
assignment strategies by hooking them into the broker. For many
environments, this is a major pain and in some cases, a non-starter. It
also challenges the validation that the coordinator can provide. For
example, some assignment strategies call for partitions to be assigned
multiple times, which means that the coordinator can only check that
partitions have been assigned at least once.

To solve these issues, we'd like to propose moving assignment to the
client. I've written a wiki which outlines some protocol changes to achieve
this:
https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal.
To summarize briefly, instead of the coordinator assigning the partitions
itself, all subscriptions are forwarded to each member of the group which
then decides independently which partitions it should consume. The protocol
provides a mechanism for the coordinator to validate that all consumers use
the same assignment strategy, but it does not ensure that the resulting
assignment is "correct." This provides a powerful capability for users to
control the full data flow on the client side. They control how data is
written to partitions through the Partitioner interface and they control
how data is consumed through the assignment strategy, all without touching
the server.

Of course nothing comes for free. In particular, this change removes the
ability of the coordinator to validate that commits are made by consumers
who were assigned the respective partition. This might not be too bad since
we retain the ability to validate the generation id, but it is a potential
concern. We have considered alternative protocols which add a second
round-trip to the protocol in order to give the coordinator the ability to
confirm the assignment. As mentioned above, the coordinator is somewhat
limited in what it can actually validate, but this would return its ability
to validate commits. The tradeoff is that it increases the protocol's
complexity which means more ways for the protocol to fail and consequently
more edge cases in the code.

It also misses an opportunity to generalize the group membership protocol
for additional use cases. In fact, after you've gone to the trouble of
moving assignment to the client, the main thing that is left in this
protocol is basically a general group management capability. This is
exactly what is needed for a few cases that are currently under discussion
(e.g. copycat or single-writer producer). We've taken this further step in
the proposal and attempted to envision what that general protocol might
look like and how it could be used both by the consumer and for some of
these other cases.

Anyway, since time is running out on the new consumer, we have perhaps one
last chance to consider a significant change in the protocol like this, so
have a look at the wiki and share your thoughts. I've no doubt that some
ideas seem clearer in my mind than they do on paper, so ask questions if
there is any confusion.

Thanks!
Jason

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Ewen Cheslack-Postava <ew...@confluent.io>.
On Tue, Aug 11, 2015 at 10:03 PM, Onur Karaman <onurkaraman.apache@gmail.com
> wrote:

> Just to make the conversation a bit easier (I don't think we have really
> established names for these modes yet), basically with the new
> KafkaConsumer today there's:
> - "external management", where the application figures out the group
> management and partition assignment externally
> - "kafka management", where kafka coordinators figure out the group
> management and partition assignment.
>
> With today's design, any sort of custom assignment strategy means you'll
> have to use external management. This proposal adjusts kafka management to
> a place where kafka still provides the group management, but the
> application figures out the partition assignment.
>
> One concern I have regarding the JoinGroupResponse:
> With kafka management today, there's only one thing looking up the
> partitions and figuring out the assignment - the coordinator. All of the
> consumers in the group get a consistent view of the assignment. The
> proposal in the wiki said JoinGroupResponse only contains the member list
> and member metadata. But the consumers still need to find out all the
> partitions for all the topics their group is interested in so that they can
> run the assignment algorithm. You'd probably want to also include all of
> these partitions in the JoinGroupResponse. Otherwise you might run into
> split-brain problems and would require additional coordination steps. I
> don't see how the coordinator can provide these partitions if you put the
> topic subscriptions into the opaque protocol metadata which the coordinator
> never looks at.
>

If you look at the example embedded consumer protocol, you can see that
each client includes the # of partitions it currently thinks exist in the
topic. This does require every client to look those up via metadata
requests (but that's not that bad and they need that info for consuming
data anyway). However, it also means that you can have disagreements if one
consumer's metadata is out of date. There are a couple of options for
resolving that. One is for each consumer to detect this and immediately
refetch metadata and start a new JoinGroup round. This is a bit annoying,
but should resolve the issue very quickly; also this type of change should
be relatively rare, so it's not necessarily worth optimizing. A different
option is for all consumers to just assume whoever reported the max # of
partitions is right and proceed with assignment that way.


>
> Another concern I had was about consumer group rebalances:
> Today, a consumer group can rebalance due to consumer
> joins/failures/leaves(KAFKA-2397), topic partition expansions, or topic
> deletion. I don't see how any of the topic related rebalances can happen if
> you put the topic subscriptions into the opaque protocol metadata which the
> coordinator never looks at.
>
>
Topic partition expansions and deletion can both be picked up by the
consumers as they periodically refresh metadata. At first I thought this
would be slower to be picked up than with the broker watching for those
events. However, in practice I don't think it really is. First of all, even
with the broker watching for those events, you still have to wait for at
least 1 heartbeat period for everyone to get notified (since we can't
proactively send notifications, they are tied to the heartbeat requests).
Second, if you have even a few consumers, they may have reasonably well
distributed metadata updates such that you're not necessarily waiting a
full metadata update period, but rather something closer to metadata update
period / # of consumers.

This does make the client implementation have to do a bit more, and that
may be a significant consideration since it makes 3rd party consumers a bit
harder to write. However, since you already need to be updating metadata it
doesn't seem like a huge additional burden.


> I'm also uncertain about the value of adding a list of SupportedProtocols
> to the JoinGroupRequest as opposed to just one. Adding heuristics to the
> coordinator regarding which protocol to choose seems to add complexity to
> the coordinator and add uncertainty to the consumers over what strategy
> would actually run.
>

Definitely adds a bit of complexity. However, there are a couple of
important use cases centered around zero downtime upgrades. Consider two
scenarios:

1. I start with the default configuration for my consumers, which gives me
range assignment. Now, I realize that was a poor choice -- it's actually
important to use a sticky assignment strategy. If I want to do a rolling
update so my service continues running while I switch to the new config, I
need to be be able to keep the group running in the old mode (range) until
everyone is updated and then they can all switch over. If the metadata
included is different at all, then at least for some time I'll need to be
able to provide both as options -- only once everyone is updated can the
new stick partitioning approach be used.

2. Suppose I'm using a resource-based assignment strategy. Over time, my
resource model grows more complex. Maybe my first version only includes
CPU. In order to use a newer version that now also adds memory, I'm going
to have to send metadata in a new format (we've added the "memory" field).
If you're careful, you may have planned ahead to handle this and guarantee
that the older assignment strategy code can still decode the metadata from
the new version (e.g. you use JSON and just ignore the new fields) and that
everyone can figure out which version of the assignment strategy code they
should use (i.e. they scan through all metadata returned and find the
minimum format version). However, you can also avoid having to be very
careful about it by simply including both formats of metadata and using two
different protocols, i.e. resource-v1 and resource-v2.

The expectation is that the overhead here isn't really that high, and it's
only used during JoinGroup which should not be happening constantly.



>
> I have more questions, but I just wanted to get these initial concerns out
> there.
>
> - Onur
>
> On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <ja...@confluent.io>
> wrote:
>
> > Hi Kafka Devs,
> >
> > One of the nagging issues in the current design of the new consumer has
> > been the need to support a variety of assignment strategies. We've
> > encountered this in particular in the design of copycat and the
> processing
> > framework (KIP-28). From what I understand, Samza also has a number of
> use
> > cases with custom assignment needs. The new consumer protocol supports
> new
> > assignment strategies by hooking them into the broker. For many
> > environments, this is a major pain and in some cases, a non-starter. It
> > also challenges the validation that the coordinator can provide. For
> > example, some assignment strategies call for partitions to be assigned
> > multiple times, which means that the coordinator can only check that
> > partitions have been assigned at least once.
> >
> > To solve these issues, we'd like to propose moving assignment to the
> > client. I've written a wiki which outlines some protocol changes to
> achieve
> > this:
> >
> >
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> > .
> > To summarize briefly, instead of the coordinator assigning the partitions
> > itself, all subscriptions are forwarded to each member of the group which
> > then decides independently which partitions it should consume. The
> protocol
> > provides a mechanism for the coordinator to validate that all consumers
> use
> > the same assignment strategy, but it does not ensure that the resulting
> > assignment is "correct." This provides a powerful capability for users to
> > control the full data flow on the client side. They control how data is
> > written to partitions through the Partitioner interface and they control
> > how data is consumed through the assignment strategy, all without
> touching
> > the server.
> >
> > Of course nothing comes for free. In particular, this change removes the
> > ability of the coordinator to validate that commits are made by consumers
> > who were assigned the respective partition. This might not be too bad
> since
> > we retain the ability to validate the generation id, but it is a
> potential
> > concern. We have considered alternative protocols which add a second
> > round-trip to the protocol in order to give the coordinator the ability
> to
> > confirm the assignment. As mentioned above, the coordinator is somewhat
> > limited in what it can actually validate, but this would return its
> ability
> > to validate commits. The tradeoff is that it increases the protocol's
> > complexity which means more ways for the protocol to fail and
> consequently
> > more edge cases in the code.
> >
> > It also misses an opportunity to generalize the group membership protocol
> > for additional use cases. In fact, after you've gone to the trouble of
> > moving assignment to the client, the main thing that is left in this
> > protocol is basically a general group management capability. This is
> > exactly what is needed for a few cases that are currently under
> discussion
> > (e.g. copycat or single-writer producer). We've taken this further step
> in
> > the proposal and attempted to envision what that general protocol might
> > look like and how it could be used both by the consumer and for some of
> > these other cases.
> >
> > Anyway, since time is running out on the new consumer, we have perhaps
> one
> > last chance to consider a significant change in the protocol like this,
> so
> > have a look at the wiki and share your thoughts. I've no doubt that some
> > ideas seem clearer in my mind than they do on paper, so ask questions if
> > there is any confusion.
> >
> > Thanks!
> > Jason
> >
>



-- 
Thanks,
Ewen

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Onur Karaman <on...@gmail.com>.
Just to make the conversation a bit easier (I don't think we have really
established names for these modes yet), basically with the new
KafkaConsumer today there's:
- "external management", where the application figures out the group
management and partition assignment externally
- "kafka management", where kafka coordinators figure out the group
management and partition assignment.

With today's design, any sort of custom assignment strategy means you'll
have to use external management. This proposal adjusts kafka management to
a place where kafka still provides the group management, but the
application figures out the partition assignment.

One concern I have regarding the JoinGroupResponse:
With kafka management today, there's only one thing looking up the
partitions and figuring out the assignment - the coordinator. All of the
consumers in the group get a consistent view of the assignment. The
proposal in the wiki said JoinGroupResponse only contains the member list
and member metadata. But the consumers still need to find out all the
partitions for all the topics their group is interested in so that they can
run the assignment algorithm. You'd probably want to also include all of
these partitions in the JoinGroupResponse. Otherwise you might run into
split-brain problems and would require additional coordination steps. I
don't see how the coordinator can provide these partitions if you put the
topic subscriptions into the opaque protocol metadata which the coordinator
never looks at.

Another concern I had was about consumer group rebalances:
Today, a consumer group can rebalance due to consumer
joins/failures/leaves(KAFKA-2397), topic partition expansions, or topic
deletion. I don't see how any of the topic related rebalances can happen if
you put the topic subscriptions into the opaque protocol metadata which the
coordinator never looks at.

I'm also uncertain about the value of adding a list of SupportedProtocols
to the JoinGroupRequest as opposed to just one. Adding heuristics to the
coordinator regarding which protocol to choose seems to add complexity to
the coordinator and add uncertainty to the consumers over what strategy
would actually run.

I have more questions, but I just wanted to get these initial concerns out
there.

- Onur

On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <ja...@confluent.io> wrote:

> Hi Kafka Devs,
>
> One of the nagging issues in the current design of the new consumer has
> been the need to support a variety of assignment strategies. We've
> encountered this in particular in the design of copycat and the processing
> framework (KIP-28). From what I understand, Samza also has a number of use
> cases with custom assignment needs. The new consumer protocol supports new
> assignment strategies by hooking them into the broker. For many
> environments, this is a major pain and in some cases, a non-starter. It
> also challenges the validation that the coordinator can provide. For
> example, some assignment strategies call for partitions to be assigned
> multiple times, which means that the coordinator can only check that
> partitions have been assigned at least once.
>
> To solve these issues, we'd like to propose moving assignment to the
> client. I've written a wiki which outlines some protocol changes to achieve
> this:
>
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> .
> To summarize briefly, instead of the coordinator assigning the partitions
> itself, all subscriptions are forwarded to each member of the group which
> then decides independently which partitions it should consume. The protocol
> provides a mechanism for the coordinator to validate that all consumers use
> the same assignment strategy, but it does not ensure that the resulting
> assignment is "correct." This provides a powerful capability for users to
> control the full data flow on the client side. They control how data is
> written to partitions through the Partitioner interface and they control
> how data is consumed through the assignment strategy, all without touching
> the server.
>
> Of course nothing comes for free. In particular, this change removes the
> ability of the coordinator to validate that commits are made by consumers
> who were assigned the respective partition. This might not be too bad since
> we retain the ability to validate the generation id, but it is a potential
> concern. We have considered alternative protocols which add a second
> round-trip to the protocol in order to give the coordinator the ability to
> confirm the assignment. As mentioned above, the coordinator is somewhat
> limited in what it can actually validate, but this would return its ability
> to validate commits. The tradeoff is that it increases the protocol's
> complexity which means more ways for the protocol to fail and consequently
> more edge cases in the code.
>
> It also misses an opportunity to generalize the group membership protocol
> for additional use cases. In fact, after you've gone to the trouble of
> moving assignment to the client, the main thing that is left in this
> protocol is basically a general group management capability. This is
> exactly what is needed for a few cases that are currently under discussion
> (e.g. copycat or single-writer producer). We've taken this further step in
> the proposal and attempted to envision what that general protocol might
> look like and how it could be used both by the consumer and for some of
> these other cases.
>
> Anyway, since time is running out on the new consumer, we have perhaps one
> last chance to consider a significant change in the protocol like this, so
> have a look at the wiki and share your thoughts. I've no doubt that some
> ideas seem clearer in my mind than they do on paper, so ask questions if
> there is any confusion.
>
> Thanks!
> Jason
>

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Ewen Cheslack-Postava <ew...@confluent.io>.
Agreed that talking about actual numbers would be helpful here.

Only 2 things affect this metadata: list of topics and number of
partitions. I don't think either of those can change *that* frequently to
be relevant to our 3s default heartbeat and 30s default session timeout, or
even the 5 minute metadata age.

Are there actual use cases where there is a steady stream of topics that
are constantly being added/removed (and they must be deleted since the
brokers won't scale up to a large number of topics anyway), or where # of
partitions on topics are constantly being adjusted (which presumably only
works for topics you don't use keys in since this would otherwise break
semantic partitioning)?

-Ewen


On Sat, Aug 15, 2015 at 9:14 AM, Jason Gustafson <ja...@confluent.io> wrote:

> Hey Jiangjie,
>
> I was thinking about the same problem. When metadata is changing
> frequently, the clients may not be able to ever find agreement on the
> current state. The server doesn't have this problem, as you say, because it
> can just take a snapshot and send that to the clients. Adding a dampening
> setting to the client would help if churn is sporadic, but not if it is
> steady. I think the metadata would have to be changing really frequently
> for this to be a problem practically, but this is a case where the
> server-side approach has an advantage.
>
> Including the metadata in the join group response would require making the
> subscription available to the coordinator, right? We lose a little bit of
> the generality of the protocol, but it might not be too bad since most use
> cases for reusing this protocol have a similar need for metadata (and they
> can always pass an empty subscription if they don't). We've gone back and
> forth a few times on this, and I'm generally not opposed. It might help if
> we try to quantify the impact of the metadata churn in practice. I think
> the rate of change would have to be in the low seconds for this to be a
> real problem. It does seem nice though that we have a way to manage even
> this much churn when we do this.
>
> -Jason
>
>
>
> On Fri, Aug 14, 2015 at 9:03 PM, Jiangjie Qin <jq...@linkedin.com.invalid>
> wrote:
>
> > Ewen,
> >
> > I agree that if there is a churn in metadata, the consumers need several
> > rounds of rebalances to succeed. The difference I am thinking is that
> with
> > coordinator as single source of truth, we can let the consumer finish one
> > round of rebalance, work for a while and start the next round of
> rebalance.
> > If we purely depend on the consumers to synchronize by themselves based
> on
> > different metadata sources, is it possible we have some groups spending a
> > lot of time on rebalancing but not able to make too much progress in
> > consuming?
> >
> > I'm thinking can we let consumers to fetch metadata only from their
> > coordinator? So the rebalance can be done in the following way:
> >
> > 1. Consumers refresh their metadata periodically
> > 2. If one of the consumer sees a change in metadata that triggers a
> > rebalance, it sends JoinGroupRequest to coordinator.
> > 3. Once the coordinator receives the first JoinGroupRequest of a group,
> it
> > takes a snapshot of current metadata and the group enters
> prepare-rebalance
> > state.
> > 4. The metadata snapshot will be used for this round of rebalance. i.e.
> the
> > metadata snapshot will be sent to consumers in JoinGroupResponse.
> > 4.1 If the consumers are subscribing to explicit topic lists (not regex),
> > the JoinGroupResponse needs only contain the metadata of all topics the
> > group is interested.
> > 4.2 If the consumers are subscribing using regex, all the topic metadata
> > will be returned to the consumer.
> > 5. Consumers get JoinGroupResponse, refresh metadata using the metadata
> in
> > JoinGroupResponse, run algorithm to assign partitions and start consume.
> > 6. Go back to 1.
> >
> > The benefit here is that we can let rebalance finish in one round, and
> all
> > the rest of changes will be captured in next consumer metadata refresh -
> so
> > we get group commit. One concern might be letting consumer refresh
> metadata
> > from coordinator might cause issue for big consumer groups. Maybe that is
> > OK because metadata refresh is infrequent.
> >
> > This approach actually is very similar to what is proposed now: rebalance
> > is triggered by metadata refresh, consumer provides subscription list to
> > pass around. The only difference is that we don't need metadata hash
> > anymore because the metadata is guaranteed to be the same. Replacing
> > metadata hash with actual metadata will not have too much overhead for
> > small subscription groups. There will be some overhead for regex
> > subscriptions, but this can save the potential extra round of metadata
> > fetch and will only occur when consumer see metadata change, which is
> > infrequent.
> >
> > Any thoughts?
> >
> > Thanks,
> >
> > Jiangjie (Becket) Qin
> >
> >
> > On Fri, Aug 14, 2015 at 12:57 PM, Ewen Cheslack-Postava <
> ewen@confluent.io
> > >
> > wrote:
> >
> > > On Fri, Aug 14, 2015 at 10:59 AM, Jiangjie Qin
> <jqin@linkedin.com.invalid
> > >
> > > wrote:
> > >
> > > > Neha and Ewen,
> > > >
> > > > About the metadata change frequency. I guess it really depends on how
> > > > frequent the metadata change might occur. If we run Kafka as a
> > service, I
> > > > can see that happens from time to time. As I can imagine people will
> > > create
> > > > some topic, test and maybe delete the topic in some automated test.
> If
> > > so,
> > > > the proposed protocol might be a little bit vulnerable.
> > > >
> > > > More specifically the scenario I am thinking is:
> > > > 1. Consumer 0 periodically refresh metadata and detected a metadata
> > > change.
> > > > So it sends a JoinGroupRequest with metadata_hash_0.
> > > > 2. Consumer 1 was notified by controller to start a rebalance, so it
> > > > refreshes its metadata and send a JoingGroupRequest with
> > metadata_hash_1,
> > > > which is different from metadata hash 0.
> > > > 3. Rebalance failed and both consumer refresh there metadata again
> from
> > > > different brokers.
> > > > 4. Depending on the metadata change frequency(or some admin operation
> > > like
> > > > partition reassigment), they may or may not have the same metadata
> > > > returned, so the restart from 3 again.
> > > >
> > > > I agree that step 4 might not be a big concern if consumers updates
> > > > metadata at almost the same time, but I'm a little bit worried
> whether
> > > that
> > > > assumption really stands because we do not have control over how
> > frequent
> > > > the metadata can change.
> > > >
> > > >
> > > Is this really that different from what would happen if the coordinator
> > > distributed the metadata to consumers? In that case you would trivially
> > > have everyone in a consistent state, but those metadata changes would
> > still
> > > cause churn and require JoinGroup rounds, during which processing is
> > > stalled for the nodes that are waiting on other members to re-join the
> > > group.
> > >
> > > -Ewen
> > >
> > >
> > > > Thanks,
> > > >
> > > > Jiangjie (Becket) Qin
> > > >
> > > > On Fri, Aug 14, 2015 at 2:03 AM, Ewen Cheslack-Postava <
> > > ewen@confluent.io>
> > > > wrote:
> > > >
> > > > > On Thu, Aug 13, 2015 at 11:07 PM, Neha Narkhede <neha@confluent.io
> >
> > > > wrote:
> > > > >
> > > > > > Becket,
> > > > > >
> > > > > > As you say, the metadata hash addresses the concern you
> originally
> > > > raised
> > > > > > about large topic subscriptions. Can you please list other
> problems
> > > you
> > > > > are
> > > > > > raising more clearly? It is more helpful to know problems that
> the
> > > > > proposal
> > > > > > does not address or addresses poorly.
> > > > > >
> > > > > > Regarding other things you said -
> > > > > >
> > > > > > it is required that each
> > > > > > > consumer refresh their metadata before sending a
> JoinGroupRequest
> > > > > > >
> > > > > >
> > > > > > This is required for wildcard topic subscriptions anyway. So this
> > > > > proposal
> > > > > > does not introduce a regression. We had agreed earlier that it
> does
> > > not
> > > > > > make sense for the server to deserialize regular expressions sent
> > by
> > > > the
> > > > > > consumer.
> > > > > >
> > > > >
> > > > > I don't think consumers need to do a metadata refresh before
> sending
> > a
> > > > > JoinGroupRequest. Metadata changes that affect assignment are rare
> --
> > > it
> > > > > requires changing the number of partitions in a topic. But you
> might
> > > > send a
> > > > > JoinGroupRequest simply because a new member is trying to join the
> > > group.
> > > > > That case is presumably much more common.
> > > > >
> > > > > I think it's actually a good idea to have the first JoinGroup cycle
> > > fail
> > > > in
> > > > > some cases, and has little impact. Lets say the metadata does
> change
> > > > > because partitions are added. Then we might fail in the first
> round,
> > > but
> > > > > then all members detect that issue *immediately*, refresh their
> > > metadata,
> > > > > and submit a new join group request. This second cycle does not
> > > require a
> > > > > full heartbeat cycle. It happens much more quickly because everyone
> > > > > detected the inconsistency based on the first JoinGroupResponse.
> The
> > > > > inconsistency should be resolved very quickly (barring other
> failures
> > > > like
> > > > > a member leaving mid-rebalance)
> > > >
> > > >
> > > >
> > > >
> > > > > >
> > > > > >
> > > > > > > the metadata might still be inconsistent if there is a topic or
> > > > > partition
> > > > > > > change because the
> > > > > > > UpdateMetadataRequest from controller might be handled at
> > different
> > > > > time.
> > > > > > >
> > > > > >
> > > > > > Topic metadata does not change frequently and even if it did, a
> > > couple
> > > > > > rebalance attempts will be needed whether the coordinator drives
> > the
> > > > > > assignments or the consumer. Because guess how the coordinator
> > knows
> > > > > about
> > > > > > the topic metadata changes -- indirectly through either a zk
> > callback
> > > > or
> > > > > > UpdateMetadataRequest, so it is completely possible the
> coordinator
> > > > sees
> > > > > > the topic metadata changes in batches, not all at once.
> > > > > >
> > > > >
> > > > > > On Thu, Aug 13, 2015 at 10:50 PM, Neha Narkhede <
> neha@confluent.io
> > >
> > > > > wrote:
> > > > > >
> > > > > > > Ewen/Jason,
> > > > > > >
> > > > > > > The metadata hash is a clever approach and certainly addresses
> > the
> > > > > > problem
> > > > > > > of large metadata for consumers like mirror maker. Few
> comments -
> > > > > > >
> > > > > > >
> > > > > > >    1. In the interest of simplifying the format of the
> consumer's
> > > > > > >    metadata - Why not just always include only the topic names
> in
> > > the
> > > > > > metadata
> > > > > > >    followed by the metadata hash? If the metadata hash check
> > > > succeeds,
> > > > > > each
> > > > > > >    consumer uses the # of partitions it had fetched. If it
> > fails, a
> > > > > > rebalance
> > > > > > >    happens and the metadata is not used anyway.
> > > > > >
> > > > >
> > > > > Doing this requires that every consumer always fetch the full
> > metadata.
> > > > The
> > > > > most common use case is consumers that just want to consume one or
> a
> > > > couple
> > > > > of topics, in which case grabbing all metadata for the entire
> cluster
> > > is
> > > > > wasteful. If I subscribe only to topic A, why make all consumers
> grab
> > > > > metadata for the entire topic (and need to rebalance every time it
> > > > > changes!). Including the # of partitions for each topic lets you
> > avoid
> > > > > having to grab the global set of metadata.
> > > > >
> > > > > So if you're just subscribing to one or a couple of topics, why not
> > > just
> > > > > compute the hash by filtering out everything but the topics you are
> > > > > subscribed to? The problem there is if you ever add/remove
> > > subscriptions
> > > > > and want to support rolling upgrades. If the group was subscribed
> to
> > > > topic
> > > > > A, but later changes require subscribing to A + B, then to achieve
> a
> > > > > seamless rolling upgrade would require one (old) consumer to be
> > > > subscribing
> > > > > to A and one (new) consumer to be subscribing to A+B. If we
> computed
> > > > > metadata hashes based on filtered metadata, those two would
> disagree
> > > and
> > > > we
> > > > > could not perform assignment while the upgrade was in progress.
> > > > >
> > > > > The solution is to differentiate between the cases when a very
> small
> > > > amount
> > > > > of the metadata is needed (one or a couple of topic subscriptions;
> > > > > communicate and share this via metadata in the JoinGroup protocol)
> vs
> > > > when
> > > > > *all* the metadata is needed (regex subscription; verify agreement
> > via
> > > > > hash).
> > > > >
> > > >
> > > > >
> > > > >
> > > > > > >    2. Do you need a topic list and topic regex to be separate?
> A
> > > > single
> > > > > > >    topic or list of topics can be expressed as a regex.
> > > > > >
> > > > >
> > > > > See above note about collecting all metadata when you really only
> > need
> > > it
> > > > > for 1 or 2 topics. There's probably some debate to be had about
> > whether
> > > > > this cost would be too high -- every consumer would need to request
> > the
> > > > > metadata for all topics, and they'd need to request that all every
> > time
> > > > > they might be out of date.
> > > > >
> > > > Are we going to allow consumers in the same group to subscribe to
> > > different
> > > > topic set? If we do, we need to let them refresh metadata for all the
> > > > topics a group is consuming from. If we don't then in the protocol we
> > > only
> > > > need a subscription set hash.
> > > >
> > > > >
> > > > >
> > > > > > >    3. Let's include a version explicitly at the beginning of
> the
> > > > > > >    ProtocolMetadata. The version dictates how to deserialize
> the
> > > > > > >    ProtocolMetadata blob and is consistent with the rest of
> > Kafka.
> > > > > >
> > > > >
> > > > > If I'm understanding correctly, in JoinGroupRequest I would change
> > > > >
> > > > > GroupProtocols          => [Protocol ProtocolMetadata]
> > > > >
> > > > > to
> > > > >
> > > > > GroupProtocols          => [Protocol ProtocolVersion
> > ProtocolMetadata]
> > > > >
> > > > > We had been talking about just baking the version into the Protocol
> > > > field,
> > > > > but making it separate seems perfectly reasonable to me. Jason, any
> > > issue
> > > > > with splitting the version out into a separate field like this?
> > > > >
> > > > > >
> > > > > > > That can simplify the metadata format to the following:
> > > > > > >
> > > > > > > GroupType => "consumer"
> > > > > > >>
> > > > > > >> Protocol => AssignmentStrategy
> > > > > > >>   AssignmentStrategy   => String
> > > > > > >>
> > > > > > >> ProtocolMetadata => Version Subscription
> > > AssignmentStrategyMetadata
> > > > > > >
> > > > > > >     Version                    => String
> > > > > > >
> > > > > > >   Subscription                 => TopicRegex MetadataHash
> > > > > > >>     TopicRegex                 => String
> > > > > > >>     MetadataHash               => String
> > > > > > >>   AssignmentStrategyMetadata   => bytes
> > > > > >
> > > > > >
> > > > > > >
> > > > > > > On Thu, Aug 13, 2015 at 6:28 PM, Jiangjie Qin
> > > > > <jqin@linkedin.com.invalid
> > > > > > >
> > > > > > > wrote:
> > > > > > >
> > > > > > >> Ewen and Jason,
> > > > > > >>
> > > > > > >> Thanks for the reply. Sorry I missed the metadata hash. Yes,
> > that
> > > > is a
> > > > > > >> clever approach and would solve my concern about the data
> > passing
> > > > > > around.
> > > > > > >> I
> > > > > > >> can see both pros and cons from doing this, though. The
> > advantage
> > > is
> > > > > we
> > > > > > >> don't need the topic metadata in JoinGroupResponse anymore.
> The
> > > > > downside
> > > > > > >> is
> > > > > > >> that now rebalance have extra dependency on the consensus of
> > > > metadata
> > > > > of
> > > > > > >> all consumers, which is obtained separately. So it is required
> > > that
> > > > > each
> > > > > > >> consumer refresh their metadata before sending a
> > JoinGroupRequest,
> > > > > > >> otherwise in some cases (e.g. wildcard consumers) will almost
> > > > > certainly
> > > > > > >> fail for the first rebalance attempt. Even if we do that,
> since
> > > the
> > > > > > >> consumers are getting metadata from different brokers, the
> > > metadata
> > > > > > might
> > > > > > >> still be inconsistent if there is a topic or partition change
> > > > because
> > > > > > the
> > > > > > >> UpdateMetadataRequest from controller might be handled at
> > > different
> > > > > > time.
> > > > > > >> Just want to make sure we think through the cases so the
> > protocol
> > > > does
> > > > > > not
> > > > > > >> cause us unexpected issues.
> > > > > > >>
> > > > > > >> About the number of consumers, I think with the current
> > liveliness
> > > > > > >> definition, we can tolerate churns by bumping up the session
> > > > timeout.
> > > > > > Also
> > > > > > >> I guess we will see an increasing number of consumers for new
> > > > > consumer,
> > > > > > >> because every the old consumer thread will probably become a
> > > > consumer.
> > > > > > >>
> > > > > > >> It is a valid concern for consumers that have large
> subscription
> > > > set.
> > > > > > This
> > > > > > >> might not be avoided though for client side assignment
> approach.
> > > One
> > > > > > >> solution is having topic names associate with a topic ID. And
> > only
> > > > use
> > > > > > >> topic ID in JoinGroupRequest and JoinGroupResponse, There is a
> > > > > > discussion
> > > > > > >> thread about this to solve the topic renaming case but this
> is a
> > > > > > >> completely
> > > > > > >> different discussion.
> > > > > > >>
> > > > > > >> Thanks,
> > > > > > >>
> > > > > > >> Jiangjie (Becket) Qin
> > > > > > >>
> > > > > > >>
> > > > > > >>
> > > > > > >> On Thu, Aug 13, 2015 at 2:14 PM, Jason Gustafson <
> > > > jason@confluent.io>
> > > > > > >> wrote:
> > > > > > >>
> > > > > > >> > Thanks Jiangjie, that information helps. I agree the
> protocol
> > > must
> > > > > > >> consider
> > > > > > >> > scalability. My point was that the synchronization barrier
> in
> > > the
> > > > > > >> current
> > > > > > >> > protocol already effectively limits the number of consumers
> > > since
> > > > it
> > > > > > >> > provides no way to gracefully handle churn. It wouldn't be
> > worth
> > > > > > >> worrying
> > > > > > >> > about scaling up to 100,000 members, for example, because
> > > there's
> > > > no
> > > > > > way
> > > > > > >> > the group would be stable. So we just need to set some clear
> > > > > > >> expectations
> > > > > > >> > on the size we can scale to, and that can help inform the
> > > > discussion
> > > > > > on
> > > > > > >> the
> > > > > > >> > size of messages in this protocol.
> > > > > > >> >
> > > > > > >> > Ewen and I were discussing this morning along similar lines
> to
> > > > what
> > > > > > >> you're
> > > > > > >> > suggesting. However, even if the coordinator decides on the
> > > > metadata
> > > > > > for
> > > > > > >> > the group, each member still needs to communicate its
> > > > subscriptions
> > > > > to
> > > > > > >> the
> > > > > > >> > rest of the group. This is nice for the regex case since the
> > > regex
> > > > > is
> > > > > > >> > probably small, but if the members have a large topic list,
> > then
> > > > we
> > > > > > have
> > > > > > >> > the same problem. One thing I was thinking about was whether
> > we
> > > > > really
> > > > > > >> need
> > > > > > >> > to handle different subscriptions for every member. If the
> > > > > coordinator
> > > > > > >> > could guarantee that all members had the same subscription,
> > then
> > > > > there
> > > > > > >> > would be no need for the coordinator to return the
> > subscriptions
> > > > for
> > > > > > >> each
> > > > > > >> > member. However, this would prevent graceful upgrades. We
> > might
> > > be
> > > > > > able
> > > > > > >> to
> > > > > > >> > fix that problem by allowing the consumer to provide two
> > > > > subscriptions
> > > > > > >> to
> > > > > > >> > allowing rolling updates, but that starts to sound pretty
> > nasty.
> > > > > > >> >
> > > > > > >> > -Jason
> > > > > > >> >
> > > > > > >> > On Thu, Aug 13, 2015 at 1:41 PM, Jiangjie Qin
> > > > > > <jqin@linkedin.com.invalid
> > > > > > >> >
> > > > > > >> > wrote:
> > > > > > >> >
> > > > > > >> > > Jason,
> > > > > > >> > >
> > > > > > >> > > The protocol has to consider the scalability. The protocol
> > in
> > > > the
> > > > > > wiki
> > > > > > >> > > means the JoinGroupResoponse size would be:
> > > > > > >> > > NumberOfTopics * (AvgTopicNameLength + 4) *
> > > > (NumberOfConsumers)^2
> > > > > > >> > >
> > > > > > >> > > To give some real number, we have 26-node Mirror Maker
> > > cluster,
> > > > > each
> > > > > > >> > with 4
> > > > > > >> > > consumers. That is 104 consumers using regex ".*". And
> most
> > of
> > > > our
> > > > > > >> > clusters
> > > > > > >> > > have around 3000 topics, whose topic name are typically
> > around
> > > > 20
> > > > > > >> > > characters.
> > > > > > >> > >
> > > > > > >> > > I think the key issue for client side partition assignment
> > > logic
> > > > > is
> > > > > > to
> > > > > > >> > make
> > > > > > >> > > sure 1) all the clients run the same algorithm. 2) all the
> > > > clients
> > > > > > >> make
> > > > > > >> > > decision on the same topic metadata. The second purpose
> can
> > be
> > > > > done
> > > > > > by
> > > > > > >> > > simply letting coordinator provide the topic metadata and
> > all
> > > > then
> > > > > > >> member
> > > > > > >> > > information as source of truth. Is it necessary to pass
> > topic
> > > > > > >> metadata of
> > > > > > >> > > each consumer around? Can we keep the protocol metadata
> > field
> > > > > > >> completely
> > > > > > >> > > independent of topic metadata? I think In the
> > > JoinGroupResponse,
> > > > > we
> > > > > > >> > should
> > > > > > >> > > have only one copy of topic metadata provided by
> coordinator
> > > and
> > > > > is
> > > > > > >> > outside
> > > > > > >> > > of protocol metadata. If user decides to put some metadata
> > in
> > > > the
> > > > > > >> > > JoinGroupRequest and let coordinator pass around, they are
> > > > > > responsible
> > > > > > >> > for
> > > > > > >> > > understanding the risk.
> > > > > > >> > >
> > > > > > >> > > Thanks,
> > > > > > >> > >
> > > > > > >> > > Jiangjie (Becket) Qin
> > > > > > >> > >
> > > > > > >> > >
> > > > > > >> > > On Thu, Aug 13, 2015 at 12:41 PM, Jason Gustafson <
> > > > > > jason@confluent.io
> > > > > > >> >
> > > > > > >> > > wrote:
> > > > > > >> > >
> > > > > > >> > > > Hey Onur and Jiangjie,
> > > > > > >> > > >
> > > > > > >> > > > I've updated that wiki with a proposal to add regex
> > > > > subscriptions
> > > > > > to
> > > > > > >> > the
> > > > > > >> > > > consumer metadata. Can you have a look to see if it
> > > addresses
> > > > > your
> > > > > > >> > > concern?
> > > > > > >> > > > In general, I think we should be a little careful when
> we
> > > are
> > > > > > >> talking
> > > > > > >> > > about
> > > > > > >> > > > the scalability of the protocol. Regardless of whether
> > > > > assignment
> > > > > > is
> > > > > > >> > done
> > > > > > >> > > > on the server or the client, the protocol assumes a
> > > relatively
> > > > > > >> stable
> > > > > > >> > > > configuration. When the number of consumers increases
> > > beyond a
> > > > > > >> certain
> > > > > > >> > > > limit, then membership churn becomes a major concern.
> > > > Similarly
> > > > > > >> there
> > > > > > >> > is
> > > > > > >> > > a
> > > > > > >> > > > notion of metadata churn when topics are added, deleted,
> > or
> > > > > > >> resized. If
> > > > > > >> > > > either membership or metadata changes, then the protocol
> > > > forces
> > > > > > all
> > > > > > >> > > > consumers to stop consumption and rejoin the group. If
> > this
> > > > > > happens
> > > > > > >> > often
> > > > > > >> > > > enough, then it can severely impact the ability of the
> > > > consumer
> > > > > to
> > > > > > >> make
> > > > > > >> > > > progress. The point is that the protocol may already be
> > > > unsuited
> > > > > > to
> > > > > > >> > cases
> > > > > > >> > > > where there are either a large number of consumers or
> > > topics.
> > > > I
> > > > > > >> wonder
> > > > > > >> > if
> > > > > > >> > > > you guys can share your thoughts about your scaling
> > > > > expectations?
> > > > > > >> > > >
> > > > > > >> > > > -Jason
> > > > > > >> > > >
> > > > > > >> > > >
> > > > > > >> > > >
> > > > > > >> > > >
> > > > > > >> > > > On Wed, Aug 12, 2015 at 12:28 PM, Jason Gustafson <
> > > > > > >> jason@confluent.io>
> > > > > > >> > > > wrote:
> > > > > > >> > > >
> > > > > > >> > > > > Hey Jiangjie,
> > > > > > >> > > > >
> > > > > > >> > > > > That's a great point. In the worst case (the mirror
> > maker
> > > > > case I
> > > > > > >> > > guess),
> > > > > > >> > > > > the join group response can be massive. This would be
> > > > > especially
> > > > > > >> > deadly
> > > > > > >> > > > > when there is a lot of churn in the group (e.g. in a
> > > rolling
> > > > > > >> > upgrade).
> > > > > > >> > > > The
> > > > > > >> > > > > current protocol is not great for this case either,
> but
> > > it's
> > > > > > >> > > > significantly
> > > > > > >> > > > > better. Here are a couple ways to deal with the size:
> > > > > > >> > > > >
> > > > > > >> > > > > 1. First, we could have the coordinator compress the
> > > > > responses.
> > > > > > >> This
> > > > > > >> > > > would
> > > > > > >> > > > > probably be pretty effective if applied across the
> > > metadata
> > > > > from
> > > > > > >> all
> > > > > > >> > > > > members.
> > > > > > >> > > > >
> > > > > > >> > > > > 2. I think the regex case is the main problem. Is that
> > > > right?
> > > > > We
> > > > > > >> > could
> > > > > > >> > > > > extend the metadata to allow the consumer to embed its
> > > regex
> > > > > > >> > > subscription
> > > > > > >> > > > > in the metadata directly (note this might be a good
> idea
> > > > > > >> regardless
> > > > > > >> > of
> > > > > > >> > > > the
> > > > > > >> > > > > rest of this proposal). To support regex on the
> > consumer,
> > > we
> > > > > > must
> > > > > > >> > fetch
> > > > > > >> > > > > metadata for all topics. Rather than having all regex
> > > > > > subscribers
> > > > > > >> > embed
> > > > > > >> > > > all
> > > > > > >> > > > > of this metadata in their join group requests, they
> > could
> > > > > > instead
> > > > > > >> > > embed a
> > > > > > >> > > > > hash of it. Then after the join group responses are
> > > > received,
> > > > > > they
> > > > > > >> > just
> > > > > > >> > > > > need to check that the hashes are the same. If there
> is
> > a
> > > > > > mismatch
> > > > > > >> > > (which
> > > > > > >> > > > > should only occur when topics are created, deleted, or
> > > > > resized),
> > > > > > >> then
> > > > > > >> > > the
> > > > > > >> > > > > group members must refetch the metadata and rejoin the
> > > > group.
> > > > > > >> This is
> > > > > > >> > > > also
> > > > > > >> > > > > how the current protocol behaves when there is a
> change
> > in
> > > > the
> > > > > > >> topic
> > > > > > >> > > > > metadata affecting the group--someone (either the
> > > > coordinator
> > > > > or
> > > > > > >> the
> > > > > > >> > > > > consumer) detects the change and forces the group to
> > > > > rebalance.
> > > > > > >> > > > >
> > > > > > >> > > > > What do you think?
> > > > > > >> > > > >
> > > > > > >> > > > > (Also I think adding groupId/generationId to fetch and
> > > > produce
> > > > > > >> > requests
> > > > > > >> > > > > seems like an interesting line of thought.)
> > > > > > >> > > > >
> > > > > > >> > > > > -Jason
> > > > > > >> > > > >
> > > > > > >> > > > >
> > > > > > >> > > > >
> > > > > > >> > > > > On Wed, Aug 12, 2015 at 10:57 AM, Jiangjie Qin
> > > > > > >> > > <jqin@linkedin.com.invalid
> > > > > > >> > > > >
> > > > > > >> > > > > wrote:
> > > > > > >> > > > >
> > > > > > >> > > > >> Hey Ewen,
> > > > > > >> > > > >>
> > > > > > >> > > > >> Onur and I discussed this a little bit more. And we
> are
> > > > still
> > > > > > >> > worrying
> > > > > > >> > > > >> about passing all the metadata of all consumers
> around.
> > > > > > >> > > > >>
> > > > > > >> > > > >> Let's say I have a cluster has 10,000 topics, the
> > average
> > > > > topic
> > > > > > >> name
> > > > > > >> > > > >> length
> > > > > > >> > > > >> is 10 bytes. In this case, the opaque metadata will
> > have
> > > > 10 *
> > > > > > >> > 10,000 =
> > > > > > >> > > > >> 100KB for topic name, for each topic, there is a
> 4-byte
> > > > > integer
> > > > > > >> of
> > > > > > >> > > > number
> > > > > > >> > > > >> of partitions, that's another 40KB. So one global
> topic
> > > > > > metadata
> > > > > > >> > will
> > > > > > >> > > > have
> > > > > > >> > > > >> 140KB data. If I have 100 consumers who are using
> > > wildcard
> > > > to
> > > > > > >> > consume
> > > > > > >> > > > from
> > > > > > >> > > > >> all the topics. That means the protocol metadata end
> up
> > > in
> > > > > the
> > > > > > >> > > > >> JoinGroupResponse will be 140KB * 100 = 14MB. And the
> > > > > > >> > > JoinGroupResponse
> > > > > > >> > > > >> will need to be sent to 100 different consumers, that
> > > means
> > > > > > 14MB
> > > > > > >> *
> > > > > > >> > > 100 =
> > > > > > >> > > > >> 1.4GB need to be sent by the consumer coordinator for
> > one
> > > > > > >> rebalance.
> > > > > > >> > > How
> > > > > > >> > > > >> would that work?
> > > > > > >> > > > >>
> > > > > > >> > > > >> Also, having two consumers (old owner and new owner)
> > > > > consuming
> > > > > > >> from
> > > > > > >> > > the
> > > > > > >> > > > >> same partition might also be a problem. e.g. people
> are
> > > > > > updating
> > > > > > >> > > > database.
> > > > > > >> > > > >> One thing might worth doing is to add GroupId and
> > > > Generation
> > > > > ID
> > > > > > >> to
> > > > > > >> > > > >> ProducerRequest and FetchRequest as well. This will
> > also
> > > > help
> > > > > > >> with
> > > > > > >> > the
> > > > > > >> > > > >> single producer use case. However, this is probably
> > > > > orthogonal
> > > > > > to
> > > > > > >> > this
> > > > > > >> > > > >> thread given the current new consumer also has this
> > > problem
> > > > > > and I
> > > > > > >> > > > believe
> > > > > > >> > > > >> we need to fix it.
> > > > > > >> > > > >>
> > > > > > >> > > > >> Thanks,
> > > > > > >> > > > >>
> > > > > > >> > > > >> Jiangjie (Becket) Qin
> > > > > > >> > > > >>
> > > > > > >> > > > >> On Tue, Aug 11, 2015 at 11:43 PM, Ewen
> > Cheslack-Postava <
> > > > > > >> > > > >> ewen@confluent.io>
> > > > > > >> > > > >> wrote:
> > > > > > >> > > > >>
> > > > > > >> > > > >> > On Tue, Aug 11, 2015 at 11:29 PM, Jiangjie Qin
> > > > > > >> > > > >> <jq...@linkedin.com.invalid>
> > > > > > >> > > > >> > wrote:
> > > > > > >> > > > >> >
> > > > > > >> > > > >> > > Ewen,
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> > > Thanks for the explanation.
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> > > For (1), I am more concerned about the failure
> case
> > > > > instead
> > > > > > >> of
> > > > > > >> > > > normal
> > > > > > >> > > > >> > case.
> > > > > > >> > > > >> > > What if a consumer somehow was kick out of a
> group
> > > but
> > > > is
> > > > > > >> still
> > > > > > >> > > > >> consuming
> > > > > > >> > > > >> > > and committing offsets? Does that mean the new
> > owner
> > > > and
> > > > > > old
> > > > > > >> > owner
> > > > > > >> > > > >> might
> > > > > > >> > > > >> > > potentially consuming from and committing offsets
> > for
> > > > the
> > > > > > >> same
> > > > > > >> > > > >> partition?
> > > > > > >> > > > >> > > In the old consumer, this won't happen because
> the
> > > new
> > > > > > >> consumer
> > > > > > >> > > will
> > > > > > >> > > > >> not
> > > > > > >> > > > >> > be
> > > > > > >> > > > >> > > able to start consumption unless the previous
> owner
> > > has
> > > > > > >> released
> > > > > > >> > > its
> > > > > > >> > > > >> > > ownership. Basically, without the ownership
> > > guarantee,
> > > > I
> > > > > > >> don't
> > > > > > >> > see
> > > > > > >> > > > how
> > > > > > >> > > > >> > the
> > > > > > >> > > > >> > > communication among consumers themselves alone
> can
> > > > solve
> > > > > > the
> > > > > > >> > > problem
> > > > > > >> > > > >> > here.
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> >
> > > > > > >> > > > >> > The generation ID check still applies to offset
> > > commits.
> > > > If
> > > > > > >> one of
> > > > > > >> > > the
> > > > > > >> > > > >> > consumers is kicked out and misbehaving, it can
> > > obviously
> > > > > > still
> > > > > > >> > > fetch
> > > > > > >> > > > >> and
> > > > > > >> > > > >> > process messages, but offset commits will not work
> > > since
> > > > it
> > > > > > >> will
> > > > > > >> > not
> > > > > > >> > > > >> have
> > > > > > >> > > > >> > the current generation ID.
> > > > > > >> > > > >> >
> > > > > > >> > > > >> >
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> > > For (2) and (3), now I understand how metadata
> are
> > > > used.
> > > > > > But
> > > > > > >> I
> > > > > > >> > > still
> > > > > > >> > > > >> > don't
> > > > > > >> > > > >> > > see why should we let the consumers to pass the
> > topic
> > > > > > >> > information
> > > > > > >> > > > >> across
> > > > > > >> > > > >> > > instead of letting coordinator give the
> > information.
> > > > The
> > > > > > >> single
> > > > > > >> > > > >> producer
> > > > > > >> > > > >> > > use case does not solve the ownership problem in
> > > > abnormal
> > > > > > >> case
> > > > > > >> > > > either,
> > > > > > >> > > > >> > > which seems to be a little bit vulnerable.
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> >
> > > > > > >> > > > >> > One of the goals here was to generalize group
> > > membership
> > > > so
> > > > > > we
> > > > > > >> > can,
> > > > > > >> > > > for
> > > > > > >> > > > >> > example, use it for balancing Copycat tasks across
> > > > workers.
> > > > > > >> > There's
> > > > > > >> > > no
> > > > > > >> > > > >> > topic subscription info in that case. The metadata
> > for
> > > > > > copycat
> > > > > > >> > > workers
> > > > > > >> > > > >> > would instead need to somehow indicate the current
> > set
> > > of
> > > > > > tasks
> > > > > > >> > that
> > > > > > >> > > > >> need
> > > > > > >> > > > >> > to be assigned to workers. By making the metadata
> > > > > completely
> > > > > > >> > opaque
> > > > > > >> > > to
> > > > > > >> > > > >> the
> > > > > > >> > > > >> > protocol, it becomes more generally useful since it
> > > > focuses
> > > > > > >> > squarely
> > > > > > >> > > > on
> > > > > > >> > > > >> the
> > > > > > >> > > > >> > group membership problem, allowing for that
> > additional
> > > > bit
> > > > > of
> > > > > > >> > > metadata
> > > > > > >> > > > >> so
> > > > > > >> > > > >> > you don't just get a list of members, but also get
> a
> > > > little
> > > > > > >> bit of
> > > > > > >> > > > info
> > > > > > >> > > > >> > about each of them.
> > > > > > >> > > > >> >
> > > > > > >> > > > >> > A different option that we explored is to use a
> sort
> > of
> > > > > mixed
> > > > > > >> > model
> > > > > > >> > > --
> > > > > > >> > > > >> > still bake all the topic subscriptions directly
> into
> > > the
> > > > > > >> protocol
> > > > > > >> > > but
> > > > > > >> > > > >> also
> > > > > > >> > > > >> > include metadata. That would allow us to maintain
> the
> > > > > > existing
> > > > > > >> > > > >> > coordinator-driven approach to handling the
> metadata
> > > and
> > > > > > change
> > > > > > >> > > events
> > > > > > >> > > > >> like
> > > > > > >> > > > >> > the ones Onur pointed out. Then something like the
> > > > Copycat
> > > > > > >> workers
> > > > > > >> > > > would
> > > > > > >> > > > >> > just not fill in any topic subscriptions and it
> would
> > > be
> > > > > > >> handled
> > > > > > >> > as
> > > > > > >> > > a
> > > > > > >> > > > >> > degenerate case. Based on the way I explained that
> we
> > > can
> > > > > > >> handle
> > > > > > >> > > those
> > > > > > >> > > > >> > types of events, I personally feel its cleaner and
> a
> > > > nicer
> > > > > > >> > > > >> generalization
> > > > > > >> > > > >> > to not include the subscriptions in the join group
> > > > > protocol,
> > > > > > >> > making
> > > > > > >> > > it
> > > > > > >> > > > >> part
> > > > > > >> > > > >> > of the metadata instead.
> > > > > > >> > > > >> >
> > > > > > >> > > > >> > For the single producer case, are you saying it
> > doesn't
> > > > > solve
> > > > > > >> > > > ownership
> > > > > > >> > > > >> in
> > > > > > >> > > > >> > the abnormal case because a producer that doesn't
> > know
> > > it
> > > > > has
> > > > > > >> been
> > > > > > >> > > > >> kicked
> > > > > > >> > > > >> > out of the group yet can still produce data even
> > though
> > > > it
> > > > > > >> > shouldn't
> > > > > > >> > > > be
> > > > > > >> > > > >> > able to anymore? I definitely agree that that is a
> > risk
> > > > --
> > > > > > this
> > > > > > >> > > > >> provides a
> > > > > > >> > > > >> > way to get closer to a true single-writer, but
> there
> > > are
> > > > > > >> > definitely
> > > > > > >> > > > >> still
> > > > > > >> > > > >> > failure modes that this does not address.
> > > > > > >> > > > >> >
> > > > > > >> > > > >> > -Ewen
> > > > > > >> > > > >> >
> > > > > > >> > > > >> >
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> > > Thanks,
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> > > Jiangjie (Becket) Qin
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> > > On Tue, Aug 11, 2015 at 11:06 PM, Ewen
> > > > Cheslack-Postava <
> > > > > > >> > > > >> > ewen@confluent.io
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > wrote:
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> > > > On Tue, Aug 11, 2015 at 10:15 PM, Jiangjie Qin
> > > > > > >> > > > >> > <jqin@linkedin.com.invalid
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > wrote:
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > > Hi Jason,
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > > > Thanks for writing this up. It would be
> useful
> > to
> > > > > > >> generalize
> > > > > > >> > > the
> > > > > > >> > > > >> > group
> > > > > > >> > > > >> > > > > concept. I have a few questions below.
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > > > 1. In old consumer actually the partition
> > > > assignment
> > > > > > are
> > > > > > >> > done
> > > > > > >> > > by
> > > > > > >> > > > >> > > > consumers
> > > > > > >> > > > >> > > > > themselves. We used zookeeper to guarantee
> > that a
> > > > > > >> partition
> > > > > > >> > > will
> > > > > > >> > > > >> only
> > > > > > >> > > > >> > > be
> > > > > > >> > > > >> > > > > consumed by one consumer thread who
> > successfully
> > > > > > claimed
> > > > > > >> its
> > > > > > >> > > > >> > ownership.
> > > > > > >> > > > >> > > > > Does the new protocol plan to provide the
> same
> > > > > > guarantee?
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > Once you have all the metadata from all the
> > > > consumers,
> > > > > > >> > > assignment
> > > > > > >> > > > >> > should
> > > > > > >> > > > >> > > > just be a simple function mapping that
> > > > Map<ConsumerId,
> > > > > > >> > Metadata>
> > > > > > >> > > > to
> > > > > > >> > > > >> > > > Map<ConsumerId, List<TopicPartition>>. If
> > everyone
> > > is
> > > > > > >> > consistent
> > > > > > >> > > > in
> > > > > > >> > > > >> > > > computing that, you don't need ZK involved at
> > all.
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > In practice, this shouldn't be that hard to
> > ensure
> > > > for
> > > > > > most
> > > > > > >> > > > >> assignment
> > > > > > >> > > > >> > > > strategies just by having decent unit testing
> on
> > > > them.
> > > > > > You
> > > > > > >> > just
> > > > > > >> > > > >> have to
> > > > > > >> > > > >> > > do
> > > > > > >> > > > >> > > > things like ensure your assignment strategy
> sorts
> > > > lists
> > > > > > >> into a
> > > > > > >> > > > >> > consistent
> > > > > > >> > > > >> > > > order.
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > You do give up the ability to use some
> techniques
> > > > (e.g.
> > > > > > any
> > > > > > >> > > > >> randomized
> > > > > > >> > > > >> > > > algorithm if you can't distribute the seed w/
> the
> > > > > > metadata)
> > > > > > >> > and
> > > > > > >> > > > it's
> > > > > > >> > > > >> > true
> > > > > > >> > > > >> > > > that nothing validates the assignment, but if
> > that
> > > > > > >> assignment
> > > > > > >> > > > >> algorithm
> > > > > > >> > > > >> > > > step is kept simple, small, and well tested,
> the
> > > risk
> > > > > is
> > > > > > >> very
> > > > > > >> > > > >> minimal.
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > > > 2. It looks that both JoinGroupRequest and
> > > > > > >> JoinGroupResponse
> > > > > > >> > > has
> > > > > > >> > > > >> the
> > > > > > >> > > > >> > > > > ProtocolMetadata.AssignmentStrategyMetadata,
> > what
> > > > > would
> > > > > > >> be
> > > > > > >> > the
> > > > > > >> > > > >> > metadata
> > > > > > >> > > > >> > > > be
> > > > > > >> > > > >> > > > > sent and returned by coordinator? How will
> the
> > > > > > >> coordinator
> > > > > > >> > > > handle
> > > > > > >> > > > >> the
> > > > > > >> > > > >> > > > > metadata?
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > The coordinator is basically just blindly
> > > > broadcasting
> > > > > > all
> > > > > > >> of
> > > > > > >> > it
> > > > > > >> > > > to
> > > > > > >> > > > >> > group
> > > > > > >> > > > >> > > > members so they have a consistent view.
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > So from the coordinators perspective, it sees
> > > > something
> > > > > > >> like:
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > Consumer 1 -> JoinGroupRequest with
> > GroupProtocols
> > > =
> > > > [
> > > > > > >> > > "consumer"
> > > > > > >> > > > >> > > > <Consumer1 opaque byte[]>]
> > > > > > >> > > > >> > > > Consumer 2 -> JoinGroupRequest with
> > GroupProtocols
> > > =
> > > > [
> > > > > > >> > > "consumer"
> > > > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > Then, in the responses would look like:
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > Consumer 1 <- JoinGroupResponse with
> > GroupProtocol
> > > =
> > > > > > >> > "consumer"
> > > > > > >> > > > and
> > > > > > >> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque
> > > > byte[]>,
> > > > > > >> > Consumer
> > > > > > >> > > 2
> > > > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > > > >> > > > >> > > > Consumer 2 <- JoinGroupResponse with
> > GroupProtocol
> > > =
> > > > > > >> > "consumer"
> > > > > > >> > > > and
> > > > > > >> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque
> > > > byte[]>,
> > > > > > >> > Consumer
> > > > > > >> > > 2
> > > > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > So all the responses include all the metadata
> for
> > > > every
> > > > > > >> member
> > > > > > >> > > in
> > > > > > >> > > > >> the
> > > > > > >> > > > >> > > > group, and everyone can use that to
> consistently
> > > > decide
> > > > > > on
> > > > > > >> > > > >> assignment.
> > > > > > >> > > > >> > > The
> > > > > > >> > > > >> > > > broker doesn't care and cannot even understand
> > the
> > > > > > metadata
> > > > > > >> > > since
> > > > > > >> > > > >> the
> > > > > > >> > > > >> > > data
> > > > > > >> > > > >> > > > format for it is dependent on the assignment
> > > strategy
> > > > > > being
> > > > > > >> > > used.
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > As another example that is *not* a consumer,
> > let's
> > > > say
> > > > > > you
> > > > > > >> > just
> > > > > > >> > > > >> want to
> > > > > > >> > > > >> > > > have a single writer in the group which
> everyone
> > > will
> > > > > > >> forward
> > > > > > >> > > > >> requests
> > > > > > >> > > > >> > > to.
> > > > > > >> > > > >> > > > To accomplish this, you could use a very dumb
> > > > > assignment
> > > > > > >> > > strategy:
> > > > > > >> > > > >> > there
> > > > > > >> > > > >> > > is
> > > > > > >> > > > >> > > > no metadata (empty byte[]) and all we care
> about
> > is
> > > > who
> > > > > > is
> > > > > > >> the
> > > > > > >> > > > first
> > > > > > >> > > > >> > > member
> > > > > > >> > > > >> > > > in the group (e.g. when IDs are sorted
> > > > > > lexicographically).
> > > > > > >> > That
> > > > > > >> > > > >> member
> > > > > > >> > > > >> > is
> > > > > > >> > > > >> > > > selected as the writer. In that case, we
> actually
> > > > just
> > > > > > care
> > > > > > >> > > about
> > > > > > >> > > > >> the
> > > > > > >> > > > >> > > > membership list, there's no additional info
> about
> > > > each
> > > > > > >> member
> > > > > > >> > > that
> > > > > > >> > > > >> is
> > > > > > >> > > > >> > > > required to determine who is the writer.
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > > 3. Do you mean that the number of partitions
> in
> > > > > > >> > > > JoinGroupResponse
> > > > > > >> > > > >> > will
> > > > > > >> > > > >> > > be
> > > > > > >> > > > >> > > > > the max partition number of a topic among all
> > the
> > > > > > >> reported
> > > > > > >> > > > >> partition
> > > > > > >> > > > >> > > > number
> > > > > > >> > > > >> > > > > by consumers? Is there any reason not just
> let
> > > > > > >> Coordinator
> > > > > > >> > to
> > > > > > >> > > > >> return
> > > > > > >> > > > >> > > the
> > > > > > >> > > > >> > > > > number of partitions of a topic in its
> metadata
> > > > > cache?
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > Nothing from the embedded protocol is touched
> by
> > > the
> > > > > > >> broker.
> > > > > > >> > The
> > > > > > >> > > > >> broker
> > > > > > >> > > > >> > > > just collects opaque bytes of metadata, does
> the
> > > > > > selection
> > > > > > >> of
> > > > > > >> > > the
> > > > > > >> > > > >> > > strategy
> > > > > > >> > > > >> > > > if multiple are supported by some consumers,
> and
> > > then
> > > > > > >> returns
> > > > > > >> > > that
> > > > > > >> > > > >> > opaque
> > > > > > >> > > > >> > > > metadata for all the members back to every
> > member.
> > > In
> > > > > > that
> > > > > > >> way
> > > > > > >> > > > they
> > > > > > >> > > > >> all
> > > > > > >> > > > >> > > > have a consistent view of the group. For
> regular
> > > > > > consumers,
> > > > > > >> > that
> > > > > > >> > > > >> view
> > > > > > >> > > > >> > of
> > > > > > >> > > > >> > > > the group includes information about how many
> > > > > partitions
> > > > > > >> each
> > > > > > >> > > > >> consumer
> > > > > > >> > > > >> > > > currently thinks the topics it is subscribed to
> > > has.
> > > > > > These
> > > > > > >> > could
> > > > > > >> > > > be
> > > > > > >> > > > >> > > > inconsistent due to out of date metadata and it
> > > would
> > > > > be
> > > > > > >> up to
> > > > > > >> > > the
> > > > > > >> > > > >> > > > assignment strategy on the *client* to resolve
> > > that.
> > > > As
> > > > > > you
> > > > > > >> > > point
> > > > > > >> > > > >> out,
> > > > > > >> > > > >> > in
> > > > > > >> > > > >> > > > that case they could just take the max value
> that
> > > any
> > > > > > >> consumer
> > > > > > >> > > > >> reported
> > > > > > >> > > > >> > > > seeing and use that. The consumers that notice
> > that
> > > > > their
> > > > > > >> > > metadata
> > > > > > >> > > > >> had
> > > > > > >> > > > >> > a
> > > > > > >> > > > >> > > > smaller # of partitions should also trigger a
> > > > metadata
> > > > > > >> update
> > > > > > >> > > when
> > > > > > >> > > > >> they
> > > > > > >> > > > >> > > see
> > > > > > >> > > > >> > > > someone else observing a larger # of
> partitions.
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > > > Thanks,
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > > > Jiangjie (Becket) Qin
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason
> > Gustafson
> > > <
> > > > > > >> > > > >> jason@confluent.io
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> > > > > wrote:
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > > > > Hi Kafka Devs,
> > > > > > >> > > > >> > > > > >
> > > > > > >> > > > >> > > > > > One of the nagging issues in the current
> > design
> > > > of
> > > > > > the
> > > > > > >> new
> > > > > > >> > > > >> consumer
> > > > > > >> > > > >> > > has
> > > > > > >> > > > >> > > > > > been the need to support a variety of
> > > assignment
> > > > > > >> > strategies.
> > > > > > >> > > > >> We've
> > > > > > >> > > > >> > > > > > encountered this in particular in the
> design
> > of
> > > > > > copycat
> > > > > > >> > and
> > > > > > >> > > > the
> > > > > > >> > > > >> > > > > processing
> > > > > > >> > > > >> > > > > > framework (KIP-28). From what I understand,
> > > Samza
> > > > > > also
> > > > > > >> > has a
> > > > > > >> > > > >> number
> > > > > > >> > > > >> > > of
> > > > > > >> > > > >> > > > > use
> > > > > > >> > > > >> > > > > > cases with custom assignment needs. The new
> > > > > consumer
> > > > > > >> > > protocol
> > > > > > >> > > > >> > > supports
> > > > > > >> > > > >> > > > > new
> > > > > > >> > > > >> > > > > > assignment strategies by hooking them into
> > the
> > > > > > broker.
> > > > > > >> For
> > > > > > >> > > > many
> > > > > > >> > > > >> > > > > > environments, this is a major pain and in
> > some
> > > > > > cases, a
> > > > > > >> > > > >> > non-starter.
> > > > > > >> > > > >> > > It
> > > > > > >> > > > >> > > > > > also challenges the validation that the
> > > > coordinator
> > > > > > can
> > > > > > >> > > > provide.
> > > > > > >> > > > >> > For
> > > > > > >> > > > >> > > > > > example, some assignment strategies call
> for
> > > > > > >> partitions to
> > > > > > >> > > be
> > > > > > >> > > > >> > > assigned
> > > > > > >> > > > >> > > > > > multiple times, which means that the
> > > coordinator
> > > > > can
> > > > > > >> only
> > > > > > >> > > > check
> > > > > > >> > > > >> > that
> > > > > > >> > > > >> > > > > > partitions have been assigned at least
> once.
> > > > > > >> > > > >> > > > > >
> > > > > > >> > > > >> > > > > > To solve these issues, we'd like to propose
> > > > moving
> > > > > > >> > > assignment
> > > > > > >> > > > to
> > > > > > >> > > > >> > the
> > > > > > >> > > > >> > > > > > client. I've written a wiki which outlines
> > some
> > > > > > >> protocol
> > > > > > >> > > > >> changes to
> > > > > > >> > > > >> > > > > achieve
> > > > > > >> > > > >> > > > > > this:
> > > > > > >> > > > >> > > > > >
> > > > > > >> > > > >> > > > > >
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> >
> > > > > > >> > > > >>
> > > > > > >> > > >
> > > > > > >> > >
> > > > > > >> >
> > > > > > >>
> > > > > >
> > > > >
> > > >
> > >
> >
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> > > > > > >> > > > >> > > > > > .
> > > > > > >> > > > >> > > > > > To summarize briefly, instead of the
> > > coordinator
> > > > > > >> assigning
> > > > > > >> > > the
> > > > > > >> > > > >> > > > partitions
> > > > > > >> > > > >> > > > > > itself, all subscriptions are forwarded to
> > each
> > > > > > member
> > > > > > >> of
> > > > > > >> > > the
> > > > > > >> > > > >> group
> > > > > > >> > > > >> > > > which
> > > > > > >> > > > >> > > > > > then decides independently which partitions
> > it
> > > > > should
> > > > > > >> > > consume.
> > > > > > >> > > > >> The
> > > > > > >> > > > >> > > > > protocol
> > > > > > >> > > > >> > > > > > provides a mechanism for the coordinator to
> > > > > validate
> > > > > > >> that
> > > > > > >> > > all
> > > > > > >> > > > >> > > consumers
> > > > > > >> > > > >> > > > > use
> > > > > > >> > > > >> > > > > > the same assignment strategy, but it does
> not
> > > > > ensure
> > > > > > >> that
> > > > > > >> > > the
> > > > > > >> > > > >> > > resulting
> > > > > > >> > > > >> > > > > > assignment is "correct." This provides a
> > > powerful
> > > > > > >> > capability
> > > > > > >> > > > for
> > > > > > >> > > > >> > > users
> > > > > > >> > > > >> > > > to
> > > > > > >> > > > >> > > > > > control the full data flow on the client
> > side.
> > > > They
> > > > > > >> > control
> > > > > > >> > > > how
> > > > > > >> > > > >> > data
> > > > > > >> > > > >> > > is
> > > > > > >> > > > >> > > > > > written to partitions through the
> Partitioner
> > > > > > interface
> > > > > > >> > and
> > > > > > >> > > > they
> > > > > > >> > > > >> > > > control
> > > > > > >> > > > >> > > > > > how data is consumed through the assignment
> > > > > strategy,
> > > > > > >> all
> > > > > > >> > > > >> without
> > > > > > >> > > > >> > > > > touching
> > > > > > >> > > > >> > > > > > the server.
> > > > > > >> > > > >> > > > > >
> > > > > > >> > > > >> > > > > > Of course nothing comes for free. In
> > > particular,
> > > > > this
> > > > > > >> > change
> > > > > > >> > > > >> > removes
> > > > > > >> > > > >> > > > the
> > > > > > >> > > > >> > > > > > ability of the coordinator to validate that
> > > > commits
> > > > > > are
> > > > > > >> > made
> > > > > > >> > > > by
> > > > > > >> > > > >> > > > consumers
> > > > > > >> > > > >> > > > > > who were assigned the respective partition.
> > > This
> > > > > > might
> > > > > > >> not
> > > > > > >> > > be
> > > > > > >> > > > >> too
> > > > > > >> > > > >> > bad
> > > > > > >> > > > >> > > > > since
> > > > > > >> > > > >> > > > > > we retain the ability to validate the
> > > generation
> > > > > id,
> > > > > > >> but
> > > > > > >> > it
> > > > > > >> > > > is a
> > > > > > >> > > > >> > > > > potential
> > > > > > >> > > > >> > > > > > concern. We have considered alternative
> > > protocols
> > > > > > which
> > > > > > >> > add
> > > > > > >> > > a
> > > > > > >> > > > >> > second
> > > > > > >> > > > >> > > > > > round-trip to the protocol in order to give
> > the
> > > > > > >> > coordinator
> > > > > > >> > > > the
> > > > > > >> > > > >> > > ability
> > > > > > >> > > > >> > > > > to
> > > > > > >> > > > >> > > > > > confirm the assignment. As mentioned above,
> > the
> > > > > > >> > coordinator
> > > > > > >> > > is
> > > > > > >> > > > >> > > somewhat
> > > > > > >> > > > >> > > > > > limited in what it can actually validate,
> but
> > > > this
> > > > > > >> would
> > > > > > >> > > > return
> > > > > > >> > > > >> its
> > > > > > >> > > > >> > > > > ability
> > > > > > >> > > > >> > > > > > to validate commits. The tradeoff is that
> it
> > > > > > increases
> > > > > > >> the
> > > > > > >> > > > >> > protocol's
> > > > > > >> > > > >> > > > > > complexity which means more ways for the
> > > protocol
> > > > > to
> > > > > > >> fail
> > > > > > >> > > and
> > > > > > >> > > > >> > > > > consequently
> > > > > > >> > > > >> > > > > > more edge cases in the code.
> > > > > > >> > > > >> > > > > >
> > > > > > >> > > > >> > > > > > It also misses an opportunity to generalize
> > the
> > > > > group
> > > > > > >> > > > membership
> > > > > > >> > > > >> > > > protocol
> > > > > > >> > > > >> > > > > > for additional use cases. In fact, after
> > you've
> > > > > gone
> > > > > > to
> > > > > > >> > the
> > > > > > >> > > > >> trouble
> > > > > > >> > > > >> > > of
> > > > > > >> > > > >> > > > > > moving assignment to the client, the main
> > thing
> > > > > that
> > > > > > is
> > > > > > >> > left
> > > > > > >> > > > in
> > > > > > >> > > > >> > this
> > > > > > >> > > > >> > > > > > protocol is basically a general group
> > > management
> > > > > > >> > capability.
> > > > > > >> > > > >> This
> > > > > > >> > > > >> > is
> > > > > > >> > > > >> > > > > > exactly what is needed for a few cases that
> > are
> > > > > > >> currently
> > > > > > >> > > > under
> > > > > > >> > > > >> > > > > discussion
> > > > > > >> > > > >> > > > > > (e.g. copycat or single-writer producer).
> > We've
> > > > > taken
> > > > > > >> this
> > > > > > >> > > > >> further
> > > > > > >> > > > >> > > step
> > > > > > >> > > > >> > > > > in
> > > > > > >> > > > >> > > > > > the proposal and attempted to envision what
> > > that
> > > > > > >> general
> > > > > > >> > > > >> protocol
> > > > > > >> > > > >> > > might
> > > > > > >> > > > >> > > > > > look like and how it could be used both by
> > the
> > > > > > consumer
> > > > > > >> > and
> > > > > > >> > > > for
> > > > > > >> > > > >> > some
> > > > > > >> > > > >> > > of
> > > > > > >> > > > >> > > > > > these other cases.
> > > > > > >> > > > >> > > > > >
> > > > > > >> > > > >> > > > > > Anyway, since time is running out on the
> new
> > > > > > consumer,
> > > > > > >> we
> > > > > > >> > > have
> > > > > > >> > > > >> > > perhaps
> > > > > > >> > > > >> > > > > one
> > > > > > >> > > > >> > > > > > last chance to consider a significant
> change
> > in
> > > > the
> > > > > > >> > protocol
> > > > > > >> > > > >> like
> > > > > > >> > > > >> > > this,
> > > > > > >> > > > >> > > > > so
> > > > > > >> > > > >> > > > > > have a look at the wiki and share your
> > > thoughts.
> > > > > I've
> > > > > > >> no
> > > > > > >> > > doubt
> > > > > > >> > > > >> that
> > > > > > >> > > > >> > > > some
> > > > > > >> > > > >> > > > > > ideas seem clearer in my mind than they do
> on
> > > > > paper,
> > > > > > so
> > > > > > >> > ask
> > > > > > >> > > > >> > questions
> > > > > > >> > > > >> > > > if
> > > > > > >> > > > >> > > > > > there is any confusion.
> > > > > > >> > > > >> > > > > >
> > > > > > >> > > > >> > > > > > Thanks!
> > > > > > >> > > > >> > > > > > Jason
> > > > > > >> > > > >> > > > > >
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > --
> > > > > > >> > > > >> > > > Thanks,
> > > > > > >> > > > >> > > > Ewen
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> >
> > > > > > >> > > > >> >
> > > > > > >> > > > >> >
> > > > > > >> > > > >> > --
> > > > > > >> > > > >> > Thanks,
> > > > > > >> > > > >> > Ewen
> > > > > > >> > > > >> >
> > > > > > >> > > > >>
> > > > > > >> > > > >
> > > > > > >> > > > >
> > > > > > >> > > >
> > > > > > >> > >
> > > > > > >> >
> > > > > > >>
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Thanks,
> > > > > > > Neha
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Thanks,
> > > > > > Neha
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Thanks,
> > > > > Ewen
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Thanks,
> > > Ewen
> > >
> >
>



-- 
Thanks,
Ewen

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Jiangjie Qin <jq...@linkedin.com.INVALID>.
Ewen,

Honestly I am not sure whether we can keep all the topic in the same
cluster or not. By default, we will mirror the topic. Because when
application teams run their test, they would expect the environment to be
as similar to production as possible. Also, we are developing a
comprehensive continuous verification test framework as well. There will be
a bunch of test continuously running, including some tests that
periodically create topic, produce some data, verify the data integrity and
performance statistics, then do the clean up. The tests framework will also
include the entire pipeline but not only one cluster.

Another use case for wildcard besides mirror maker is that our auditing
service. Currently our auditing framework also reads from all the topics
and compares the messages count with the producers to see if there is any
data loss.

So I think for some topics we can let mirror maker exclude them, but it
might be a little bit difficult to exclude everything from all wildcard
consumer groups.

Thanks,

Jiangjie (Becket) Qin



On Mon, Aug 17, 2015 at 5:06 PM, Ewen Cheslack-Postava <ew...@confluent.io>
wrote:

> Becket,
>
> Just to clarify, when topics are being created/resized for automated tests,
> are those excluded by mirrormaker? I assume you don't want to bother with
> copying them since they are just for tests. If they are excluded, then they
> don't need to affect the metadata used by the consumer and so wouldn't
> trigger rebalancing in the scheme proposed -- the hash being reported can
> be restricted to the set of topics that will be processed by the consumer
> group. Consumers should only ever need to rejoin the group if they detect a
> metadata change that would affect the group's behavior.
>
> -Ewen
>
> On Mon, Aug 17, 2015 at 11:14 AM, Jason Gustafson <ja...@confluent.io>
> wrote:
>
> > Hey Becket,
> >
> > Thanks for raising these concerns. I think the rolling upgrade problem is
> > handled quite a bit better with the new consumer if Onur's LeaveGroup
> patch
> > (or a variant) is accepted. Without it, the coordinator has to wait for
> the
> > full session timeout to detect that a node has left the group, which can
> > significantly delay rebalancing.
> >
> > -Jason
> >
> > On Sun, Aug 16, 2015 at 11:42 AM, Neha Narkhede <ne...@confluent.io>
> wrote:
> >
> > > Hey Becket,
> > >
> > > These are all fair points. Regarding running Kafka as a service, it
> will
> > be
> > > good for everyone to know some numbers around topic creation and
> changes
> > > around # of partitions. I don't think the test usage is a good one
> since
> > no
> > > one should be creating and deleting topics in a loop on a production
> > > cluster.
> > >
> > > Regarding your point about mirror maker, I think we should definitely
> > > ensure that a mirror maker with a large topic subscription list should
> be
> > > well supported. The reason for the half an hour stalls in LinkedIn
> mirror
> > > makers is due to the fact that it still uses the old consumer. The 3
> > major
> > > reasons for long rebalance operations in the mirror maker using the old
> > > consumer are -
> > > 1. Every rebalance operation involves many writes to ZK. For large
> > consumer
> > > groups and large number of partitions, this adds up to several seconds
> > > 2. The view of the members in a group is inconsistent and hence there
> are
> > > typically several rebalance attempts. Note that this is fixed in the
> new
> > > design where the group membership is always consistently communicated
> to
> > > all members.
> > > 3. The rebalance backoff time is high (of the order of seconds).
> > >
> > > The good news is that the new design has none of these problems. As we
> > > said, we will run some tests to ensure that the mirror maker case is
> > > handled well. Thank you for the feedback!
> > >
> > > Thanks,
> > > Neha
> > >
> > > On Sat, Aug 15, 2015 at 6:17 PM, Jiangjie Qin
> <jqin@linkedin.com.invalid
> > >
> > > wrote:
> > >
> > > > Neha, Ewen and Jason,
> > > >
> > > > Maybe I am over concerning and I agree that it does depend on the
> > > metadata
> > > > change frequency. As Neha said, a few tests will be helpful. We can
> see
> > > how
> > > > it goes.
> > > >
> > > > What worries me is that in LinkedIn we are in the progress of running
> > > Kafka
> > > > as a service. That means user will have the ability to create/delete
> > > topics
> > > > and update their topic configurations programmatically or through UI
> > > using
> > > > LinkedIn internal cloud service platform. And some automated test
> will
> > > also
> > > > be consistently running to create topic, produce/consume some data,
> > then
> > > > clean up the topics. This brings us some new challenges for mirror
> > maker
> > > > because we need to make sure it actually copies data instead of
> > spending
> > > > too much time on rebalance. As what we see now is that each rebalance
> > > will
> > > > probably take 30 seconds or more to finish even with some tricks and
> > > > tuning.
> > > >
> > > > Another related use case I want to bring up is that today when we
> want
> > to
> > > > do a rolling upgrade of mirror maker (26 nodes), there will be two
> > rounds
> > > > of rebalance to bounce each node, each rebalance takes about 30
> > seconds.
> > > So
> > > > bouncing 26 nodes takes roughly half an hour. Awkwardly, during the
> > > rolling
> > > > bounce, because mirror maker is keeping rebalancing, it actually does
> > not
> > > > really copy any data! So the pipeline will literally stall for half
> an
> > > > hour! Since we are designing the new protocol, it will also be good
> it
> > we
> > > > make sure this use case is addressed.
> > > >
> > > > Thanks,
> > > >
> > > > Jiangjie (Becket) Qin
> > > >
> > > > On Sat, Aug 15, 2015 at 10:50 AM, Neha Narkhede <ne...@confluent.io>
> > > wrote:
> > > >
> > > > > Becket,
> > > > >
> > > > > This is a clever approach for to ensure that only one thing
> > > communicates
> > > > > the metadata so even if it is stale, the entire group has the same
> > > view.
> > > > > However, the big assumption this makes is that the coordinator is
> > that
> > > > one
> > > > > process that has the ability to know the metadata for group
> members,
> > > > which
> > > > > does not work for any non-consumer use case.
> > > > >
> > > > > I wonder if we may be complicating the design of 95% use cases for
> > the
> > > > > remaining 5%. For instance, how many times do people create and
> > remove
> > > > > topics or even add partitions? We operated LI clusters for a long
> > time
> > > > and
> > > > > this wasn't a frequent event that would need us to optimize this
> > design
> > > > > for.
> > > > >
> > > > > Also, this is something we can easily validate by running a few
> tests
> > > on
> > > > > the patch and I suggest we wait for that.
> > > > >
> > > > > Thanks,
> > > > > Neha
> > > > >
> > > > > On Sat, Aug 15, 2015 at 9:14 AM, Jason Gustafson <
> jason@confluent.io
> > >
> > > > > wrote:
> > > > >
> > > > > > Hey Jiangjie,
> > > > > >
> > > > > > I was thinking about the same problem. When metadata is changing
> > > > > > frequently, the clients may not be able to ever find agreement on
> > the
> > > > > > current state. The server doesn't have this problem, as you say,
> > > > because
> > > > > it
> > > > > > can just take a snapshot and send that to the clients. Adding a
> > > > dampening
> > > > > > setting to the client would help if churn is sporadic, but not if
> > it
> > > is
> > > > > > steady. I think the metadata would have to be changing really
> > > > frequently
> > > > > > for this to be a problem practically, but this is a case where
> the
> > > > > > server-side approach has an advantage.
> > > > > >
> > > > > > Including the metadata in the join group response would require
> > > making
> > > > > the
> > > > > > subscription available to the coordinator, right? We lose a
> little
> > > bit
> > > > of
> > > > > > the generality of the protocol, but it might not be too bad since
> > > most
> > > > > use
> > > > > > cases for reusing this protocol have a similar need for metadata
> > (and
> > > > > they
> > > > > > can always pass an empty subscription if they don't). We've gone
> > back
> > > > and
> > > > > > forth a few times on this, and I'm generally not opposed. It
> might
> > > help
> > > > > if
> > > > > > we try to quantify the impact of the metadata churn in practice.
> I
> > > > think
> > > > > > the rate of change would have to be in the low seconds for this
> to
> > > be a
> > > > > > real problem. It does seem nice though that we have a way to
> manage
> > > > even
> > > > > > this much churn when we do this.
> > > > > >
> > > > > > -Jason
> > > > > >
> > > > > >
> > > > > >
> > > > > > On Fri, Aug 14, 2015 at 9:03 PM, Jiangjie Qin
> > > > <jqin@linkedin.com.invalid
> > > > > >
> > > > > > wrote:
> > > > > >
> > > > > > > Ewen,
> > > > > > >
> > > > > > > I agree that if there is a churn in metadata, the consumers
> need
> > > > > several
> > > > > > > rounds of rebalances to succeed. The difference I am thinking
> is
> > > that
> > > > > > with
> > > > > > > coordinator as single source of truth, we can let the consumer
> > > finish
> > > > > one
> > > > > > > round of rebalance, work for a while and start the next round
> of
> > > > > > rebalance.
> > > > > > > If we purely depend on the consumers to synchronize by
> themselves
> > > > based
> > > > > > on
> > > > > > > different metadata sources, is it possible we have some groups
> > > > > spending a
> > > > > > > lot of time on rebalancing but not able to make too much
> progress
> > > in
> > > > > > > consuming?
> > > > > > >
> > > > > > > I'm thinking can we let consumers to fetch metadata only from
> > their
> > > > > > > coordinator? So the rebalance can be done in the following way:
> > > > > > >
> > > > > > > 1. Consumers refresh their metadata periodically
> > > > > > > 2. If one of the consumer sees a change in metadata that
> > triggers a
> > > > > > > rebalance, it sends JoinGroupRequest to coordinator.
> > > > > > > 3. Once the coordinator receives the first JoinGroupRequest of
> a
> > > > group,
> > > > > > it
> > > > > > > takes a snapshot of current metadata and the group enters
> > > > > > prepare-rebalance
> > > > > > > state.
> > > > > > > 4. The metadata snapshot will be used for this round of
> > rebalance.
> > > > i.e.
> > > > > > the
> > > > > > > metadata snapshot will be sent to consumers in
> JoinGroupResponse.
> > > > > > > 4.1 If the consumers are subscribing to explicit topic lists
> (not
> > > > > regex),
> > > > > > > the JoinGroupResponse needs only contain the metadata of all
> > topics
> > > > the
> > > > > > > group is interested.
> > > > > > > 4.2 If the consumers are subscribing using regex, all the topic
> > > > > metadata
> > > > > > > will be returned to the consumer.
> > > > > > > 5. Consumers get JoinGroupResponse, refresh metadata using the
> > > > metadata
> > > > > > in
> > > > > > > JoinGroupResponse, run algorithm to assign partitions and start
> > > > > consume.
> > > > > > > 6. Go back to 1.
> > > > > > >
> > > > > > > The benefit here is that we can let rebalance finish in one
> > round,
> > > > and
> > > > > > all
> > > > > > > the rest of changes will be captured in next consumer metadata
> > > > refresh
> > > > > -
> > > > > > so
> > > > > > > we get group commit. One concern might be letting consumer
> > refresh
> > > > > > metadata
> > > > > > > from coordinator might cause issue for big consumer groups.
> Maybe
> > > > that
> > > > > is
> > > > > > > OK because metadata refresh is infrequent.
> > > > > > >
> > > > > > > This approach actually is very similar to what is proposed now:
> > > > > rebalance
> > > > > > > is triggered by metadata refresh, consumer provides
> subscription
> > > list
> > > > > to
> > > > > > > pass around. The only difference is that we don't need metadata
> > > hash
> > > > > > > anymore because the metadata is guaranteed to be the same.
> > > Replacing
> > > > > > > metadata hash with actual metadata will not have too much
> > overhead
> > > > for
> > > > > > > small subscription groups. There will be some overhead for
> regex
> > > > > > > subscriptions, but this can save the potential extra round of
> > > > metadata
> > > > > > > fetch and will only occur when consumer see metadata change,
> > which
> > > is
> > > > > > > infrequent.
> > > > > > >
> > > > > > > Any thoughts?
> > > > > > >
> > > > > > > Thanks,
> > > > > > >
> > > > > > > Jiangjie (Becket) Qin
> > > > > > >
> > > > > > >
> > > > > > > On Fri, Aug 14, 2015 at 12:57 PM, Ewen Cheslack-Postava <
> > > > > > ewen@confluent.io
> > > > > > > >
> > > > > > > wrote:
> > > > > > >
> > > > > > > > On Fri, Aug 14, 2015 at 10:59 AM, Jiangjie Qin
> > > > > > <jqin@linkedin.com.invalid
> > > > > > > >
> > > > > > > > wrote:
> > > > > > > >
> > > > > > > > > Neha and Ewen,
> > > > > > > > >
> > > > > > > > > About the metadata change frequency. I guess it really
> > depends
> > > on
> > > > > how
> > > > > > > > > frequent the metadata change might occur. If we run Kafka
> as
> > a
> > > > > > > service, I
> > > > > > > > > can see that happens from time to time. As I can imagine
> > people
> > > > > will
> > > > > > > > create
> > > > > > > > > some topic, test and maybe delete the topic in some
> automated
> > > > test.
> > > > > > If
> > > > > > > > so,
> > > > > > > > > the proposed protocol might be a little bit vulnerable.
> > > > > > > > >
> > > > > > > > > More specifically the scenario I am thinking is:
> > > > > > > > > 1. Consumer 0 periodically refresh metadata and detected a
> > > > metadata
> > > > > > > > change.
> > > > > > > > > So it sends a JoinGroupRequest with metadata_hash_0.
> > > > > > > > > 2. Consumer 1 was notified by controller to start a
> > rebalance,
> > > so
> > > > > it
> > > > > > > > > refreshes its metadata and send a JoingGroupRequest with
> > > > > > > metadata_hash_1,
> > > > > > > > > which is different from metadata hash 0.
> > > > > > > > > 3. Rebalance failed and both consumer refresh there
> metadata
> > > > again
> > > > > > from
> > > > > > > > > different brokers.
> > > > > > > > > 4. Depending on the metadata change frequency(or some admin
> > > > > operation
> > > > > > > > like
> > > > > > > > > partition reassigment), they may or may not have the same
> > > > metadata
> > > > > > > > > returned, so the restart from 3 again.
> > > > > > > > >
> > > > > > > > > I agree that step 4 might not be a big concern if consumers
> > > > updates
> > > > > > > > > metadata at almost the same time, but I'm a little bit
> > worried
> > > > > > whether
> > > > > > > > that
> > > > > > > > > assumption really stands because we do not have control
> over
> > > how
> > > > > > > frequent
> > > > > > > > > the metadata can change.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > Is this really that different from what would happen if the
> > > > > coordinator
> > > > > > > > distributed the metadata to consumers? In that case you would
> > > > > trivially
> > > > > > > > have everyone in a consistent state, but those metadata
> changes
> > > > would
> > > > > > > still
> > > > > > > > cause churn and require JoinGroup rounds, during which
> > processing
> > > > is
> > > > > > > > stalled for the nodes that are waiting on other members to
> > > re-join
> > > > > the
> > > > > > > > group.
> > > > > > > >
> > > > > > > > -Ewen
> > > > > > > >
> > > > > > > >
> > > > > > > > > Thanks,
> > > > > > > > >
> > > > > > > > > Jiangjie (Becket) Qin
> > > > > > > > >
> > > > > > > > > On Fri, Aug 14, 2015 at 2:03 AM, Ewen Cheslack-Postava <
> > > > > > > > ewen@confluent.io>
> > > > > > > > > wrote:
> > > > > > > > >
> > > > > > > > > > On Thu, Aug 13, 2015 at 11:07 PM, Neha Narkhede <
> > > > > neha@confluent.io
> > > > > > >
> > > > > > > > > wrote:
> > > > > > > > > >
> > > > > > > > > > > Becket,
> > > > > > > > > > >
> > > > > > > > > > > As you say, the metadata hash addresses the concern you
> > > > > > originally
> > > > > > > > > raised
> > > > > > > > > > > about large topic subscriptions. Can you please list
> > other
> > > > > > problems
> > > > > > > > you
> > > > > > > > > > are
> > > > > > > > > > > raising more clearly? It is more helpful to know
> problems
> > > > that
> > > > > > the
> > > > > > > > > > proposal
> > > > > > > > > > > does not address or addresses poorly.
> > > > > > > > > > >
> > > > > > > > > > > Regarding other things you said -
> > > > > > > > > > >
> > > > > > > > > > > it is required that each
> > > > > > > > > > > > consumer refresh their metadata before sending a
> > > > > > JoinGroupRequest
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > This is required for wildcard topic subscriptions
> anyway.
> > > So
> > > > > this
> > > > > > > > > > proposal
> > > > > > > > > > > does not introduce a regression. We had agreed earlier
> > that
> > > > it
> > > > > > does
> > > > > > > > not
> > > > > > > > > > > make sense for the server to deserialize regular
> > > expressions
> > > > > sent
> > > > > > > by
> > > > > > > > > the
> > > > > > > > > > > consumer.
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > I don't think consumers need to do a metadata refresh
> > before
> > > > > > sending
> > > > > > > a
> > > > > > > > > > JoinGroupRequest. Metadata changes that affect assignment
> > are
> > > > > rare
> > > > > > --
> > > > > > > > it
> > > > > > > > > > requires changing the number of partitions in a topic.
> But
> > > you
> > > > > > might
> > > > > > > > > send a
> > > > > > > > > > JoinGroupRequest simply because a new member is trying to
> > > join
> > > > > the
> > > > > > > > group.
> > > > > > > > > > That case is presumably much more common.
> > > > > > > > > >
> > > > > > > > > > I think it's actually a good idea to have the first
> > JoinGroup
> > > > > cycle
> > > > > > > > fail
> > > > > > > > > in
> > > > > > > > > > some cases, and has little impact. Lets say the metadata
> > does
> > > > > > change
> > > > > > > > > > because partitions are added. Then we might fail in the
> > first
> > > > > > round,
> > > > > > > > but
> > > > > > > > > > then all members detect that issue *immediately*, refresh
> > > their
> > > > > > > > metadata,
> > > > > > > > > > and submit a new join group request. This second cycle
> does
> > > not
> > > > > > > > require a
> > > > > > > > > > full heartbeat cycle. It happens much more quickly
> because
> > > > > everyone
> > > > > > > > > > detected the inconsistency based on the first
> > > > JoinGroupResponse.
> > > > > > The
> > > > > > > > > > inconsistency should be resolved very quickly (barring
> > other
> > > > > > failures
> > > > > > > > > like
> > > > > > > > > > a member leaving mid-rebalance)
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > > the metadata might still be inconsistent if there is
> a
> > > > topic
> > > > > or
> > > > > > > > > > partition
> > > > > > > > > > > > change because the
> > > > > > > > > > > > UpdateMetadataRequest from controller might be
> handled
> > at
> > > > > > > different
> > > > > > > > > > time.
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Topic metadata does not change frequently and even if
> it
> > > > did, a
> > > > > > > > couple
> > > > > > > > > > > rebalance attempts will be needed whether the
> coordinator
> > > > > drives
> > > > > > > the
> > > > > > > > > > > assignments or the consumer. Because guess how the
> > > > coordinator
> > > > > > > knows
> > > > > > > > > > about
> > > > > > > > > > > the topic metadata changes -- indirectly through
> either a
> > > zk
> > > > > > > callback
> > > > > > > > > or
> > > > > > > > > > > UpdateMetadataRequest, so it is completely possible the
> > > > > > coordinator
> > > > > > > > > sees
> > > > > > > > > > > the topic metadata changes in batches, not all at once.
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > > On Thu, Aug 13, 2015 at 10:50 PM, Neha Narkhede <
> > > > > > neha@confluent.io
> > > > > > > >
> > > > > > > > > > wrote:
> > > > > > > > > > >
> > > > > > > > > > > > Ewen/Jason,
> > > > > > > > > > > >
> > > > > > > > > > > > The metadata hash is a clever approach and certainly
> > > > > addresses
> > > > > > > the
> > > > > > > > > > > problem
> > > > > > > > > > > > of large metadata for consumers like mirror maker.
> Few
> > > > > > comments -
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >    1. In the interest of simplifying the format of
> the
> > > > > > consumer's
> > > > > > > > > > > >    metadata - Why not just always include only the
> > topic
> > > > > names
> > > > > > in
> > > > > > > > the
> > > > > > > > > > > metadata
> > > > > > > > > > > >    followed by the metadata hash? If the metadata
> hash
> > > > check
> > > > > > > > > succeeds,
> > > > > > > > > > > each
> > > > > > > > > > > >    consumer uses the # of partitions it had fetched.
> If
> > > it
> > > > > > > fails, a
> > > > > > > > > > > rebalance
> > > > > > > > > > > >    happens and the metadata is not used anyway.
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Doing this requires that every consumer always fetch the
> > full
> > > > > > > metadata.
> > > > > > > > > The
> > > > > > > > > > most common use case is consumers that just want to
> consume
> > > one
> > > > > or
> > > > > > a
> > > > > > > > > couple
> > > > > > > > > > of topics, in which case grabbing all metadata for the
> > entire
> > > > > > cluster
> > > > > > > > is
> > > > > > > > > > wasteful. If I subscribe only to topic A, why make all
> > > > consumers
> > > > > > grab
> > > > > > > > > > metadata for the entire topic (and need to rebalance
> every
> > > time
> > > > > it
> > > > > > > > > > changes!). Including the # of partitions for each topic
> > lets
> > > > you
> > > > > > > avoid
> > > > > > > > > > having to grab the global set of metadata.
> > > > > > > > > >
> > > > > > > > > > So if you're just subscribing to one or a couple of
> topics,
> > > why
> > > > > not
> > > > > > > > just
> > > > > > > > > > compute the hash by filtering out everything but the
> topics
> > > you
> > > > > are
> > > > > > > > > > subscribed to? The problem there is if you ever
> add/remove
> > > > > > > > subscriptions
> > > > > > > > > > and want to support rolling upgrades. If the group was
> > > > subscribed
> > > > > > to
> > > > > > > > > topic
> > > > > > > > > > A, but later changes require subscribing to A + B, then
> to
> > > > > achieve
> > > > > > a
> > > > > > > > > > seamless rolling upgrade would require one (old) consumer
> > to
> > > be
> > > > > > > > > subscribing
> > > > > > > > > > to A and one (new) consumer to be subscribing to A+B. If
> we
> > > > > > computed
> > > > > > > > > > metadata hashes based on filtered metadata, those two
> would
> > > > > > disagree
> > > > > > > > and
> > > > > > > > > we
> > > > > > > > > > could not perform assignment while the upgrade was in
> > > progress.
> > > > > > > > > >
> > > > > > > > > > The solution is to differentiate between the cases when a
> > > very
> > > > > > small
> > > > > > > > > amount
> > > > > > > > > > of the metadata is needed (one or a couple of topic
> > > > > subscriptions;
> > > > > > > > > > communicate and share this via metadata in the JoinGroup
> > > > > protocol)
> > > > > > vs
> > > > > > > > > when
> > > > > > > > > > *all* the metadata is needed (regex subscription; verify
> > > > > agreement
> > > > > > > via
> > > > > > > > > > hash).
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > > >    2. Do you need a topic list and topic regex to be
> > > > > separate?
> > > > > > A
> > > > > > > > > single
> > > > > > > > > > > >    topic or list of topics can be expressed as a
> regex.
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > See above note about collecting all metadata when you
> > really
> > > > only
> > > > > > > need
> > > > > > > > it
> > > > > > > > > > for 1 or 2 topics. There's probably some debate to be had
> > > about
> > > > > > > whether
> > > > > > > > > > this cost would be too high -- every consumer would need
> to
> > > > > request
> > > > > > > the
> > > > > > > > > > metadata for all topics, and they'd need to request that
> > all
> > > > > every
> > > > > > > time
> > > > > > > > > > they might be out of date.
> > > > > > > > > >
> > > > > > > > > Are we going to allow consumers in the same group to
> > subscribe
> > > to
> > > > > > > > different
> > > > > > > > > topic set? If we do, we need to let them refresh metadata
> for
> > > all
> > > > > the
> > > > > > > > > topics a group is consuming from. If we don't then in the
> > > > protocol
> > > > > we
> > > > > > > > only
> > > > > > > > > need a subscription set hash.
> > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > > >    3. Let's include a version explicitly at the
> > beginning
> > > > of
> > > > > > the
> > > > > > > > > > > >    ProtocolMetadata. The version dictates how to
> > > > deserialize
> > > > > > the
> > > > > > > > > > > >    ProtocolMetadata blob and is consistent with the
> > rest
> > > of
> > > > > > > Kafka.
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > If I'm understanding correctly, in JoinGroupRequest I
> would
> > > > > change
> > > > > > > > > >
> > > > > > > > > > GroupProtocols          => [Protocol ProtocolMetadata]
> > > > > > > > > >
> > > > > > > > > > to
> > > > > > > > > >
> > > > > > > > > > GroupProtocols          => [Protocol ProtocolVersion
> > > > > > > ProtocolMetadata]
> > > > > > > > > >
> > > > > > > > > > We had been talking about just baking the version into
> the
> > > > > Protocol
> > > > > > > > > field,
> > > > > > > > > > but making it separate seems perfectly reasonable to me.
> > > Jason,
> > > > > any
> > > > > > > > issue
> > > > > > > > > > with splitting the version out into a separate field like
> > > this?
> > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > > That can simplify the metadata format to the
> following:
> > > > > > > > > > > >
> > > > > > > > > > > > GroupType => "consumer"
> > > > > > > > > > > >>
> > > > > > > > > > > >> Protocol => AssignmentStrategy
> > > > > > > > > > > >>   AssignmentStrategy   => String
> > > > > > > > > > > >>
> > > > > > > > > > > >> ProtocolMetadata => Version Subscription
> > > > > > > > AssignmentStrategyMetadata
> > > > > > > > > > > >
> > > > > > > > > > > >     Version                    => String
> > > > > > > > > > > >
> > > > > > > > > > > >   Subscription                 => TopicRegex
> > MetadataHash
> > > > > > > > > > > >>     TopicRegex                 => String
> > > > > > > > > > > >>     MetadataHash               => String
> > > > > > > > > > > >>   AssignmentStrategyMetadata   => bytes
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > On Thu, Aug 13, 2015 at 6:28 PM, Jiangjie Qin
> > > > > > > > > > <jqin@linkedin.com.invalid
> > > > > > > > > > > >
> > > > > > > > > > > > wrote:
> > > > > > > > > > > >
> > > > > > > > > > > >> Ewen and Jason,
> > > > > > > > > > > >>
> > > > > > > > > > > >> Thanks for the reply. Sorry I missed the metadata
> > hash.
> > > > Yes,
> > > > > > > that
> > > > > > > > > is a
> > > > > > > > > > > >> clever approach and would solve my concern about the
> > > data
> > > > > > > passing
> > > > > > > > > > > around.
> > > > > > > > > > > >> I
> > > > > > > > > > > >> can see both pros and cons from doing this, though.
> > The
> > > > > > > advantage
> > > > > > > > is
> > > > > > > > > > we
> > > > > > > > > > > >> don't need the topic metadata in JoinGroupResponse
> > > > anymore.
> > > > > > The
> > > > > > > > > > downside
> > > > > > > > > > > >> is
> > > > > > > > > > > >> that now rebalance have extra dependency on the
> > > consensus
> > > > of
> > > > > > > > > metadata
> > > > > > > > > > of
> > > > > > > > > > > >> all consumers, which is obtained separately. So it
> is
> > > > > required
> > > > > > > > that
> > > > > > > > > > each
> > > > > > > > > > > >> consumer refresh their metadata before sending a
> > > > > > > JoinGroupRequest,
> > > > > > > > > > > >> otherwise in some cases (e.g. wildcard consumers)
> will
> > > > > almost
> > > > > > > > > > certainly
> > > > > > > > > > > >> fail for the first rebalance attempt. Even if we do
> > > that,
> > > > > > since
> > > > > > > > the
> > > > > > > > > > > >> consumers are getting metadata from different
> brokers,
> > > the
> > > > > > > > metadata
> > > > > > > > > > > might
> > > > > > > > > > > >> still be inconsistent if there is a topic or
> partition
> > > > > change
> > > > > > > > > because
> > > > > > > > > > > the
> > > > > > > > > > > >> UpdateMetadataRequest from controller might be
> handled
> > > at
> > > > > > > > different
> > > > > > > > > > > time.
> > > > > > > > > > > >> Just want to make sure we think through the cases so
> > the
> > > > > > > protocol
> > > > > > > > > does
> > > > > > > > > > > not
> > > > > > > > > > > >> cause us unexpected issues.
> > > > > > > > > > > >>
> > > > > > > > > > > >> About the number of consumers, I think with the
> > current
> > > > > > > liveliness
> > > > > > > > > > > >> definition, we can tolerate churns by bumping up the
> > > > session
> > > > > > > > > timeout.
> > > > > > > > > > > Also
> > > > > > > > > > > >> I guess we will see an increasing number of
> consumers
> > > for
> > > > > new
> > > > > > > > > > consumer,
> > > > > > > > > > > >> because every the old consumer thread will probably
> > > > become a
> > > > > > > > > consumer.
> > > > > > > > > > > >>
> > > > > > > > > > > >> It is a valid concern for consumers that have large
> > > > > > subscription
> > > > > > > > > set.
> > > > > > > > > > > This
> > > > > > > > > > > >> might not be avoided though for client side
> assignment
> > > > > > approach.
> > > > > > > > One
> > > > > > > > > > > >> solution is having topic names associate with a
> topic
> > > ID.
> > > > > And
> > > > > > > only
> > > > > > > > > use
> > > > > > > > > > > >> topic ID in JoinGroupRequest and JoinGroupResponse,
> > > There
> > > > > is a
> > > > > > > > > > > discussion
> > > > > > > > > > > >> thread about this to solve the topic renaming case
> but
> > > > this
> > > > > > is a
> > > > > > > > > > > >> completely
> > > > > > > > > > > >> different discussion.
> > > > > > > > > > > >>
> > > > > > > > > > > >> Thanks,
> > > > > > > > > > > >>
> > > > > > > > > > > >> Jiangjie (Becket) Qin
> > > > > > > > > > > >>
> > > > > > > > > > > >>
> > > > > > > > > > > >>
> > > > > > > > > > > >> On Thu, Aug 13, 2015 at 2:14 PM, Jason Gustafson <
> > > > > > > > > jason@confluent.io>
> > > > > > > > > > > >> wrote:
> > > > > > > > > > > >>
> > > > > > > > > > > >> > Thanks Jiangjie, that information helps. I agree
> the
> > > > > > protocol
> > > > > > > > must
> > > > > > > > > > > >> consider
> > > > > > > > > > > >> > scalability. My point was that the synchronization
> > > > barrier
> > > > > > in
> > > > > > > > the
> > > > > > > > > > > >> current
> > > > > > > > > > > >> > protocol already effectively limits the number of
> > > > > consumers
> > > > > > > > since
> > > > > > > > > it
> > > > > > > > > > > >> > provides no way to gracefully handle churn. It
> > > wouldn't
> > > > be
> > > > > > > worth
> > > > > > > > > > > >> worrying
> > > > > > > > > > > >> > about scaling up to 100,000 members, for example,
> > > > because
> > > > > > > > there's
> > > > > > > > > no
> > > > > > > > > > > way
> > > > > > > > > > > >> > the group would be stable. So we just need to set
> > some
> > > > > clear
> > > > > > > > > > > >> expectations
> > > > > > > > > > > >> > on the size we can scale to, and that can help
> > inform
> > > > the
> > > > > > > > > discussion
> > > > > > > > > > > on
> > > > > > > > > > > >> the
> > > > > > > > > > > >> > size of messages in this protocol.
> > > > > > > > > > > >> >
> > > > > > > > > > > >> > Ewen and I were discussing this morning along
> > similar
> > > > > lines
> > > > > > to
> > > > > > > > > what
> > > > > > > > > > > >> you're
> > > > > > > > > > > >> > suggesting. However, even if the coordinator
> decides
> > > on
> > > > > the
> > > > > > > > > metadata
> > > > > > > > > > > for
> > > > > > > > > > > >> > the group, each member still needs to communicate
> > its
> > > > > > > > > subscriptions
> > > > > > > > > > to
> > > > > > > > > > > >> the
> > > > > > > > > > > >> > rest of the group. This is nice for the regex case
> > > since
> > > > > the
> > > > > > > > regex
> > > > > > > > > > is
> > > > > > > > > > > >> > probably small, but if the members have a large
> > topic
> > > > > list,
> > > > > > > then
> > > > > > > > > we
> > > > > > > > > > > have
> > > > > > > > > > > >> > the same problem. One thing I was thinking about
> was
> > > > > whether
> > > > > > > we
> > > > > > > > > > really
> > > > > > > > > > > >> need
> > > > > > > > > > > >> > to handle different subscriptions for every
> member.
> > If
> > > > the
> > > > > > > > > > coordinator
> > > > > > > > > > > >> > could guarantee that all members had the same
> > > > > subscription,
> > > > > > > then
> > > > > > > > > > there
> > > > > > > > > > > >> > would be no need for the coordinator to return the
> > > > > > > subscriptions
> > > > > > > > > for
> > > > > > > > > > > >> each
> > > > > > > > > > > >> > member. However, this would prevent graceful
> > upgrades.
> > > > We
> > > > > > > might
> > > > > > > > be
> > > > > > > > > > > able
> > > > > > > > > > > >> to
> > > > > > > > > > > >> > fix that problem by allowing the consumer to
> provide
> > > two
> > > > > > > > > > subscriptions
> > > > > > > > > > > >> to
> > > > > > > > > > > >> > allowing rolling updates, but that starts to sound
> > > > pretty
> > > > > > > nasty.
> > > > > > > > > > > >> >
> > > > > > > > > > > >> > -Jason
> > > > > > > > > > > >> >
> > > > > > > > > > > >> > On Thu, Aug 13, 2015 at 1:41 PM, Jiangjie Qin
> > > > > > > > > > > <jqin@linkedin.com.invalid
> > > > > > > > > > > >> >
> > > > > > > > > > > >> > wrote:
> > > > > > > > > > > >> >
> > > > > > > > > > > >> > > Jason,
> > > > > > > > > > > >> > >
> > > > > > > > > > > >> > > The protocol has to consider the scalability.
> The
> > > > > protocol
> > > > > > > in
> > > > > > > > > the
> > > > > > > > > > > wiki
> > > > > > > > > > > >> > > means the JoinGroupResoponse size would be:
> > > > > > > > > > > >> > > NumberOfTopics * (AvgTopicNameLength + 4) *
> > > > > > > > > (NumberOfConsumers)^2
> > > > > > > > > > > >> > >
> > > > > > > > > > > >> > > To give some real number, we have 26-node Mirror
> > > Maker
> > > > > > > > cluster,
> > > > > > > > > > each
> > > > > > > > > > > >> > with 4
> > > > > > > > > > > >> > > consumers. That is 104 consumers using regex
> ".*".
> > > And
> > > > > > most
> > > > > > > of
> > > > > > > > > our
> > > > > > > > > > > >> > clusters
> > > > > > > > > > > >> > > have around 3000 topics, whose topic name are
> > > > typically
> > > > > > > around
> > > > > > > > > 20
> > > > > > > > > > > >> > > characters.
> > > > > > > > > > > >> > >
> > > > > > > > > > > >> > > I think the key issue for client side partition
> > > > > assignment
> > > > > > > > logic
> > > > > > > > > > is
> > > > > > > > > > > to
> > > > > > > > > > > >> > make
> > > > > > > > > > > >> > > sure 1) all the clients run the same algorithm.
> 2)
> > > all
> > > > > the
> > > > > > > > > clients
> > > > > > > > > > > >> make
> > > > > > > > > > > >> > > decision on the same topic metadata. The second
> > > > purpose
> > > > > > can
> > > > > > > be
> > > > > > > > > > done
> > > > > > > > > > > by
> > > > > > > > > > > >> > > simply letting coordinator provide the topic
> > > metadata
> > > > > and
> > > > > > > all
> > > > > > > > > then
> > > > > > > > > > > >> member
> > > > > > > > > > > >> > > information as source of truth. Is it necessary
> to
> > > > pass
> > > > > > > topic
> > > > > > > > > > > >> metadata of
> > > > > > > > > > > >> > > each consumer around? Can we keep the protocol
> > > > metadata
> > > > > > > field
> > > > > > > > > > > >> completely
> > > > > > > > > > > >> > > independent of topic metadata? I think In the
> > > > > > > > JoinGroupResponse,
> > > > > > > > > > we
> > > > > > > > > > > >> > should
> > > > > > > > > > > >> > > have only one copy of topic metadata provided by
> > > > > > coordinator
> > > > > > > > and
> > > > > > > > > > is
> > > > > > > > > > > >> > outside
> > > > > > > > > > > >> > > of protocol metadata. If user decides to put
> some
> > > > > metadata
> > > > > > > in
> > > > > > > > > the
> > > > > > > > > > > >> > > JoinGroupRequest and let coordinator pass
> around,
> > > they
> > > > > are
> > > > > > > > > > > responsible
> > > > > > > > > > > >> > for
> > > > > > > > > > > >> > > understanding the risk.
> > > > > > > > > > > >> > >
> > > > > > > > > > > >> > > Thanks,
> > > > > > > > > > > >> > >
> > > > > > > > > > > >> > > Jiangjie (Becket) Qin
> > > > > > > > > > > >> > >
> > > > > > > > > > > >> > >
> > > > > > > > > > > >> > > On Thu, Aug 13, 2015 at 12:41 PM, Jason
> Gustafson
> > <
> > > > > > > > > > > jason@confluent.io
> > > > > > > > > > > >> >
> > > > > > > > > > > >> > > wrote:
> > > > > > > > > > > >> > >
> > > > > > > > > > > >> > > > Hey Onur and Jiangjie,
> > > > > > > > > > > >> > > >
> > > > > > > > > > > >> > > > I've updated that wiki with a proposal to add
> > > regex
> > > > > > > > > > subscriptions
> > > > > > > > > > > to
> > > > > > > > > > > >> > the
> > > > > > > > > > > >> > > > consumer metadata. Can you have a look to see
> if
> > > it
> > > > > > > > addresses
> > > > > > > > > > your
> > > > > > > > > > > >> > > concern?
> > > > > > > > > > > >> > > > In general, I think we should be a little
> > careful
> > > > when
> > > > > > we
> > > > > > > > are
> > > > > > > > > > > >> talking
> > > > > > > > > > > >> > > about
> > > > > > > > > > > >> > > > the scalability of the protocol. Regardless of
> > > > whether
> > > > > > > > > > assignment
> > > > > > > > > > > is
> > > > > > > > > > > >> > done
> > > > > > > > > > > >> > > > on the server or the client, the protocol
> > assumes
> > > a
> > > > > > > > relatively
> > > > > > > > > > > >> stable
> > > > > > > > > > > >> > > > configuration. When the number of consumers
> > > > increases
> > > > > > > > beyond a
> > > > > > > > > > > >> certain
> > > > > > > > > > > >> > > > limit, then membership churn becomes a major
> > > > concern.
> > > > > > > > > Similarly
> > > > > > > > > > > >> there
> > > > > > > > > > > >> > is
> > > > > > > > > > > >> > > a
> > > > > > > > > > > >> > > > notion of metadata churn when topics are
> added,
> > > > > deleted,
> > > > > > > or
> > > > > > > > > > > >> resized. If
> > > > > > > > > > > >> > > > either membership or metadata changes, then
> the
> > > > > protocol
> > > > > > > > > forces
> > > > > > > > > > > all
> > > > > > > > > > > >> > > > consumers to stop consumption and rejoin the
> > > group.
> > > > If
> > > > > > > this
> > > > > > > > > > > happens
> > > > > > > > > > > >> > often
> > > > > > > > > > > >> > > > enough, then it can severely impact the
> ability
> > of
> > > > the
> > > > > > > > > consumer
> > > > > > > > > > to
> > > > > > > > > > > >> make
> > > > > > > > > > > >> > > > progress. The point is that the protocol may
> > > already
> > > > > be
> > > > > > > > > unsuited
> > > > > > > > > > > to
> > > > > > > > > > > >> > cases
> > > > > > > > > > > >> > > > where there are either a large number of
> > consumers
> > > > or
> > > > > > > > topics.
> > > > > > > > > I
> > > > > > > > > > > >> wonder
> > > > > > > > > > > >> > if
> > > > > > > > > > > >> > > > you guys can share your thoughts about your
> > > scaling
> > > > > > > > > > expectations?
> > > > > > > > > > > >> > > >
> > > > > > > > > > > >> > > > -Jason
> > > > > > > > > > > >> > > >
> > > > > > > > > > > >> > > >
> > > > > > > > > > > >> > > >
> > > > > > > > > > > >> > > >
> > > > > > > > > > > >> > > > On Wed, Aug 12, 2015 at 12:28 PM, Jason
> > Gustafson
> > > <
> > > > > > > > > > > >> jason@confluent.io>
> > > > > > > > > > > >> > > > wrote:
> > > > > > > > > > > >> > > >
> > > > > > > > > > > >> > > > > Hey Jiangjie,
> > > > > > > > > > > >> > > > >
> > > > > > > > > > > >> > > > > That's a great point. In the worst case (the
> > > > mirror
> > > > > > > maker
> > > > > > > > > > case I
> > > > > > > > > > > >> > > guess),
> > > > > > > > > > > >> > > > > the join group response can be massive. This
> > > would
> > > > > be
> > > > > > > > > > especially
> > > > > > > > > > > >> > deadly
> > > > > > > > > > > >> > > > > when there is a lot of churn in the group
> > (e.g.
> > > > in a
> > > > > > > > rolling
> > > > > > > > > > > >> > upgrade).
> > > > > > > > > > > >> > > > The
> > > > > > > > > > > >> > > > > current protocol is not great for this case
> > > > either,
> > > > > > but
> > > > > > > > it's
> > > > > > > > > > > >> > > > significantly
> > > > > > > > > > > >> > > > > better. Here are a couple ways to deal with
> > the
> > > > > size:
> > > > > > > > > > > >> > > > >
> > > > > > > > > > > >> > > > > 1. First, we could have the coordinator
> > compress
> > > > the
> > > > > > > > > > responses.
> > > > > > > > > > > >> This
> > > > > > > > > > > >> > > > would
> > > > > > > > > > > >> > > > > probably be pretty effective if applied
> across
> > > the
> > > > > > > > metadata
> > > > > > > > > > from
> > > > > > > > > > > >> all
> > > > > > > > > > > >> > > > > members.
> > > > > > > > > > > >> > > > >
> > > > > > > > > > > >> > > > > 2. I think the regex case is the main
> problem.
> > > Is
> > > > > that
> > > > > > > > > right?
> > > > > > > > > > We
> > > > > > > > > > > >> > could
> > > > > > > > > > > >> > > > > extend the metadata to allow the consumer to
> > > embed
> > > > > its
> > > > > > > > regex
> > > > > > > > > > > >> > > subscription
> > > > > > > > > > > >> > > > > in the metadata directly (note this might
> be a
> > > > good
> > > > > > idea
> > > > > > > > > > > >> regardless
> > > > > > > > > > > >> > of
> > > > > > > > > > > >> > > > the
> > > > > > > > > > > >> > > > > rest of this proposal). To support regex on
> > the
> > > > > > > consumer,
> > > > > > > > we
> > > > > > > > > > > must
> > > > > > > > > > > >> > fetch
> > > > > > > > > > > >> > > > > metadata for all topics. Rather than having
> > all
> > > > > regex
> > > > > > > > > > > subscribers
> > > > > > > > > > > >> > embed
> > > > > > > > > > > >> > > > all
> > > > > > > > > > > >> > > > > of this metadata in their join group
> requests,
> > > > they
> > > > > > > could
> > > > > > > > > > > instead
> > > > > > > > > > > >> > > embed a
> > > > > > > > > > > >> > > > > hash of it. Then after the join group
> > responses
> > > > are
> > > > > > > > > received,
> > > > > > > > > > > they
> > > > > > > > > > > >> > just
> > > > > > > > > > > >> > > > > need to check that the hashes are the same.
> If
> > > > there
> > > > > > is
> > > > > > > a
> > > > > > > > > > > mismatch
> > > > > > > > > > > >> > > (which
> > > > > > > > > > > >> > > > > should only occur when topics are created,
> > > > deleted,
> > > > > or
> > > > > > > > > > resized),
> > > > > > > > > > > >> then
> > > > > > > > > > > >> > > the
> > > > > > > > > > > >> > > > > group members must refetch the metadata and
> > > rejoin
> > > > > the
> > > > > > > > > group.
> > > > > > > > > > > >> This is
> > > > > > > > > > > >> > > > also
> > > > > > > > > > > >> > > > > how the current protocol behaves when there
> > is a
> > > > > > change
> > > > > > > in
> > > > > > > > > the
> > > > > > > > > > > >> topic
> > > > > > > > > > > >> > > > > metadata affecting the group--someone
> (either
> > > the
> > > > > > > > > coordinator
> > > > > > > > > > or
> > > > > > > > > > > >> the
> > > > > > > > > > > >> > > > > consumer) detects the change and forces the
> > > group
> > > > to
> > > > > > > > > > rebalance.
> > > > > > > > > > > >> > > > >
> > > > > > > > > > > >> > > > > What do you think?
> > > > > > > > > > > >> > > > >
> > > > > > > > > > > >> > > > > (Also I think adding groupId/generationId to
> > > fetch
> > > > > and
> > > > > > > > > produce
> > > > > > > > > > > >> > requests
> > > > > > > > > > > >> > > > > seems like an interesting line of thought.)
> > > > > > > > > > > >> > > > >
> > > > > > > > > > > >> > > > > -Jason
> > > > > > > > > > > >> > > > >
> > > > > > > > > > > >> > > > >
> > > > > > > > > > > >> > > > >
> > > > > > > > > > > >> > > > > On Wed, Aug 12, 2015 at 10:57 AM, Jiangjie
> Qin
> > > > > > > > > > > >> > > <jqin@linkedin.com.invalid
> > > > > > > > > > > >> > > > >
> > > > > > > > > > > >> > > > > wrote:
> > > > > > > > > > > >> > > > >
> > > > > > > > > > > >> > > > >> Hey Ewen,
> > > > > > > > > > > >> > > > >>
> > > > > > > > > > > >> > > > >> Onur and I discussed this a little bit
> more.
> > > And
> > > > we
> > > > > > are
> > > > > > > > > still
> > > > > > > > > > > >> > worrying
> > > > > > > > > > > >> > > > >> about passing all the metadata of all
> > consumers
> > > > > > around.
> > > > > > > > > > > >> > > > >>
> > > > > > > > > > > >> > > > >> Let's say I have a cluster has 10,000
> topics,
> > > the
> > > > > > > average
> > > > > > > > > > topic
> > > > > > > > > > > >> name
> > > > > > > > > > > >> > > > >> length
> > > > > > > > > > > >> > > > >> is 10 bytes. In this case, the opaque
> > metadata
> > > > will
> > > > > > > have
> > > > > > > > > 10 *
> > > > > > > > > > > >> > 10,000 =
> > > > > > > > > > > >> > > > >> 100KB for topic name, for each topic, there
> > is
> > > a
> > > > > > 4-byte
> > > > > > > > > > integer
> > > > > > > > > > > >> of
> > > > > > > > > > > >> > > > number
> > > > > > > > > > > >> > > > >> of partitions, that's another 40KB. So one
> > > global
> > > > > > topic
> > > > > > > > > > > metadata
> > > > > > > > > > > >> > will
> > > > > > > > > > > >> > > > have
> > > > > > > > > > > >> > > > >> 140KB data. If I have 100 consumers who are
> > > using
> > > > > > > > wildcard
> > > > > > > > > to
> > > > > > > > > > > >> > consume
> > > > > > > > > > > >> > > > from
> > > > > > > > > > > >> > > > >> all the topics. That means the protocol
> > > metadata
> > > > > end
> > > > > > up
> > > > > > > > in
> > > > > > > > > > the
> > > > > > > > > > > >> > > > >> JoinGroupResponse will be 140KB * 100 =
> 14MB.
> > > And
> > > > > the
> > > > > > > > > > > >> > > JoinGroupResponse
> > > > > > > > > > > >> > > > >> will need to be sent to 100 different
> > > consumers,
> > > > > that
> > > > > > > > means
> > > > > > > > > > > 14MB
> > > > > > > > > > > >> *
> > > > > > > > > > > >> > > 100 =
> > > > > > > > > > > >> > > > >> 1.4GB need to be sent by the consumer
> > > coordinator
> > > > > for
> > > > > > > one
> > > > > > > > > > > >> rebalance.
> > > > > > > > > > > >> > > How
> > > > > > > > > > > >> > > > >> would that work?
> > > > > > > > > > > >> > > > >>
> > > > > > > > > > > >> > > > >> Also, having two consumers (old owner and
> new
> > > > > owner)
> > > > > > > > > > consuming
> > > > > > > > > > > >> from
> > > > > > > > > > > >> > > the
> > > > > > > > > > > >> > > > >> same partition might also be a problem.
> e.g.
> > > > people
> > > > > > are
> > > > > > > > > > > updating
> > > > > > > > > > > >> > > > database.
> > > > > > > > > > > >> > > > >> One thing might worth doing is to add
> GroupId
> > > and
> > > > > > > > > Generation
> > > > > > > > > > ID
> > > > > > > > > > > >> to
> > > > > > > > > > > >> > > > >> ProducerRequest and FetchRequest as well.
> > This
> > > > will
> > > > > > > also
> > > > > > > > > help
> > > > > > > > > > > >> with
> > > > > > > > > > > >> > the
> > > > > > > > > > > >> > > > >> single producer use case. However, this is
> > > > probably
> > > > > > > > > > orthogonal
> > > > > > > > > > > to
> > > > > > > > > > > >> > this
> > > > > > > > > > > >> > > > >> thread given the current new consumer also
> > has
> > > > this
> > > > > > > > problem
> > > > > > > > > > > and I
> > > > > > > > > > > >> > > > believe
> > > > > > > > > > > >> > > > >> we need to fix it.
> > > > > > > > > > > >> > > > >>
> > > > > > > > > > > >> > > > >> Thanks,
> > > > > > > > > > > >> > > > >>
> > > > > > > > > > > >> > > > >> Jiangjie (Becket) Qin
> > > > > > > > > > > >> > > > >>
> > > > > > > > > > > >> > > > >> On Tue, Aug 11, 2015 at 11:43 PM, Ewen
> > > > > > > Cheslack-Postava <
> > > > > > > > > > > >> > > > >> ewen@confluent.io>
> > > > > > > > > > > >> > > > >> wrote:
> > > > > > > > > > > >> > > > >>
> > > > > > > > > > > >> > > > >> > On Tue, Aug 11, 2015 at 11:29 PM,
> Jiangjie
> > > Qin
> > > > > > > > > > > >> > > > >> <jq...@linkedin.com.invalid>
> > > > > > > > > > > >> > > > >> > wrote:
> > > > > > > > > > > >> > > > >> >
> > > > > > > > > > > >> > > > >> > > Ewen,
> > > > > > > > > > > >> > > > >> > >
> > > > > > > > > > > >> > > > >> > > Thanks for the explanation.
> > > > > > > > > > > >> > > > >> > >
> > > > > > > > > > > >> > > > >> > > For (1), I am more concerned about the
> > > > failure
> > > > > > case
> > > > > > > > > > instead
> > > > > > > > > > > >> of
> > > > > > > > > > > >> > > > normal
> > > > > > > > > > > >> > > > >> > case.
> > > > > > > > > > > >> > > > >> > > What if a consumer somehow was kick out
> > of
> > > a
> > > > > > group
> > > > > > > > but
> > > > > > > > > is
> > > > > > > > > > > >> still
> > > > > > > > > > > >> > > > >> consuming
> > > > > > > > > > > >> > > > >> > > and committing offsets? Does that mean
> > the
> > > > new
> > > > > > > owner
> > > > > > > > > and
> > > > > > > > > > > old
> > > > > > > > > > > >> > owner
> > > > > > > > > > > >> > > > >> might
> > > > > > > > > > > >> > > > >> > > potentially consuming from and
> committing
> > > > > offsets
> > > > > > > for
> > > > > > > > > the
> > > > > > > > > > > >> same
> > > > > > > > > > > >> > > > >> partition?
> > > > > > > > > > > >> > > > >> > > In the old consumer, this won't happen
> > > > because
> > > > > > the
> > > > > > > > new
> > > > > > > > > > > >> consumer
> > > > > > > > > > > >> > > will
> > > > > > > > > > > >> > > > >> not
> > > > > > > > > > > >> > > > >> > be
> > > > > > > > > > > >> > > > >> > > able to start consumption unless the
> > > previous
> > > > > > owner
> > > > > > > > has
> > > > > > > > > > > >> released
> > > > > > > > > > > >> > > its
> > > > > > > > > > > >> > > > >> > > ownership. Basically, without the
> > ownership
> > > > > > > > guarantee,
> > > > > > > > > I
> > > > > > > > > > > >> don't
> > > > > > > > > > > >> > see
> > > > > > > > > > > >> > > > how
> > > > > > > > > > > >> > > > >> > the
> > > > > > > > > > > >> > > > >> > > communication among consumers
> themselves
> > > > alone
> > > > > > can
> > > > > > > > > solve
> > > > > > > > > > > the
> > > > > > > > > > > >> > > problem
> > > > > > > > > > > >> > > > >> > here.
> > > > > > > > > > > >> > > > >> > >
> > > > > > > > > > > >> > > > >> >
> > > > > > > > > > > >> > > > >> > The generation ID check still applies to
> > > offset
> > > > > > > > commits.
> > > > > > > > > If
> > > > > > > > > > > >> one of
> > > > > > > > > > > >> > > the
> > > > > > > > > > > >> > > > >> > consumers is kicked out and misbehaving,
> it
> > > can
> > > > > > > > obviously
> > > > > > > > > > > still
> > > > > > > > > > > >> > > fetch
> > > > > > > > > > > >> > > > >> and
> > > > > > > > > > > >> > > > >> > process messages, but offset commits will
> > not
> > > > > work
> > > > > > > > since
> > > > > > > > > it
> > > > > > > > > > > >> will
> > > > > > > > > > > >> > not
> > > > > > > > > > > >> > > > >> have
> > > > > > > > > > > >> > > > >> > the current generation ID.
> > > > > > > > > > > >> > > > >> >
> > > > > > > > > > > >> > > > >> >
> > > > > > > > > > > >> > > > >> > >
> > > > > > > > > > > >> > > > >> > > For (2) and (3), now I understand how
> > > > metadata
> > > > > > are
> > > > > > > > > used.
> > > > > > > > > > > But
> > > > > > > > > > > >> I
> > > > > > > > > > > >> > > still
> > > > > > > > > > > >> > > > >> > don't
> > > > > > > > > > > >> > > > >> > > see why should we let the consumers to
> > pass
> > > > the
> > > > > > > topic
> > > > > > > > > > > >> > information
> > > > > > > > > > > >> > > > >> across
> > > > > > > > > > > >> > > > >> > > instead of letting coordinator give the
> > > > > > > information.
> > > > > > > > > The
> > > > > > > > > > > >> single
> > > > > > > > > > > >> > > > >> producer
> > > > > > > > > > > >> > > > >> > > use case does not solve the ownership
> > > problem
> > > > > in
> > > > > > > > > abnormal
> > > > > > > > > > > >> case
> > > > > > > > > > > >> > > > either,
> > > > > > > > > > > >> > > > >> > > which seems to be a little bit
> > vulnerable.
> > > > > > > > > > > >> > > > >> > >
> > > > > > > > > > > >> > > > >> >
> > > > > > > > > > > >> > > > >> > One of the goals here was to generalize
> > group
> > > > > > > > membership
> > > > > > > > > so
> > > > > > > > > > > we
> > > > > > > > > > > >> > can,
> > > > > > > > > > > >> > > > for
> > > > > > > > > > > >> > > > >> > example, use it for balancing Copycat
> tasks
> > > > > across
> > > > > > > > > workers.
> > > > > > > > > > > >> > There's
> > > > > > > > > > > >> > > no
> > > > > > > > > > > >> > > > >> > topic subscription info in that case. The
> > > > > metadata
> > > > > > > for
> > > > > > > > > > > copycat
> > > > > > > > > > > >> > > workers
> > > > > > > > > > > >> > > > >> > would instead need to somehow indicate
> the
> > > > > current
> > > > > > > set
> > > > > > > > of
> > > > > > > > > > > tasks
> > > > > > > > > > > >> > that
> > > > > > > > > > > >> > > > >> need
> > > > > > > > > > > >> > > > >> > to be assigned to workers. By making the
> > > > metadata
> > > > > > > > > > completely
> > > > > > > > > > > >> > opaque
> > > > > > > > > > > >> > > to
> > > > > > > > > > > >> > > > >> the
> > > > > > > > > > > >> > > > >> > protocol, it becomes more generally
> useful
> > > > since
> > > > > it
> > > > > > > > > focuses
> > > > > > > > > > > >> > squarely
> > > > > > > > > > > >> > > > on
> > > > > > > > > > > >> > > > >> the
> > > > > > > > > > > >> > > > >> > group membership problem, allowing for
> that
> > > > > > > additional
> > > > > > > > > bit
> > > > > > > > > > of
> > > > > > > > > > > >> > > metadata
> > > > > > > > > > > >> > > > >> so
> > > > > > > > > > > >> > > > >> > you don't just get a list of members, but
> > > also
> > > > > get
> > > > > > a
> > > > > > > > > little
> > > > > > > > > > > >> bit of
> > > > > > > > > > > >> > > > info
> > > > > > > > > > > >> > > > >> > about each of them.
> > > > > > > > > > > >> > > > >> >
> > > > > > > > > > > >> > > > >> > A different option that we explored is to
> > > use a
> > > > > > sort
> > > > > > > of
> > > > > > > > > > mixed
> > > > > > > > > > > >> > model
> > > > > > > > > > > >> > > --
> > > > > > > > > > > >> > > > >> > still bake all the topic subscriptions
> > > directly
> > > > > > into
> > > > > > > > the
> > > > > > > > > > > >> protocol
> > > > > > > > > > > >> > > but
> > > > > > > > > > > >> > > > >> also
> > > > > > > > > > > >> > > > >> > include metadata. That would allow us to
> > > > maintain
> > > > > > the
> > > > > > > > > > > existing
> > > > > > > > > > > >> > > > >> > coordinator-driven approach to handling
> the
> > > > > > metadata
> > > > > > > > and
> > > > > > > > > > > change
> > > > > > > > > > > >> > > events
> > > > > > > > > > > >> > > > >> like
> > > > > > > > > > > >> > > > >> > the ones Onur pointed out. Then something
> > > like
> > > > > the
> > > > > > > > > Copycat
> > > > > > > > > > > >> workers
> > > > > > > > > > > >> > > > would
> > > > > > > > > > > >> > > > >> > just not fill in any topic subscriptions
> > and
> > > it
> > > > > > would
> > > > > > > > be
> > > > > > > > > > > >> handled
> > > > > > > > > > > >> > as
> > > > > > > > > > > >> > > a
> > > > > > > > > > > >> > > > >> > degenerate case. Based on the way I
> > explained
> > > > > that
> > > > > > we
> > > > > > > > can
> > > > > > > > > > > >> handle
> > > > > > > > > > > >> > > those
> > > > > > > > > > > >> > > > >> > types of events, I personally feel its
> > > cleaner
> > > > > and
> > > > > > a
> > > > > > > > > nicer
> > > > > > > > > > > >> > > > >> generalization
> > > > > > > > > > > >> > > > >> > to not include the subscriptions in the
> > join
> > > > > group
> > > > > > > > > > protocol,
> > > > > > > > > > > >> > making
> > > > > > > > > > > >> > > it
> > > > > > > > > > > >> > > > >> part
> > > > > > > > > > > >> > > > >> > of the metadata instead.
> > > > > > > > > > > >> > > > >> >
> > > > > > > > > > > >> > > > >> > For the single producer case, are you
> > saying
> > > it
> > > > > > > doesn't
> > > > > > > > > > solve
> > > > > > > > > > > >> > > > ownership
> > > > > > > > > > > >> > > > >> in
> > > > > > > > > > > >> > > > >> > the abnormal case because a producer that
> > > > doesn't
> > > > > > > know
> > > > > > > > it
> > > > > > > > > > has
> > > > > > > > > > > >> been
> > > > > > > > > > > >> > > > >> kicked
> > > > > > > > > > > >> > > > >> > out of the group yet can still produce
> data
> > > > even
> > > > > > > though
> > > > > > > > > it
> > > > > > > > > > > >> > shouldn't
> > > > > > > > > > > >> > > > be
> > > > > > > > > > > >> > > > >> > able to anymore? I definitely agree that
> > that
> > > > is
> > > > > a
> > > > > > > risk
> > > > > > > > > --
> > > > > > > > > > > this
> > > > > > > > > > > >> > > > >> provides a
> > > > > > > > > > > >> > > > >> > way to get closer to a true
> single-writer,
> > > but
> > > > > > there
> > > > > > > > are
> > > > > > > > > > > >> > definitely
> > > > > > > > > > > >> > > > >> still
> > > > > > > > > > > >> > > > >> > failure modes that this does not address.
> > > > > > > > > > > >> > > > >> >
> > > > > > > > > > > >> > > > >> > -Ewen
> > > > > > > > > > > >> > > > >> >
> > > > > > > > > > > >> > > > >> >
> > > > > > > > > > > >> > > > >> > >
> > > > > > > > > > > >> > > > >> > > Thanks,
> > > > > > > > > > > >> > > > >> > >
> > > > > > > > > > > >> > > > >> > > Jiangjie (Becket) Qin
> > > > > > > > > > > >> > > > >> > >
> > > > > > > > > > > >> > > > >> > >
> > > > > > > > > > > >> > > > >> > > On Tue, Aug 11, 2015 at 11:06 PM, Ewen
> > > > > > > > > Cheslack-Postava <
> > > > > > > > > > > >> > > > >> > ewen@confluent.io
> > > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > > >> > > > >> > > wrote:
> > > > > > > > > > > >> > > > >> > >
> > > > > > > > > > > >> > > > >> > > > On Tue, Aug 11, 2015 at 10:15 PM,
> > > Jiangjie
> > > > > Qin
> > > > > > > > > > > >> > > > >> > <jqin@linkedin.com.invalid
> > > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > > >> > > > >> > > > wrote:
> > > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > > >> > > > >> > > > > Hi Jason,
> > > > > > > > > > > >> > > > >> > > > >
> > > > > > > > > > > >> > > > >> > > > > Thanks for writing this up. It
> would
> > be
> > > > > > useful
> > > > > > > to
> > > > > > > > > > > >> generalize
> > > > > > > > > > > >> > > the
> > > > > > > > > > > >> > > > >> > group
> > > > > > > > > > > >> > > > >> > > > > concept. I have a few questions
> > below.
> > > > > > > > > > > >> > > > >> > > > >
> > > > > > > > > > > >> > > > >> > > > > 1. In old consumer actually the
> > > partition
> > > > > > > > > assignment
> > > > > > > > > > > are
> > > > > > > > > > > >> > done
> > > > > > > > > > > >> > > by
> > > > > > > > > > > >> > > > >> > > > consumers
> > > > > > > > > > > >> > > > >> > > > > themselves. We used zookeeper to
> > > > guarantee
> > > > > > > that a
> > > > > > > > > > > >> partition
> > > > > > > > > > > >> > > will
> > > > > > > > > > > >> > > > >> only
> > > > > > > > > > > >> > > > >> > > be
> > > > > > > > > > > >> > > > >> > > > > consumed by one consumer thread who
> > > > > > > successfully
> > > > > > > > > > > claimed
> > > > > > > > > > > >> its
> > > > > > > > > > > >> > > > >> > ownership.
> > > > > > > > > > > >> > > > >> > > > > Does the new protocol plan to
> provide
> > > the
> > > > > > same
> > > > > > > > > > > guarantee?
> > > > > > > > > > > >> > > > >> > > > >
> > > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > > >> > > > >> > > > Once you have all the metadata from
> all
> > > the
> > > > > > > > > consumers,
> > > > > > > > > > > >> > > assignment
> > > > > > > > > > > >> > > > >> > should
> > > > > > > > > > > >> > > > >> > > > just be a simple function mapping
> that
> > > > > > > > > Map<ConsumerId,
> > > > > > > > > > > >> > Metadata>
> > > > > > > > > > > >> > > > to
> > > > > > > > > > > >> > > > >> > > > Map<ConsumerId,
> List<TopicPartition>>.
> > If
> > > > > > > everyone
> > > > > > > > is
> > > > > > > > > > > >> > consistent
> > > > > > > > > > > >> > > > in
> > > > > > > > > > > >> > > > >> > > > computing that, you don't need ZK
> > > involved
> > > > at
> > > > > > > all.
> > > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > > >> > > > >> > > > In practice, this shouldn't be that
> > hard
> > > to
> > > > > > > ensure
> > > > > > > > > for
> > > > > > > > > > > most
> > > > > > > > > > > >> > > > >> assignment
> > > > > > > > > > > >> > > > >> > > > strategies just by having decent unit
> > > > testing
> > > > > > on
> > > > > > > > > them.
> > > > > > > > > > > You
> > > > > > > > > > > >> > just
> > > > > > > > > > > >> > > > >> have to
> > > > > > > > > > > >> > > > >> > > do
> > > > > > > > > > > >> > > > >> > > > things like ensure your assignment
> > > strategy
> > > > > > sorts
> > > > > > > > > lists
> > > > > > > > > > > >> into a
> > > > > > > > > > > >> > > > >> > consistent
> > > > > > > > > > > >> > > > >> > > > order.
> > > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > > >> > > > >> > > > You do give up the ability to use
> some
> > > > > > techniques
> > > > > > > > > (e.g.
> > > > > > > > > > > any
> > > > > > > > > > > >> > > > >> randomized
> > > > > > > > > > > >> > > > >> > > > algorithm if you can't distribute the
> > > seed
> > > > w/
> > > > > > the
> > > > > > > > > > > metadata)
> > > > > > > > > > > >> > and
> > > > > > > > > > > >> > > > it's
> > > > > > > > > > > >> > > > >> > true
> > > > > > > > > > > >> > > > >> > > > that nothing validates the
> assignment,
> > > but
> > > > if
> > > > > > > that
> > > > > > > > > > > >> assignment
> > > > > > > > > > > >> > > > >> algorithm
> > > > > > > > > > > >> > > > >> > > > step is kept simple, small, and well
> > > > tested,
> > > > > > the
> > > > > > > > risk
> > > > > > > > > > is
> > > > > > > > > > > >> very
> > > > > > > > > > > >> > > > >> minimal.
> > > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > > >> > > > >> > > > >
> > > > > > > > > > > >> > > > >> > > > > 2. It looks that both
> > JoinGroupRequest
> > > > and
> > > > > > > > > > > >> JoinGroupResponse
> > > > > > > > > > > >> > > has
> > > > > > > > > > > >> > > > >> the
> > > > > > > > > > > >> > > > >> > > > >
> > > > > ProtocolMetadata.AssignmentStrategyMetadata,
> > > > > > > what
> > > > > > > > > > would
> > > > > > > > > > > >> be
> > > > > > > > > > > >> > the
> > > > > > > > > > > >> > > > >> > metadata
> > > > > > > > > > > >> > > > >> > > > be
> > > > > > > > > > > >> > > > >> > > > > sent and returned by coordinator?
> How
> > > > will
> > > > > > the
> > > > > > > > > > > >> coordinator
> > > > > > > > > > > >> > > > handle
> > > > > > > > > > > >> > > > >> the
> > > > > > > > > > > >> > > > >> > > > > metadata?
> > > > > > > > > > > >> > > > >> > > > >
> > > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > > >> > > > >> > > > The coordinator is basically just
> > blindly
> > > > > > > > > broadcasting
> > > > > > > > > > > all
> > > > > > > > > > > >> of
> > > > > > > > > > > >> > it
> > > > > > > > > > > >> > > > to
> > > > > > > > > > > >> > > > >> > group
> > > > > > > > > > > >> > > > >> > > > members so they have a consistent
> view.
> > > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > > >> > > > >> > > > So from the coordinators perspective,
> > it
> > > > sees
> > > > > > > > > something
> > > > > > > > > > > >> like:
> > > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > > >> > > > >> > > > Consumer 1 -> JoinGroupRequest with
> > > > > > > GroupProtocols
> > > > > > > > =
> > > > > > > > > [
> > > > > > > > > > > >> > > "consumer"
> > > > > > > > > > > >> > > > >> > > > <Consumer1 opaque byte[]>]
> > > > > > > > > > > >> > > > >> > > > Consumer 2 -> JoinGroupRequest with
> > > > > > > GroupProtocols
> > > > > > > > =
> > > > > > > > > [
> > > > > > > > > > > >> > > "consumer"
> > > > > > > > > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > > >> > > > >> > > > Then, in the responses would look
> like:
> > > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > > >> > > > >> > > > Consumer 1 <- JoinGroupResponse with
> > > > > > > GroupProtocol
> > > > > > > > =
> > > > > > > > > > > >> > "consumer"
> > > > > > > > > > > >> > > > and
> > > > > > > > > > > >> > > > >> > > > GroupMembers = [ Consumer 1
> <Consumer1
> > > > opaque
> > > > > > > > > byte[]>,
> > > > > > > > > > > >> > Consumer
> > > > > > > > > > > >> > > 2
> > > > > > > > > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > > > > > > > > >> > > > >> > > > Consumer 2 <- JoinGroupResponse with
> > > > > > > GroupProtocol
> > > > > > > > =
> > > > > > > > > > > >> > "consumer"
> > > > > > > > > > > >> > > > and
> > > > > > > > > > > >> > > > >> > > > GroupMembers = [ Consumer 1
> <Consumer1
> > > > opaque
> > > > > > > > > byte[]>,
> > > > > > > > > > > >> > Consumer
> > > > > > > > > > > >> > > 2
> > > > > > > > > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > > >> > > > >> > > > So all the responses include all the
> > > > metadata
> > > > > > for
> > > > > > > > > every
> > > > > > > > > > > >> member
> > > > > > > > > > > >> > > in
> > > > > > > > > > > >> > > > >> the
> > > > > > > > > > > >> > > > >> > > > group, and everyone can use that to
> > > > > > consistently
> > > > > > > > > decide
> > > > > > > > > > > on
> > > > > > > > > > > >> > > > >> assignment.
> > > > > > > > > > > >> > > > >> > > The
> > > > > > > > > > > >> > > > >> > > > broker doesn't care and cannot even
> > > > > understand
> > > > > > > the
> > > > > > > > > > > metadata
> > > > > > > > > > > >> > > since
> > > > > > > > > > > >> > > > >> the
> > > > > > > > > > > >> > > > >> > > data
> > > > > > > > > > > >> > > > >> > > > format for it is dependent on the
> > > > assignment
> > > > > > > > strategy
> > > > > > > > > > > being
> > > > > > > > > > > >> > > used.
> > > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > > >> > > > >> > > > As another example that is *not* a
> > > > consumer,
> > > > > > > let's
> > > > > > > > > say
> > > > > > > > > > > you
> > > > > > > > > > > >> > just
> > > > > > > > > > > >> > > > >> want to
> > > > > > > > > > > >> > > > >> > > > have a single writer in the group
> which
> > > > > > everyone
> > > > > > > > will
> > > > > > > > > > > >> forward
> > > > > > > > > > > >> > > > >> requests
> > > > > > > > > > > >> > > > >> > > to.
> > > > > > > > > > > >> > > > >> > > > To accomplish this, you could use a
> > very
> > > > dumb
> > > > > > > > > > assignment
> > > > > > > > > > > >> > > strategy:
> > > > > > > > > > > >> > > > >> > there
> > > > > > > > > > > >> > > > >> > > is
> > > > > > > > > > > >> > > > >> > > > no metadata (empty byte[]) and all we
> > > care
> > > > > > about
> > > > > > > is
> > > > > > > > > who
> > > > > > > > > > > is
> > > > > > > > > > > >> the
> > > > > > > > > > > >> > > > first
> > > > > > > > > > > >> > > > >> > > member
> > > > > > > > > > > >> > > > >> > > > in the group (e.g. when IDs are
> sorted
> > > > > > > > > > > lexicographically).
> > > > > > > > > > > >> > That
> > > > > > > > > > > >> > > > >> member
> > > > > > > > > > > >> > > > >> > is
> > > > > > > > > > > >> > > > >> > > > selected as the writer. In that case,
> > we
> > > > > > actually
> > > > > > > > > just
> > > > > > > > > > > care
> > > > > > > > > > > >> > > about
> > > > > > > > > > > >> > > > >> the
> > > > > > > > > > > >> > > > >> > > > membership list, there's no
> additional
> > > info
> > > > > > about
> > > > > > > > > each
> > > > > > > > > > > >> member
> > > > > > > > > > > >> > > that
> > > > > > > > > > > >> > > > >> is
> > > > > > > > > > > >> > > > >> > > > required to determine who is the
> > writer.
> > > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > > >> > > > >> > > > > 3. Do you mean that the number of
> > > > > partitions
> > > > > > in
> > > > > > > > > > > >> > > > JoinGroupResponse
> > > > > > > > > > > >> > > > >> > will
> > > > > > > > > > > >> > > > >> > > be
> > > > > > > > > > > >> > > > >> > > > > the max partition number of a topic
> > > among
> > > > > all
> > > > > > > the
> > > > > > > > > > > >> reported
> > > > > > > > > > > >> > > > >> partition
> > > > > > > > > > > >> > > > >> > > > number
> > > > > > > > > > > >> > > > >> > > > > by consumers? Is there any reason
> not
> > > > just
> > > > > > let
> > > > > > > > > > > >> Coordinator
> > > > > > > > > > > >> > to
> > > > > > > > > > > >> > > > >> return
> > > > > > > > > > > >> > > > >> > > the
> > > > > > > > > > > >> > > > >> > > > > number of partitions of a topic in
> > its
> > > > > > metadata
> > > > > > > > > > cache?
> > > > > > > > > > > >> > > > >> > > > >
> > > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > > >> > > > >> > > > Nothing from the embedded protocol is
> > > > touched
> > > > > > by
> > > > > > > > the
> > > > > > > > > > > >> broker.
> > > > > > > > > > > >> > The
> > > > > > > > > > > >> > > > >> broker
> > > > > > > > > > > >> > > > >> > > > just collects opaque bytes of
> metadata,
> > > > does
> > > > > > the
> > > > > > > > > > > selection
> > > > > > > > > > > >> of
> > > > > > > > > > > >> > > the
> > > > > > > > > > > >> > > > >> > > strategy
> > > > > > > > > > > >> > > > >> > > > if multiple are supported by some
> > > > consumers,
> > > > > > and
> > > > > > > > then
> > > > > > > > > > > >> returns
> > > > > > > > > > > >> > > that
> > > > > > > > > > > >> > > > >> > opaque
> > > > > > > > > > > >> > > > >> > > > metadata for all the members back to
> > > every
> > > > > > > member.
> > > > > > > > In
> > > > > > > > > > > that
> > > > > > > > > > > >> way
> > > > > > > > > > > >> > > > they
> > > > > > > > > > > >> > > > >> all
> > > > > > > > > > > >> > > > >> > > > have a consistent view of the group.
> > For
> > > > > > regular
> > > > > > > > > > > consumers,
> > > > > > > > > > > >> > that
> > > > > > > > > > > >> > > > >> view
> > > > > > > > > > > >> > > > >> > of
> > > > > > > > > > > >> > > > >> > > > the group includes information about
> > how
> > > > many
> > > > > > > > > > partitions
> > > > > > > > > > > >> each
> > > > > > > > > > > >> > > > >> consumer
> > > > > > > > > > > >> > > > >> > > > currently thinks the topics it is
> > > > subscribed
> > > > > to
> > > > > > > > has.
> > > > > > > > > > > These
> > > > > > > > > > > >> > could
> > > > > > > > > > > >> > > > be
> > > > > > > > > > > >> > > > >> > > > inconsistent due to out of date
> > metadata
> > > > and
> > > > > it
> > > > > > > > would
> > > > > > > > > > be
> > > > > > > > > > > >> up to
> > > > > > > > > > > >> > > the
> > > > > > > > > > > >> > > > >> > > > assignment strategy on the *client*
> to
> > > > > resolve
> > > > > > > > that.
> > > > > > > > > As
> > > > > > > > > > > you
> > > > > > > > > > > >> > > point
> > > > > > > > > > > >> > > > >> out,
> > > > > > > > > > > >> > > > >> > in
> > > > > > > > > > > >> > > > >> > > > that case they could just take the
> max
> > > > value
> > > > > > that
> > > > > > > > any
> > > > > > > > > > > >> consumer
> > > > > > > > > > > >> > > > >> reported
> > > > > > > > > > > >> > > > >> > > > seeing and use that. The consumers
> that
> > > > > notice
> > > > > > > that
> > > > > > > > > > their
> > > > > > > > > > > >> > > metadata
> > > > > > > > > > > >> > > > >> had
> > > > > > > > > > > >> > > > >> > a
> > > > > > > > > > > >> > > > >> > > > smaller # of partitions should also
> > > > trigger a
> > > > > > > > > metadata
> > > > > > > > > > > >> update
> > > > > > > > > > > >> > > when
> > > > > > > > > > > >> > > > >> they
> > > > > > > > > > > >> > > > >> > > see
> > > > > > > > > > > >> > > > >> > > > someone else observing a larger # of
> > > > > > partitions.
> > > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > > >> > > > >> > > > >
> > > > > > > > > > > >> > > > >> > > > > Thanks,
> > > > > > > > > > > >> > > > >> > > > >
> > > > > > > > > > > >> > > > >> > > > > Jiangjie (Becket) Qin
> > > > > > > > > > > >> > > > >> > > > >
> > > > > > > > > > > >> > > > >> > > > >
> > > > > > > > > > > >> > > > >> > > > >
> > > > > > > > > > > >> > > > >> > > > >
> > > > > > > > > > > >> > > > >> > > > > On Tue, Aug 11, 2015 at 1:19 PM,
> > Jason
> > > > > > > Gustafson
> > > > > > > > <
> > > > > > > > > > > >> > > > >> jason@confluent.io
> > > > > > > > > > > >> > > > >> > >
> > > > > > > > > > > >> > > > >> > > > > wrote:
> > > > > > > > > > > >> > > > >> > > > >
> > > > > > > > > > > >> > > > >> > > > > > Hi Kafka Devs,
> > > > > > > > > > > >> > > > >> > > > > >
> > > > > > > > > > > >> > > > >> > > > > > One of the nagging issues in the
> > > > current
> > > > > > > design
> > > > > > > > > of
> > > > > > > > > > > the
> > > > > > > > > > > >> new
> > > > > > > > > > > >> > > > >> consumer
> > > > > > > > > > > >> > > > >> > > has
> > > > > > > > > > > >> > > > >> > > > > > been the need to support a
> variety
> > of
> > > > > > > > assignment
> > > > > > > > > > > >> > strategies.
> > > > > > > > > > > >> > > > >> We've
> > > > > > > > > > > >> > > > >> > > > > > encountered this in particular in
> > the
> > > > > > design
> > > > > > > of
> > > > > > > > > > > copycat
> > > > > > > > > > > >> > and
> > > > > > > > > > > >> > > > the
> > > > > > > > > > > >> > > > >> > > > > processing
> > > > > > > > > > > >> > > > >> > > > > > framework (KIP-28). From what I
> > > > > understand,
> > > > > > > > Samza
> > > > > > > > > > > also
> > > > > > > > > > > >> > has a
> > > > > > > > > > > >> > > > >> number
> > > > > > > > > > > >> > > > >> > > of
> > > > > > > > > > > >> > > > >> > > > > use
> > > > > > > > > > > >> > > > >> > > > > > cases with custom assignment
> needs.
> > > The
> > > > > new
> > > > > > > > > > consumer
> > > > > > > > > > > >> > > protocol
> > > > > > > > > > > >> > > > >> > > supports
> > > > > > > > > > > >> > > > >> > > > > new
> > > > > > > > > > > >> > > > >> > > > > > assignment strategies by hooking
> > them
> > > > > into
> > > > > > > the
> > > > > > > > > > > broker.
> > > > > > > > > > > >> For
> > > > > > > > > > > >> > > > many
> > > > > > > > > > > >> > > > >> > > > > > environments, this is a major
> pain
> > > and
> > > > in
> > > > > > > some
> > > > > > > > > > > cases, a
> > > > > > > > > > > >> > > > >> > non-starter.
> > > > > > > > > > > >> > > > >> > > It
> > > > > > > > > > > >> > > > >> > > > > > also challenges the validation
> that
> > > the
> > > > > > > > > coordinator
> > > > > > > > > > > can
> > > > > > > > > > > >> > > > provide.
> > > > > > > > > > > >> > > > >> > For
> > > > > > > > > > > >> > > > >> > > > > > example, some assignment
> strategies
> > > > call
> > > > > > for
> > > > > > > > > > > >> partitions to
> > > > > > > > > > > >> > > be
> > > > > > > > > > > >> > > > >> > > assigned
> > > > > > > > > > > >> > > > >> > > > > > multiple times, which means that
> > the
> > > > > > > > coordinator
> > > > > > > > > > can
> > > > > > > > > > > >> only
> > > > > > > > > > > >> > > > check
> > > > > > > > > > > >> > > > >> > that
> > > > > > > > > > > >> > > > >> > > > > > partitions have been assigned at
> > > least
> > > > > > once.
> > > > > > > > > > > >> > > > >> > > > > >
> > > > > > > > > > > >> > > > >> > > > > > To solve these issues, we'd like
> to
> > > > > propose
> > > > > > > > > moving
> > > > > > > > > > > >> > > assignment
> > > > > > > > > > > >> > > > to
> > > > > > > > > > > >> > > > >> > the
> > > > > > > > > > > >> > > > >> > > > > > client. I've written a wiki which
> > > > > outlines
> > > > > > > some
> > > > > > > > > > > >> protocol
> > > > > > > > > > > >> > > > >> changes to
> > > > > > > > > > > >> > > > >> > > > > achieve
> > > > > > > > > > > >> > > > >> > > > > > this:
> > > > > > > > > > > >> > > > >> > > > > >
> > > > > > > > > > > >> > > > >> > > > > >
> > > > > > > > > > > >> > > > >> > > > >
> > > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > > >> > > > >> > >
> > > > > > > > > > > >> > > > >> >
> > > > > > > > > > > >> > > > >>
> > > > > > > > > > > >> > > >
> > > > > > > > > > > >> > >
> > > > > > > > > > > >> >
> > > > > > > > > > > >>
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> > > > > > > > > > > >> > > > >> > > > > > .
> > > > > > > > > > > >> > > > >> > > > > > To summarize briefly, instead of
> > the
> > > > > > > > coordinator
> > > > > > > > > > > >> assigning
> > > > > > > > > > > >> > > the
> > > > > > > > > > > >> > > > >> > > > partitions
> > > > > > > > > > > >> > > > >> > > > > > itself, all subscriptions are
> > > forwarded
> > > > > to
> > > > > > > each
> > > > > > > > > > > member
> > > > > > > > > > > >> of
> > > > > > > > > > > >> > > the
> > > > > > > > > > > >> > > > >> group
> > > > > > > > > > > >> > > > >> > > > which
> > > > > > > > > > > >> > > > >> > > > > > then decides independently which
> > > > > partitions
> > > > > > > it
> > > > > > > > > > should
> > > > > > > > > > > >> > > consume.
> > > > > > > > > > > >> > > > >> The
> > > > > > > > > > > >> > > > >> > > > > protocol
> > > > > > > > > > > >> > > > >> > > > > > provides a mechanism for the
> > > > coordinator
> > > > > to
> > > > > > > > > > validate
> > > > > > > > > > > >> that
> > > > > > > > > > > >> > > all
> > > > > > > > > > > >> > > > >> > > consumers
> > > > > > > > > > > >> > > > >> > > > > use
> > > > > > > > > > > >> > > > >> > > > > > the same assignment strategy, but
> > it
> > > > does
> > > > > > not
> > > > > > > > > > ensure
> > > > > > > > > > > >> that
> > > > > > > > > > > >> > > the
> > > > > > > > > > > >> > > > >> > > resulting
> > > > > > > > > > > >> > > > >> > > > > > assignment is "correct." This
> > > provides
> > > > a
> > > > > > > > powerful
> > > > > > > > > > > >> > capability
> > > > > > > > > > > >> > > > for
> > > > > > > > > > > >> > > > >> > > users
> > > > > > > > > > > >> > > > >> > > > to
> > > > > > > > > > > >> > > > >> > > > > > control the full data flow on the
> > > > client
> > > > > > > side.
> > > > > > > > > They
> > > > > > > > > > > >> > control
> > > > > > > > > > > >> > > > how
> > > > > > > > > > > >> > > > >> > data
> > > > > > > > > > > >> > > > >> > > is
> > > > > > > > > > > >> > > > >> > > > > > written to partitions through the
> > > > > > Partitioner
> > > > > > > > > > > interface
> > > > > > > > > > > >> > and
> > > > > > > > > > > >> > > > they
> > > > > > > > > > > >> > > > >> > > > control
> > > > > > > > > > > >> > > > >> > > > > > how data is consumed through the
> > > > > assignment
> > > > > > > > > > strategy,
> > > > > > > > > > > >> all
> > > > > > > > > > > >> > > > >> without
> > > > > > > > > > > >> > > > >> > > > > touching
> > > > > > > > > > > >> > > > >> > > > > > the server.
> > > > > > > > > > > >> > > > >> > > > > >
> > > > > > > > > > > >> > > > >> > > > > > Of course nothing comes for free.
> > In
> > > > > > > > particular,
> > > > > > > > > > this
> > > > > > > > > > > >> > change
> > > > > > > > > > > >> > > > >> > removes
> > > > > > > > > > > >> > > > >> > > > the
> > > > > > > > > > > >> > > > >> > > > > > ability of the coordinator to
> > > validate
> > > > > that
> > > > > > > > > commits
> > > > > > > > > > > are
> > > > > > > > > > > >> > made
> > > > > > > > > > > >> > > > by
> > > > > > > > > > > >> > > > >> > > > consumers
> > > > > > > > > > > >> > > > >> > > > > > who were assigned the respective
> > > > > partition.
> > > > > > > > This
> > > > > > > > > > > might
> > > > > > > > > > > >> not
> > > > > > > > > > > >> > > be
> > > > > > > > > > > >> > > > >> too
> > > > > > > > > > > >> > > > >> > bad
> > > > > > > > > > > >> > > > >> > > > > since
> > > > > > > > > > > >> > > > >> > > > > > we retain the ability to validate
> > the
> > > > > > > > generation
> > > > > > > > > > id,
> > > > > > > > > > > >> but
> > > > > > > > > > > >> > it
> > > > > > > > > > > >> > > > is a
> > > > > > > > > > > >> > > > >> > > > > potential
> > > > > > > > > > > >> > > > >> > > > > > concern. We have considered
> > > alternative
> > > > > > > > protocols
> > > > > > > > > > > which
> > > > > > > > > > > >> > add
> > > > > > > > > > > >> > > a
> > > > > > > > > > > >> > > > >> > second
> > > > > > > > > > > >> > > > >> > > > > > round-trip to the protocol in
> order
> > > to
> > > > > give
> > > > > > > the
> > > > > > > > > > > >> > coordinator
> > > > > > > > > > > >> > > > the
> > > > > > > > > > > >> > > > >> > > ability
> > > > > > > > > > > >> > > > >> > > > > to
> > > > > > > > > > > >> > > > >> > > > > > confirm the assignment. As
> > mentioned
> > > > > above,
> > > > > > > the
> > > > > > > > > > > >> > coordinator
> > > > > > > > > > > >> > > is
> > > > > > > > > > > >> > > > >> > > somewhat
> > > > > > > > > > > >> > > > >> > > > > > limited in what it can actually
> > > > validate,
> > > > > > but
> > > > > > > > > this
> > > > > > > > > > > >> would
> > > > > > > > > > > >> > > > return
> > > > > > > > > > > >> > > > >> its
> > > > > > > > > > > >> > > > >> > > > > ability
> > > > > > > > > > > >> > > > >> > > > > > to validate commits. The tradeoff
> > is
> > > > that
> > > > > > it
> > > > > > > > > > > increases
> > > > > > > > > > > >> the
> > > > > > > > > > > >> > > > >> > protocol's
> > > > > > > > > > > >> > > > >> > > > > > complexity which means more ways
> > for
> > > > the
> > > > > > > > protocol
> > > > > > > > > > to
> > > > > > > > > > > >> fail
> > > > > > > > > > > >> > > and
> > > > > > > > > > > >> > > > >> > > > > consequently
> > > > > > > > > > > >> > > > >> > > > > > more edge cases in the code.
> > > > > > > > > > > >> > > > >> > > > > >
> > > > > > > > > > > >> > > > >> > > > > > It also misses an opportunity to
> > > > > generalize
> > > > > > > the
> > > > > > > > > > group
> > > > > > > > > > > >> > > > membership
> > > > > > > > > > > >> > > > >> > > > protocol
> > > > > > > > > > > >> > > > >> > > > > > for additional use cases. In
> fact,
> > > > after
> > > > > > > you've
> > > > > > > > > > gone
> > > > > > > > > > > to
> > > > > > > > > > > >> > the
> > > > > > > > > > > >> > > > >> trouble
> > > > > > > > > > > >> > > > >> > > of
> > > > > > > > > > > >> > > > >> > > > > > moving assignment to the client,
> > the
> > > > main
> > > > > > > thing
> > > > > > > > > > that
> > > > > > > > > > > is
> > > > > > > > > > > >> > left
> > > > > > > > > > > >> > > > in
> > > > > > > > > > > >> > > > >> > this
> > > > > > > > > > > >> > > > >> > > > > > protocol is basically a general
> > group
> > > > > > > > management
> > > > > > > > > > > >> > capability.
> > > > > > > > > > > >> > > > >> This
> > > > > > > > > > > >> > > > >> > is
> > > > > > > > > > > >> > > > >> > > > > > exactly what is needed for a few
> > > cases
> > > > > that
> > > > > > > are
> > > > > > > > > > > >> currently
> > > > > > > > > > > >> > > > under
> > > > > > > > > > > >> > > > >> > > > > discussion
> > > > > > > > > > > >> > > > >> > > > > > (e.g. copycat or single-writer
> > > > producer).
> > > > > > > We've
> > > > > > > > > > taken
> > > > > > > > > > > >> this
> > > > > > > > > > > >> > > > >> further
> > > > > > > > > > > >> > > > >> > > step
> > > > > > > > > > > >> > > > >> > > > > in
> > > > > > > > > > > >> > > > >> > > > > > the proposal and attempted to
> > > envision
> > > > > what
> > > > > > > > that
> > > > > > > > > > > >> general
> > > > > > > > > > > >> > > > >> protocol
> > > > > > > > > > > >> > > > >> > > might
> > > > > > > > > > > >> > > > >> > > > > > look like and how it could be
> used
> > > both
> > > > > by
> > > > > > > the
> > > > > > > > > > > consumer
> > > > > > > > > > > >> > and
> > > > > > > > > > > >> > > > for
> > > > > > > > > > > >> > > > >> > some
> > > > > > > > > > > >> > > > >> > > of
> > > > > > > > > > > >> > > > >> > > > > > these other cases.
> > > > > > > > > > > >> > > > >> > > > > >
> > > > > > > > > > > >> > > > >> > > > > > Anyway, since time is running out
> > on
> > > > the
> > > > > > new
> > > > > > > > > > > consumer,
> > > > > > > > > > > >> we
> > > > > > > > > > > >> > > have
> > > > > > > > > > > >> > > > >> > > perhaps
> > > > > > > > > > > >> > > > >> > > > > one
> > > > > > > > > > > >> > > > >> > > > > > last chance to consider a
> > significant
> > > > > > change
> > > > > > > in
> > > > > > > > > the
> > > > > > > > > > > >> > protocol
> > > > > > > > > > > >> > > > >> like
> > > > > > > > > > > >> > > > >> > > this,
> > > > > > > > > > > >> > > > >> > > > > so
> > > > > > > > > > > >> > > > >> > > > > > have a look at the wiki and share
> > > your
> > > > > > > > thoughts.
> > > > > > > > > > I've
> > > > > > > > > > > >> no
> > > > > > > > > > > >> > > doubt
> > > > > > > > > > > >> > > > >> that
> > > > > > > > > > > >> > > > >> > > > some
> > > > > > > > > > > >> > > > >> > > > > > ideas seem clearer in my mind
> than
> > > they
> > > > > do
> > > > > > on
> > > > > > > > > > paper,
> > > > > > > > > > > so
> > > > > > > > > > > >> > ask
> > > > > > > > > > > >> > > > >> > questions
> > > > > > > > > > > >> > > > >> > > > if
> > > > > > > > > > > >> > > > >> > > > > > there is any confusion.
> > > > > > > > > > > >> > > > >> > > > > >
> > > > > > > > > > > >> > > > >> > > > > > Thanks!
> > > > > > > > > > > >> > > > >> > > > > > Jason
> > > > > > > > > > > >> > > > >> > > > > >
> > > > > > > > > > > >> > > > >> > > > >
> > > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > > >> > > > >> > > > --
> > > > > > > > > > > >> > > > >> > > > Thanks,
> > > > > > > > > > > >> > > > >> > > > Ewen
> > > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > > >> > > > >> > >
> > > > > > > > > > > >> > > > >> >
> > > > > > > > > > > >> > > > >> >
> > > > > > > > > > > >> > > > >> >
> > > > > > > > > > > >> > > > >> > --
> > > > > > > > > > > >> > > > >> > Thanks,
> > > > > > > > > > > >> > > > >> > Ewen
> > > > > > > > > > > >> > > > >> >
> > > > > > > > > > > >> > > > >>
> > > > > > > > > > > >> > > > >
> > > > > > > > > > > >> > > > >
> > > > > > > > > > > >> > > >
> > > > > > > > > > > >> > >
> > > > > > > > > > > >> >
> > > > > > > > > > > >>
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > --
> > > > > > > > > > > > Thanks,
> > > > > > > > > > > > Neha
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > --
> > > > > > > > > > > Thanks,
> > > > > > > > > > > Neha
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > --
> > > > > > > > > > Thanks,
> > > > > > > > > > Ewen
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > Thanks,
> > > > > > > > Ewen
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Thanks,
> > > > > Neha
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Thanks,
> > > Neha
> > >
> >
>
>
>
> --
> Thanks,
> Ewen
>

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Ewen Cheslack-Postava <ew...@confluent.io>.
Becket,

Just to clarify, when topics are being created/resized for automated tests,
are those excluded by mirrormaker? I assume you don't want to bother with
copying them since they are just for tests. If they are excluded, then they
don't need to affect the metadata used by the consumer and so wouldn't
trigger rebalancing in the scheme proposed -- the hash being reported can
be restricted to the set of topics that will be processed by the consumer
group. Consumers should only ever need to rejoin the group if they detect a
metadata change that would affect the group's behavior.

-Ewen

On Mon, Aug 17, 2015 at 11:14 AM, Jason Gustafson <ja...@confluent.io>
wrote:

> Hey Becket,
>
> Thanks for raising these concerns. I think the rolling upgrade problem is
> handled quite a bit better with the new consumer if Onur's LeaveGroup patch
> (or a variant) is accepted. Without it, the coordinator has to wait for the
> full session timeout to detect that a node has left the group, which can
> significantly delay rebalancing.
>
> -Jason
>
> On Sun, Aug 16, 2015 at 11:42 AM, Neha Narkhede <ne...@confluent.io> wrote:
>
> > Hey Becket,
> >
> > These are all fair points. Regarding running Kafka as a service, it will
> be
> > good for everyone to know some numbers around topic creation and changes
> > around # of partitions. I don't think the test usage is a good one since
> no
> > one should be creating and deleting topics in a loop on a production
> > cluster.
> >
> > Regarding your point about mirror maker, I think we should definitely
> > ensure that a mirror maker with a large topic subscription list should be
> > well supported. The reason for the half an hour stalls in LinkedIn mirror
> > makers is due to the fact that it still uses the old consumer. The 3
> major
> > reasons for long rebalance operations in the mirror maker using the old
> > consumer are -
> > 1. Every rebalance operation involves many writes to ZK. For large
> consumer
> > groups and large number of partitions, this adds up to several seconds
> > 2. The view of the members in a group is inconsistent and hence there are
> > typically several rebalance attempts. Note that this is fixed in the new
> > design where the group membership is always consistently communicated to
> > all members.
> > 3. The rebalance backoff time is high (of the order of seconds).
> >
> > The good news is that the new design has none of these problems. As we
> > said, we will run some tests to ensure that the mirror maker case is
> > handled well. Thank you for the feedback!
> >
> > Thanks,
> > Neha
> >
> > On Sat, Aug 15, 2015 at 6:17 PM, Jiangjie Qin <jqin@linkedin.com.invalid
> >
> > wrote:
> >
> > > Neha, Ewen and Jason,
> > >
> > > Maybe I am over concerning and I agree that it does depend on the
> > metadata
> > > change frequency. As Neha said, a few tests will be helpful. We can see
> > how
> > > it goes.
> > >
> > > What worries me is that in LinkedIn we are in the progress of running
> > Kafka
> > > as a service. That means user will have the ability to create/delete
> > topics
> > > and update their topic configurations programmatically or through UI
> > using
> > > LinkedIn internal cloud service platform. And some automated test will
> > also
> > > be consistently running to create topic, produce/consume some data,
> then
> > > clean up the topics. This brings us some new challenges for mirror
> maker
> > > because we need to make sure it actually copies data instead of
> spending
> > > too much time on rebalance. As what we see now is that each rebalance
> > will
> > > probably take 30 seconds or more to finish even with some tricks and
> > > tuning.
> > >
> > > Another related use case I want to bring up is that today when we want
> to
> > > do a rolling upgrade of mirror maker (26 nodes), there will be two
> rounds
> > > of rebalance to bounce each node, each rebalance takes about 30
> seconds.
> > So
> > > bouncing 26 nodes takes roughly half an hour. Awkwardly, during the
> > rolling
> > > bounce, because mirror maker is keeping rebalancing, it actually does
> not
> > > really copy any data! So the pipeline will literally stall for half an
> > > hour! Since we are designing the new protocol, it will also be good it
> we
> > > make sure this use case is addressed.
> > >
> > > Thanks,
> > >
> > > Jiangjie (Becket) Qin
> > >
> > > On Sat, Aug 15, 2015 at 10:50 AM, Neha Narkhede <ne...@confluent.io>
> > wrote:
> > >
> > > > Becket,
> > > >
> > > > This is a clever approach for to ensure that only one thing
> > communicates
> > > > the metadata so even if it is stale, the entire group has the same
> > view.
> > > > However, the big assumption this makes is that the coordinator is
> that
> > > one
> > > > process that has the ability to know the metadata for group members,
> > > which
> > > > does not work for any non-consumer use case.
> > > >
> > > > I wonder if we may be complicating the design of 95% use cases for
> the
> > > > remaining 5%. For instance, how many times do people create and
> remove
> > > > topics or even add partitions? We operated LI clusters for a long
> time
> > > and
> > > > this wasn't a frequent event that would need us to optimize this
> design
> > > > for.
> > > >
> > > > Also, this is something we can easily validate by running a few tests
> > on
> > > > the patch and I suggest we wait for that.
> > > >
> > > > Thanks,
> > > > Neha
> > > >
> > > > On Sat, Aug 15, 2015 at 9:14 AM, Jason Gustafson <jason@confluent.io
> >
> > > > wrote:
> > > >
> > > > > Hey Jiangjie,
> > > > >
> > > > > I was thinking about the same problem. When metadata is changing
> > > > > frequently, the clients may not be able to ever find agreement on
> the
> > > > > current state. The server doesn't have this problem, as you say,
> > > because
> > > > it
> > > > > can just take a snapshot and send that to the clients. Adding a
> > > dampening
> > > > > setting to the client would help if churn is sporadic, but not if
> it
> > is
> > > > > steady. I think the metadata would have to be changing really
> > > frequently
> > > > > for this to be a problem practically, but this is a case where the
> > > > > server-side approach has an advantage.
> > > > >
> > > > > Including the metadata in the join group response would require
> > making
> > > > the
> > > > > subscription available to the coordinator, right? We lose a little
> > bit
> > > of
> > > > > the generality of the protocol, but it might not be too bad since
> > most
> > > > use
> > > > > cases for reusing this protocol have a similar need for metadata
> (and
> > > > they
> > > > > can always pass an empty subscription if they don't). We've gone
> back
> > > and
> > > > > forth a few times on this, and I'm generally not opposed. It might
> > help
> > > > if
> > > > > we try to quantify the impact of the metadata churn in practice. I
> > > think
> > > > > the rate of change would have to be in the low seconds for this to
> > be a
> > > > > real problem. It does seem nice though that we have a way to manage
> > > even
> > > > > this much churn when we do this.
> > > > >
> > > > > -Jason
> > > > >
> > > > >
> > > > >
> > > > > On Fri, Aug 14, 2015 at 9:03 PM, Jiangjie Qin
> > > <jqin@linkedin.com.invalid
> > > > >
> > > > > wrote:
> > > > >
> > > > > > Ewen,
> > > > > >
> > > > > > I agree that if there is a churn in metadata, the consumers need
> > > > several
> > > > > > rounds of rebalances to succeed. The difference I am thinking is
> > that
> > > > > with
> > > > > > coordinator as single source of truth, we can let the consumer
> > finish
> > > > one
> > > > > > round of rebalance, work for a while and start the next round of
> > > > > rebalance.
> > > > > > If we purely depend on the consumers to synchronize by themselves
> > > based
> > > > > on
> > > > > > different metadata sources, is it possible we have some groups
> > > > spending a
> > > > > > lot of time on rebalancing but not able to make too much progress
> > in
> > > > > > consuming?
> > > > > >
> > > > > > I'm thinking can we let consumers to fetch metadata only from
> their
> > > > > > coordinator? So the rebalance can be done in the following way:
> > > > > >
> > > > > > 1. Consumers refresh their metadata periodically
> > > > > > 2. If one of the consumer sees a change in metadata that
> triggers a
> > > > > > rebalance, it sends JoinGroupRequest to coordinator.
> > > > > > 3. Once the coordinator receives the first JoinGroupRequest of a
> > > group,
> > > > > it
> > > > > > takes a snapshot of current metadata and the group enters
> > > > > prepare-rebalance
> > > > > > state.
> > > > > > 4. The metadata snapshot will be used for this round of
> rebalance.
> > > i.e.
> > > > > the
> > > > > > metadata snapshot will be sent to consumers in JoinGroupResponse.
> > > > > > 4.1 If the consumers are subscribing to explicit topic lists (not
> > > > regex),
> > > > > > the JoinGroupResponse needs only contain the metadata of all
> topics
> > > the
> > > > > > group is interested.
> > > > > > 4.2 If the consumers are subscribing using regex, all the topic
> > > > metadata
> > > > > > will be returned to the consumer.
> > > > > > 5. Consumers get JoinGroupResponse, refresh metadata using the
> > > metadata
> > > > > in
> > > > > > JoinGroupResponse, run algorithm to assign partitions and start
> > > > consume.
> > > > > > 6. Go back to 1.
> > > > > >
> > > > > > The benefit here is that we can let rebalance finish in one
> round,
> > > and
> > > > > all
> > > > > > the rest of changes will be captured in next consumer metadata
> > > refresh
> > > > -
> > > > > so
> > > > > > we get group commit. One concern might be letting consumer
> refresh
> > > > > metadata
> > > > > > from coordinator might cause issue for big consumer groups. Maybe
> > > that
> > > > is
> > > > > > OK because metadata refresh is infrequent.
> > > > > >
> > > > > > This approach actually is very similar to what is proposed now:
> > > > rebalance
> > > > > > is triggered by metadata refresh, consumer provides subscription
> > list
> > > > to
> > > > > > pass around. The only difference is that we don't need metadata
> > hash
> > > > > > anymore because the metadata is guaranteed to be the same.
> > Replacing
> > > > > > metadata hash with actual metadata will not have too much
> overhead
> > > for
> > > > > > small subscription groups. There will be some overhead for regex
> > > > > > subscriptions, but this can save the potential extra round of
> > > metadata
> > > > > > fetch and will only occur when consumer see metadata change,
> which
> > is
> > > > > > infrequent.
> > > > > >
> > > > > > Any thoughts?
> > > > > >
> > > > > > Thanks,
> > > > > >
> > > > > > Jiangjie (Becket) Qin
> > > > > >
> > > > > >
> > > > > > On Fri, Aug 14, 2015 at 12:57 PM, Ewen Cheslack-Postava <
> > > > > ewen@confluent.io
> > > > > > >
> > > > > > wrote:
> > > > > >
> > > > > > > On Fri, Aug 14, 2015 at 10:59 AM, Jiangjie Qin
> > > > > <jqin@linkedin.com.invalid
> > > > > > >
> > > > > > > wrote:
> > > > > > >
> > > > > > > > Neha and Ewen,
> > > > > > > >
> > > > > > > > About the metadata change frequency. I guess it really
> depends
> > on
> > > > how
> > > > > > > > frequent the metadata change might occur. If we run Kafka as
> a
> > > > > > service, I
> > > > > > > > can see that happens from time to time. As I can imagine
> people
> > > > will
> > > > > > > create
> > > > > > > > some topic, test and maybe delete the topic in some automated
> > > test.
> > > > > If
> > > > > > > so,
> > > > > > > > the proposed protocol might be a little bit vulnerable.
> > > > > > > >
> > > > > > > > More specifically the scenario I am thinking is:
> > > > > > > > 1. Consumer 0 periodically refresh metadata and detected a
> > > metadata
> > > > > > > change.
> > > > > > > > So it sends a JoinGroupRequest with metadata_hash_0.
> > > > > > > > 2. Consumer 1 was notified by controller to start a
> rebalance,
> > so
> > > > it
> > > > > > > > refreshes its metadata and send a JoingGroupRequest with
> > > > > > metadata_hash_1,
> > > > > > > > which is different from metadata hash 0.
> > > > > > > > 3. Rebalance failed and both consumer refresh there metadata
> > > again
> > > > > from
> > > > > > > > different brokers.
> > > > > > > > 4. Depending on the metadata change frequency(or some admin
> > > > operation
> > > > > > > like
> > > > > > > > partition reassigment), they may or may not have the same
> > > metadata
> > > > > > > > returned, so the restart from 3 again.
> > > > > > > >
> > > > > > > > I agree that step 4 might not be a big concern if consumers
> > > updates
> > > > > > > > metadata at almost the same time, but I'm a little bit
> worried
> > > > > whether
> > > > > > > that
> > > > > > > > assumption really stands because we do not have control over
> > how
> > > > > > frequent
> > > > > > > > the metadata can change.
> > > > > > > >
> > > > > > > >
> > > > > > > Is this really that different from what would happen if the
> > > > coordinator
> > > > > > > distributed the metadata to consumers? In that case you would
> > > > trivially
> > > > > > > have everyone in a consistent state, but those metadata changes
> > > would
> > > > > > still
> > > > > > > cause churn and require JoinGroup rounds, during which
> processing
> > > is
> > > > > > > stalled for the nodes that are waiting on other members to
> > re-join
> > > > the
> > > > > > > group.
> > > > > > >
> > > > > > > -Ewen
> > > > > > >
> > > > > > >
> > > > > > > > Thanks,
> > > > > > > >
> > > > > > > > Jiangjie (Becket) Qin
> > > > > > > >
> > > > > > > > On Fri, Aug 14, 2015 at 2:03 AM, Ewen Cheslack-Postava <
> > > > > > > ewen@confluent.io>
> > > > > > > > wrote:
> > > > > > > >
> > > > > > > > > On Thu, Aug 13, 2015 at 11:07 PM, Neha Narkhede <
> > > > neha@confluent.io
> > > > > >
> > > > > > > > wrote:
> > > > > > > > >
> > > > > > > > > > Becket,
> > > > > > > > > >
> > > > > > > > > > As you say, the metadata hash addresses the concern you
> > > > > originally
> > > > > > > > raised
> > > > > > > > > > about large topic subscriptions. Can you please list
> other
> > > > > problems
> > > > > > > you
> > > > > > > > > are
> > > > > > > > > > raising more clearly? It is more helpful to know problems
> > > that
> > > > > the
> > > > > > > > > proposal
> > > > > > > > > > does not address or addresses poorly.
> > > > > > > > > >
> > > > > > > > > > Regarding other things you said -
> > > > > > > > > >
> > > > > > > > > > it is required that each
> > > > > > > > > > > consumer refresh their metadata before sending a
> > > > > JoinGroupRequest
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > This is required for wildcard topic subscriptions anyway.
> > So
> > > > this
> > > > > > > > > proposal
> > > > > > > > > > does not introduce a regression. We had agreed earlier
> that
> > > it
> > > > > does
> > > > > > > not
> > > > > > > > > > make sense for the server to deserialize regular
> > expressions
> > > > sent
> > > > > > by
> > > > > > > > the
> > > > > > > > > > consumer.
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > > I don't think consumers need to do a metadata refresh
> before
> > > > > sending
> > > > > > a
> > > > > > > > > JoinGroupRequest. Metadata changes that affect assignment
> are
> > > > rare
> > > > > --
> > > > > > > it
> > > > > > > > > requires changing the number of partitions in a topic. But
> > you
> > > > > might
> > > > > > > > send a
> > > > > > > > > JoinGroupRequest simply because a new member is trying to
> > join
> > > > the
> > > > > > > group.
> > > > > > > > > That case is presumably much more common.
> > > > > > > > >
> > > > > > > > > I think it's actually a good idea to have the first
> JoinGroup
> > > > cycle
> > > > > > > fail
> > > > > > > > in
> > > > > > > > > some cases, and has little impact. Lets say the metadata
> does
> > > > > change
> > > > > > > > > because partitions are added. Then we might fail in the
> first
> > > > > round,
> > > > > > > but
> > > > > > > > > then all members detect that issue *immediately*, refresh
> > their
> > > > > > > metadata,
> > > > > > > > > and submit a new join group request. This second cycle does
> > not
> > > > > > > require a
> > > > > > > > > full heartbeat cycle. It happens much more quickly because
> > > > everyone
> > > > > > > > > detected the inconsistency based on the first
> > > JoinGroupResponse.
> > > > > The
> > > > > > > > > inconsistency should be resolved very quickly (barring
> other
> > > > > failures
> > > > > > > > like
> > > > > > > > > a member leaving mid-rebalance)
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > > the metadata might still be inconsistent if there is a
> > > topic
> > > > or
> > > > > > > > > partition
> > > > > > > > > > > change because the
> > > > > > > > > > > UpdateMetadataRequest from controller might be handled
> at
> > > > > > different
> > > > > > > > > time.
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Topic metadata does not change frequently and even if it
> > > did, a
> > > > > > > couple
> > > > > > > > > > rebalance attempts will be needed whether the coordinator
> > > > drives
> > > > > > the
> > > > > > > > > > assignments or the consumer. Because guess how the
> > > coordinator
> > > > > > knows
> > > > > > > > > about
> > > > > > > > > > the topic metadata changes -- indirectly through either a
> > zk
> > > > > > callback
> > > > > > > > or
> > > > > > > > > > UpdateMetadataRequest, so it is completely possible the
> > > > > coordinator
> > > > > > > > sees
> > > > > > > > > > the topic metadata changes in batches, not all at once.
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > > > On Thu, Aug 13, 2015 at 10:50 PM, Neha Narkhede <
> > > > > neha@confluent.io
> > > > > > >
> > > > > > > > > wrote:
> > > > > > > > > >
> > > > > > > > > > > Ewen/Jason,
> > > > > > > > > > >
> > > > > > > > > > > The metadata hash is a clever approach and certainly
> > > > addresses
> > > > > > the
> > > > > > > > > > problem
> > > > > > > > > > > of large metadata for consumers like mirror maker. Few
> > > > > comments -
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >    1. In the interest of simplifying the format of the
> > > > > consumer's
> > > > > > > > > > >    metadata - Why not just always include only the
> topic
> > > > names
> > > > > in
> > > > > > > the
> > > > > > > > > > metadata
> > > > > > > > > > >    followed by the metadata hash? If the metadata hash
> > > check
> > > > > > > > succeeds,
> > > > > > > > > > each
> > > > > > > > > > >    consumer uses the # of partitions it had fetched. If
> > it
> > > > > > fails, a
> > > > > > > > > > rebalance
> > > > > > > > > > >    happens and the metadata is not used anyway.
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > > Doing this requires that every consumer always fetch the
> full
> > > > > > metadata.
> > > > > > > > The
> > > > > > > > > most common use case is consumers that just want to consume
> > one
> > > > or
> > > > > a
> > > > > > > > couple
> > > > > > > > > of topics, in which case grabbing all metadata for the
> entire
> > > > > cluster
> > > > > > > is
> > > > > > > > > wasteful. If I subscribe only to topic A, why make all
> > > consumers
> > > > > grab
> > > > > > > > > metadata for the entire topic (and need to rebalance every
> > time
> > > > it
> > > > > > > > > changes!). Including the # of partitions for each topic
> lets
> > > you
> > > > > > avoid
> > > > > > > > > having to grab the global set of metadata.
> > > > > > > > >
> > > > > > > > > So if you're just subscribing to one or a couple of topics,
> > why
> > > > not
> > > > > > > just
> > > > > > > > > compute the hash by filtering out everything but the topics
> > you
> > > > are
> > > > > > > > > subscribed to? The problem there is if you ever add/remove
> > > > > > > subscriptions
> > > > > > > > > and want to support rolling upgrades. If the group was
> > > subscribed
> > > > > to
> > > > > > > > topic
> > > > > > > > > A, but later changes require subscribing to A + B, then to
> > > > achieve
> > > > > a
> > > > > > > > > seamless rolling upgrade would require one (old) consumer
> to
> > be
> > > > > > > > subscribing
> > > > > > > > > to A and one (new) consumer to be subscribing to A+B. If we
> > > > > computed
> > > > > > > > > metadata hashes based on filtered metadata, those two would
> > > > > disagree
> > > > > > > and
> > > > > > > > we
> > > > > > > > > could not perform assignment while the upgrade was in
> > progress.
> > > > > > > > >
> > > > > > > > > The solution is to differentiate between the cases when a
> > very
> > > > > small
> > > > > > > > amount
> > > > > > > > > of the metadata is needed (one or a couple of topic
> > > > subscriptions;
> > > > > > > > > communicate and share this via metadata in the JoinGroup
> > > > protocol)
> > > > > vs
> > > > > > > > when
> > > > > > > > > *all* the metadata is needed (regex subscription; verify
> > > > agreement
> > > > > > via
> > > > > > > > > hash).
> > > > > > > > >
> > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > > >    2. Do you need a topic list and topic regex to be
> > > > separate?
> > > > > A
> > > > > > > > single
> > > > > > > > > > >    topic or list of topics can be expressed as a regex.
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > > See above note about collecting all metadata when you
> really
> > > only
> > > > > > need
> > > > > > > it
> > > > > > > > > for 1 or 2 topics. There's probably some debate to be had
> > about
> > > > > > whether
> > > > > > > > > this cost would be too high -- every consumer would need to
> > > > request
> > > > > > the
> > > > > > > > > metadata for all topics, and they'd need to request that
> all
> > > > every
> > > > > > time
> > > > > > > > > they might be out of date.
> > > > > > > > >
> > > > > > > > Are we going to allow consumers in the same group to
> subscribe
> > to
> > > > > > > different
> > > > > > > > topic set? If we do, we need to let them refresh metadata for
> > all
> > > > the
> > > > > > > > topics a group is consuming from. If we don't then in the
> > > protocol
> > > > we
> > > > > > > only
> > > > > > > > need a subscription set hash.
> > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > > >    3. Let's include a version explicitly at the
> beginning
> > > of
> > > > > the
> > > > > > > > > > >    ProtocolMetadata. The version dictates how to
> > > deserialize
> > > > > the
> > > > > > > > > > >    ProtocolMetadata blob and is consistent with the
> rest
> > of
> > > > > > Kafka.
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > > If I'm understanding correctly, in JoinGroupRequest I would
> > > > change
> > > > > > > > >
> > > > > > > > > GroupProtocols          => [Protocol ProtocolMetadata]
> > > > > > > > >
> > > > > > > > > to
> > > > > > > > >
> > > > > > > > > GroupProtocols          => [Protocol ProtocolVersion
> > > > > > ProtocolMetadata]
> > > > > > > > >
> > > > > > > > > We had been talking about just baking the version into the
> > > > Protocol
> > > > > > > > field,
> > > > > > > > > but making it separate seems perfectly reasonable to me.
> > Jason,
> > > > any
> > > > > > > issue
> > > > > > > > > with splitting the version out into a separate field like
> > this?
> > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > > That can simplify the metadata format to the following:
> > > > > > > > > > >
> > > > > > > > > > > GroupType => "consumer"
> > > > > > > > > > >>
> > > > > > > > > > >> Protocol => AssignmentStrategy
> > > > > > > > > > >>   AssignmentStrategy   => String
> > > > > > > > > > >>
> > > > > > > > > > >> ProtocolMetadata => Version Subscription
> > > > > > > AssignmentStrategyMetadata
> > > > > > > > > > >
> > > > > > > > > > >     Version                    => String
> > > > > > > > > > >
> > > > > > > > > > >   Subscription                 => TopicRegex
> MetadataHash
> > > > > > > > > > >>     TopicRegex                 => String
> > > > > > > > > > >>     MetadataHash               => String
> > > > > > > > > > >>   AssignmentStrategyMetadata   => bytes
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > On Thu, Aug 13, 2015 at 6:28 PM, Jiangjie Qin
> > > > > > > > > <jqin@linkedin.com.invalid
> > > > > > > > > > >
> > > > > > > > > > > wrote:
> > > > > > > > > > >
> > > > > > > > > > >> Ewen and Jason,
> > > > > > > > > > >>
> > > > > > > > > > >> Thanks for the reply. Sorry I missed the metadata
> hash.
> > > Yes,
> > > > > > that
> > > > > > > > is a
> > > > > > > > > > >> clever approach and would solve my concern about the
> > data
> > > > > > passing
> > > > > > > > > > around.
> > > > > > > > > > >> I
> > > > > > > > > > >> can see both pros and cons from doing this, though.
> The
> > > > > > advantage
> > > > > > > is
> > > > > > > > > we
> > > > > > > > > > >> don't need the topic metadata in JoinGroupResponse
> > > anymore.
> > > > > The
> > > > > > > > > downside
> > > > > > > > > > >> is
> > > > > > > > > > >> that now rebalance have extra dependency on the
> > consensus
> > > of
> > > > > > > > metadata
> > > > > > > > > of
> > > > > > > > > > >> all consumers, which is obtained separately. So it is
> > > > required
> > > > > > > that
> > > > > > > > > each
> > > > > > > > > > >> consumer refresh their metadata before sending a
> > > > > > JoinGroupRequest,
> > > > > > > > > > >> otherwise in some cases (e.g. wildcard consumers) will
> > > > almost
> > > > > > > > > certainly
> > > > > > > > > > >> fail for the first rebalance attempt. Even if we do
> > that,
> > > > > since
> > > > > > > the
> > > > > > > > > > >> consumers are getting metadata from different brokers,
> > the
> > > > > > > metadata
> > > > > > > > > > might
> > > > > > > > > > >> still be inconsistent if there is a topic or partition
> > > > change
> > > > > > > > because
> > > > > > > > > > the
> > > > > > > > > > >> UpdateMetadataRequest from controller might be handled
> > at
> > > > > > > different
> > > > > > > > > > time.
> > > > > > > > > > >> Just want to make sure we think through the cases so
> the
> > > > > > protocol
> > > > > > > > does
> > > > > > > > > > not
> > > > > > > > > > >> cause us unexpected issues.
> > > > > > > > > > >>
> > > > > > > > > > >> About the number of consumers, I think with the
> current
> > > > > > liveliness
> > > > > > > > > > >> definition, we can tolerate churns by bumping up the
> > > session
> > > > > > > > timeout.
> > > > > > > > > > Also
> > > > > > > > > > >> I guess we will see an increasing number of consumers
> > for
> > > > new
> > > > > > > > > consumer,
> > > > > > > > > > >> because every the old consumer thread will probably
> > > become a
> > > > > > > > consumer.
> > > > > > > > > > >>
> > > > > > > > > > >> It is a valid concern for consumers that have large
> > > > > subscription
> > > > > > > > set.
> > > > > > > > > > This
> > > > > > > > > > >> might not be avoided though for client side assignment
> > > > > approach.
> > > > > > > One
> > > > > > > > > > >> solution is having topic names associate with a topic
> > ID.
> > > > And
> > > > > > only
> > > > > > > > use
> > > > > > > > > > >> topic ID in JoinGroupRequest and JoinGroupResponse,
> > There
> > > > is a
> > > > > > > > > > discussion
> > > > > > > > > > >> thread about this to solve the topic renaming case but
> > > this
> > > > > is a
> > > > > > > > > > >> completely
> > > > > > > > > > >> different discussion.
> > > > > > > > > > >>
> > > > > > > > > > >> Thanks,
> > > > > > > > > > >>
> > > > > > > > > > >> Jiangjie (Becket) Qin
> > > > > > > > > > >>
> > > > > > > > > > >>
> > > > > > > > > > >>
> > > > > > > > > > >> On Thu, Aug 13, 2015 at 2:14 PM, Jason Gustafson <
> > > > > > > > jason@confluent.io>
> > > > > > > > > > >> wrote:
> > > > > > > > > > >>
> > > > > > > > > > >> > Thanks Jiangjie, that information helps. I agree the
> > > > > protocol
> > > > > > > must
> > > > > > > > > > >> consider
> > > > > > > > > > >> > scalability. My point was that the synchronization
> > > barrier
> > > > > in
> > > > > > > the
> > > > > > > > > > >> current
> > > > > > > > > > >> > protocol already effectively limits the number of
> > > > consumers
> > > > > > > since
> > > > > > > > it
> > > > > > > > > > >> > provides no way to gracefully handle churn. It
> > wouldn't
> > > be
> > > > > > worth
> > > > > > > > > > >> worrying
> > > > > > > > > > >> > about scaling up to 100,000 members, for example,
> > > because
> > > > > > > there's
> > > > > > > > no
> > > > > > > > > > way
> > > > > > > > > > >> > the group would be stable. So we just need to set
> some
> > > > clear
> > > > > > > > > > >> expectations
> > > > > > > > > > >> > on the size we can scale to, and that can help
> inform
> > > the
> > > > > > > > discussion
> > > > > > > > > > on
> > > > > > > > > > >> the
> > > > > > > > > > >> > size of messages in this protocol.
> > > > > > > > > > >> >
> > > > > > > > > > >> > Ewen and I were discussing this morning along
> similar
> > > > lines
> > > > > to
> > > > > > > > what
> > > > > > > > > > >> you're
> > > > > > > > > > >> > suggesting. However, even if the coordinator decides
> > on
> > > > the
> > > > > > > > metadata
> > > > > > > > > > for
> > > > > > > > > > >> > the group, each member still needs to communicate
> its
> > > > > > > > subscriptions
> > > > > > > > > to
> > > > > > > > > > >> the
> > > > > > > > > > >> > rest of the group. This is nice for the regex case
> > since
> > > > the
> > > > > > > regex
> > > > > > > > > is
> > > > > > > > > > >> > probably small, but if the members have a large
> topic
> > > > list,
> > > > > > then
> > > > > > > > we
> > > > > > > > > > have
> > > > > > > > > > >> > the same problem. One thing I was thinking about was
> > > > whether
> > > > > > we
> > > > > > > > > really
> > > > > > > > > > >> need
> > > > > > > > > > >> > to handle different subscriptions for every member.
> If
> > > the
> > > > > > > > > coordinator
> > > > > > > > > > >> > could guarantee that all members had the same
> > > > subscription,
> > > > > > then
> > > > > > > > > there
> > > > > > > > > > >> > would be no need for the coordinator to return the
> > > > > > subscriptions
> > > > > > > > for
> > > > > > > > > > >> each
> > > > > > > > > > >> > member. However, this would prevent graceful
> upgrades.
> > > We
> > > > > > might
> > > > > > > be
> > > > > > > > > > able
> > > > > > > > > > >> to
> > > > > > > > > > >> > fix that problem by allowing the consumer to provide
> > two
> > > > > > > > > subscriptions
> > > > > > > > > > >> to
> > > > > > > > > > >> > allowing rolling updates, but that starts to sound
> > > pretty
> > > > > > nasty.
> > > > > > > > > > >> >
> > > > > > > > > > >> > -Jason
> > > > > > > > > > >> >
> > > > > > > > > > >> > On Thu, Aug 13, 2015 at 1:41 PM, Jiangjie Qin
> > > > > > > > > > <jqin@linkedin.com.invalid
> > > > > > > > > > >> >
> > > > > > > > > > >> > wrote:
> > > > > > > > > > >> >
> > > > > > > > > > >> > > Jason,
> > > > > > > > > > >> > >
> > > > > > > > > > >> > > The protocol has to consider the scalability. The
> > > > protocol
> > > > > > in
> > > > > > > > the
> > > > > > > > > > wiki
> > > > > > > > > > >> > > means the JoinGroupResoponse size would be:
> > > > > > > > > > >> > > NumberOfTopics * (AvgTopicNameLength + 4) *
> > > > > > > > (NumberOfConsumers)^2
> > > > > > > > > > >> > >
> > > > > > > > > > >> > > To give some real number, we have 26-node Mirror
> > Maker
> > > > > > > cluster,
> > > > > > > > > each
> > > > > > > > > > >> > with 4
> > > > > > > > > > >> > > consumers. That is 104 consumers using regex ".*".
> > And
> > > > > most
> > > > > > of
> > > > > > > > our
> > > > > > > > > > >> > clusters
> > > > > > > > > > >> > > have around 3000 topics, whose topic name are
> > > typically
> > > > > > around
> > > > > > > > 20
> > > > > > > > > > >> > > characters.
> > > > > > > > > > >> > >
> > > > > > > > > > >> > > I think the key issue for client side partition
> > > > assignment
> > > > > > > logic
> > > > > > > > > is
> > > > > > > > > > to
> > > > > > > > > > >> > make
> > > > > > > > > > >> > > sure 1) all the clients run the same algorithm. 2)
> > all
> > > > the
> > > > > > > > clients
> > > > > > > > > > >> make
> > > > > > > > > > >> > > decision on the same topic metadata. The second
> > > purpose
> > > > > can
> > > > > > be
> > > > > > > > > done
> > > > > > > > > > by
> > > > > > > > > > >> > > simply letting coordinator provide the topic
> > metadata
> > > > and
> > > > > > all
> > > > > > > > then
> > > > > > > > > > >> member
> > > > > > > > > > >> > > information as source of truth. Is it necessary to
> > > pass
> > > > > > topic
> > > > > > > > > > >> metadata of
> > > > > > > > > > >> > > each consumer around? Can we keep the protocol
> > > metadata
> > > > > > field
> > > > > > > > > > >> completely
> > > > > > > > > > >> > > independent of topic metadata? I think In the
> > > > > > > JoinGroupResponse,
> > > > > > > > > we
> > > > > > > > > > >> > should
> > > > > > > > > > >> > > have only one copy of topic metadata provided by
> > > > > coordinator
> > > > > > > and
> > > > > > > > > is
> > > > > > > > > > >> > outside
> > > > > > > > > > >> > > of protocol metadata. If user decides to put some
> > > > metadata
> > > > > > in
> > > > > > > > the
> > > > > > > > > > >> > > JoinGroupRequest and let coordinator pass around,
> > they
> > > > are
> > > > > > > > > > responsible
> > > > > > > > > > >> > for
> > > > > > > > > > >> > > understanding the risk.
> > > > > > > > > > >> > >
> > > > > > > > > > >> > > Thanks,
> > > > > > > > > > >> > >
> > > > > > > > > > >> > > Jiangjie (Becket) Qin
> > > > > > > > > > >> > >
> > > > > > > > > > >> > >
> > > > > > > > > > >> > > On Thu, Aug 13, 2015 at 12:41 PM, Jason Gustafson
> <
> > > > > > > > > > jason@confluent.io
> > > > > > > > > > >> >
> > > > > > > > > > >> > > wrote:
> > > > > > > > > > >> > >
> > > > > > > > > > >> > > > Hey Onur and Jiangjie,
> > > > > > > > > > >> > > >
> > > > > > > > > > >> > > > I've updated that wiki with a proposal to add
> > regex
> > > > > > > > > subscriptions
> > > > > > > > > > to
> > > > > > > > > > >> > the
> > > > > > > > > > >> > > > consumer metadata. Can you have a look to see if
> > it
> > > > > > > addresses
> > > > > > > > > your
> > > > > > > > > > >> > > concern?
> > > > > > > > > > >> > > > In general, I think we should be a little
> careful
> > > when
> > > > > we
> > > > > > > are
> > > > > > > > > > >> talking
> > > > > > > > > > >> > > about
> > > > > > > > > > >> > > > the scalability of the protocol. Regardless of
> > > whether
> > > > > > > > > assignment
> > > > > > > > > > is
> > > > > > > > > > >> > done
> > > > > > > > > > >> > > > on the server or the client, the protocol
> assumes
> > a
> > > > > > > relatively
> > > > > > > > > > >> stable
> > > > > > > > > > >> > > > configuration. When the number of consumers
> > > increases
> > > > > > > beyond a
> > > > > > > > > > >> certain
> > > > > > > > > > >> > > > limit, then membership churn becomes a major
> > > concern.
> > > > > > > > Similarly
> > > > > > > > > > >> there
> > > > > > > > > > >> > is
> > > > > > > > > > >> > > a
> > > > > > > > > > >> > > > notion of metadata churn when topics are added,
> > > > deleted,
> > > > > > or
> > > > > > > > > > >> resized. If
> > > > > > > > > > >> > > > either membership or metadata changes, then the
> > > > protocol
> > > > > > > > forces
> > > > > > > > > > all
> > > > > > > > > > >> > > > consumers to stop consumption and rejoin the
> > group.
> > > If
> > > > > > this
> > > > > > > > > > happens
> > > > > > > > > > >> > often
> > > > > > > > > > >> > > > enough, then it can severely impact the ability
> of
> > > the
> > > > > > > > consumer
> > > > > > > > > to
> > > > > > > > > > >> make
> > > > > > > > > > >> > > > progress. The point is that the protocol may
> > already
> > > > be
> > > > > > > > unsuited
> > > > > > > > > > to
> > > > > > > > > > >> > cases
> > > > > > > > > > >> > > > where there are either a large number of
> consumers
> > > or
> > > > > > > topics.
> > > > > > > > I
> > > > > > > > > > >> wonder
> > > > > > > > > > >> > if
> > > > > > > > > > >> > > > you guys can share your thoughts about your
> > scaling
> > > > > > > > > expectations?
> > > > > > > > > > >> > > >
> > > > > > > > > > >> > > > -Jason
> > > > > > > > > > >> > > >
> > > > > > > > > > >> > > >
> > > > > > > > > > >> > > >
> > > > > > > > > > >> > > >
> > > > > > > > > > >> > > > On Wed, Aug 12, 2015 at 12:28 PM, Jason
> Gustafson
> > <
> > > > > > > > > > >> jason@confluent.io>
> > > > > > > > > > >> > > > wrote:
> > > > > > > > > > >> > > >
> > > > > > > > > > >> > > > > Hey Jiangjie,
> > > > > > > > > > >> > > > >
> > > > > > > > > > >> > > > > That's a great point. In the worst case (the
> > > mirror
> > > > > > maker
> > > > > > > > > case I
> > > > > > > > > > >> > > guess),
> > > > > > > > > > >> > > > > the join group response can be massive. This
> > would
> > > > be
> > > > > > > > > especially
> > > > > > > > > > >> > deadly
> > > > > > > > > > >> > > > > when there is a lot of churn in the group
> (e.g.
> > > in a
> > > > > > > rolling
> > > > > > > > > > >> > upgrade).
> > > > > > > > > > >> > > > The
> > > > > > > > > > >> > > > > current protocol is not great for this case
> > > either,
> > > > > but
> > > > > > > it's
> > > > > > > > > > >> > > > significantly
> > > > > > > > > > >> > > > > better. Here are a couple ways to deal with
> the
> > > > size:
> > > > > > > > > > >> > > > >
> > > > > > > > > > >> > > > > 1. First, we could have the coordinator
> compress
> > > the
> > > > > > > > > responses.
> > > > > > > > > > >> This
> > > > > > > > > > >> > > > would
> > > > > > > > > > >> > > > > probably be pretty effective if applied across
> > the
> > > > > > > metadata
> > > > > > > > > from
> > > > > > > > > > >> all
> > > > > > > > > > >> > > > > members.
> > > > > > > > > > >> > > > >
> > > > > > > > > > >> > > > > 2. I think the regex case is the main problem.
> > Is
> > > > that
> > > > > > > > right?
> > > > > > > > > We
> > > > > > > > > > >> > could
> > > > > > > > > > >> > > > > extend the metadata to allow the consumer to
> > embed
> > > > its
> > > > > > > regex
> > > > > > > > > > >> > > subscription
> > > > > > > > > > >> > > > > in the metadata directly (note this might be a
> > > good
> > > > > idea
> > > > > > > > > > >> regardless
> > > > > > > > > > >> > of
> > > > > > > > > > >> > > > the
> > > > > > > > > > >> > > > > rest of this proposal). To support regex on
> the
> > > > > > consumer,
> > > > > > > we
> > > > > > > > > > must
> > > > > > > > > > >> > fetch
> > > > > > > > > > >> > > > > metadata for all topics. Rather than having
> all
> > > > regex
> > > > > > > > > > subscribers
> > > > > > > > > > >> > embed
> > > > > > > > > > >> > > > all
> > > > > > > > > > >> > > > > of this metadata in their join group requests,
> > > they
> > > > > > could
> > > > > > > > > > instead
> > > > > > > > > > >> > > embed a
> > > > > > > > > > >> > > > > hash of it. Then after the join group
> responses
> > > are
> > > > > > > > received,
> > > > > > > > > > they
> > > > > > > > > > >> > just
> > > > > > > > > > >> > > > > need to check that the hashes are the same. If
> > > there
> > > > > is
> > > > > > a
> > > > > > > > > > mismatch
> > > > > > > > > > >> > > (which
> > > > > > > > > > >> > > > > should only occur when topics are created,
> > > deleted,
> > > > or
> > > > > > > > > resized),
> > > > > > > > > > >> then
> > > > > > > > > > >> > > the
> > > > > > > > > > >> > > > > group members must refetch the metadata and
> > rejoin
> > > > the
> > > > > > > > group.
> > > > > > > > > > >> This is
> > > > > > > > > > >> > > > also
> > > > > > > > > > >> > > > > how the current protocol behaves when there
> is a
> > > > > change
> > > > > > in
> > > > > > > > the
> > > > > > > > > > >> topic
> > > > > > > > > > >> > > > > metadata affecting the group--someone (either
> > the
> > > > > > > > coordinator
> > > > > > > > > or
> > > > > > > > > > >> the
> > > > > > > > > > >> > > > > consumer) detects the change and forces the
> > group
> > > to
> > > > > > > > > rebalance.
> > > > > > > > > > >> > > > >
> > > > > > > > > > >> > > > > What do you think?
> > > > > > > > > > >> > > > >
> > > > > > > > > > >> > > > > (Also I think adding groupId/generationId to
> > fetch
> > > > and
> > > > > > > > produce
> > > > > > > > > > >> > requests
> > > > > > > > > > >> > > > > seems like an interesting line of thought.)
> > > > > > > > > > >> > > > >
> > > > > > > > > > >> > > > > -Jason
> > > > > > > > > > >> > > > >
> > > > > > > > > > >> > > > >
> > > > > > > > > > >> > > > >
> > > > > > > > > > >> > > > > On Wed, Aug 12, 2015 at 10:57 AM, Jiangjie Qin
> > > > > > > > > > >> > > <jqin@linkedin.com.invalid
> > > > > > > > > > >> > > > >
> > > > > > > > > > >> > > > > wrote:
> > > > > > > > > > >> > > > >
> > > > > > > > > > >> > > > >> Hey Ewen,
> > > > > > > > > > >> > > > >>
> > > > > > > > > > >> > > > >> Onur and I discussed this a little bit more.
> > And
> > > we
> > > > > are
> > > > > > > > still
> > > > > > > > > > >> > worrying
> > > > > > > > > > >> > > > >> about passing all the metadata of all
> consumers
> > > > > around.
> > > > > > > > > > >> > > > >>
> > > > > > > > > > >> > > > >> Let's say I have a cluster has 10,000 topics,
> > the
> > > > > > average
> > > > > > > > > topic
> > > > > > > > > > >> name
> > > > > > > > > > >> > > > >> length
> > > > > > > > > > >> > > > >> is 10 bytes. In this case, the opaque
> metadata
> > > will
> > > > > > have
> > > > > > > > 10 *
> > > > > > > > > > >> > 10,000 =
> > > > > > > > > > >> > > > >> 100KB for topic name, for each topic, there
> is
> > a
> > > > > 4-byte
> > > > > > > > > integer
> > > > > > > > > > >> of
> > > > > > > > > > >> > > > number
> > > > > > > > > > >> > > > >> of partitions, that's another 40KB. So one
> > global
> > > > > topic
> > > > > > > > > > metadata
> > > > > > > > > > >> > will
> > > > > > > > > > >> > > > have
> > > > > > > > > > >> > > > >> 140KB data. If I have 100 consumers who are
> > using
> > > > > > > wildcard
> > > > > > > > to
> > > > > > > > > > >> > consume
> > > > > > > > > > >> > > > from
> > > > > > > > > > >> > > > >> all the topics. That means the protocol
> > metadata
> > > > end
> > > > > up
> > > > > > > in
> > > > > > > > > the
> > > > > > > > > > >> > > > >> JoinGroupResponse will be 140KB * 100 = 14MB.
> > And
> > > > the
> > > > > > > > > > >> > > JoinGroupResponse
> > > > > > > > > > >> > > > >> will need to be sent to 100 different
> > consumers,
> > > > that
> > > > > > > means
> > > > > > > > > > 14MB
> > > > > > > > > > >> *
> > > > > > > > > > >> > > 100 =
> > > > > > > > > > >> > > > >> 1.4GB need to be sent by the consumer
> > coordinator
> > > > for
> > > > > > one
> > > > > > > > > > >> rebalance.
> > > > > > > > > > >> > > How
> > > > > > > > > > >> > > > >> would that work?
> > > > > > > > > > >> > > > >>
> > > > > > > > > > >> > > > >> Also, having two consumers (old owner and new
> > > > owner)
> > > > > > > > > consuming
> > > > > > > > > > >> from
> > > > > > > > > > >> > > the
> > > > > > > > > > >> > > > >> same partition might also be a problem. e.g.
> > > people
> > > > > are
> > > > > > > > > > updating
> > > > > > > > > > >> > > > database.
> > > > > > > > > > >> > > > >> One thing might worth doing is to add GroupId
> > and
> > > > > > > > Generation
> > > > > > > > > ID
> > > > > > > > > > >> to
> > > > > > > > > > >> > > > >> ProducerRequest and FetchRequest as well.
> This
> > > will
> > > > > > also
> > > > > > > > help
> > > > > > > > > > >> with
> > > > > > > > > > >> > the
> > > > > > > > > > >> > > > >> single producer use case. However, this is
> > > probably
> > > > > > > > > orthogonal
> > > > > > > > > > to
> > > > > > > > > > >> > this
> > > > > > > > > > >> > > > >> thread given the current new consumer also
> has
> > > this
> > > > > > > problem
> > > > > > > > > > and I
> > > > > > > > > > >> > > > believe
> > > > > > > > > > >> > > > >> we need to fix it.
> > > > > > > > > > >> > > > >>
> > > > > > > > > > >> > > > >> Thanks,
> > > > > > > > > > >> > > > >>
> > > > > > > > > > >> > > > >> Jiangjie (Becket) Qin
> > > > > > > > > > >> > > > >>
> > > > > > > > > > >> > > > >> On Tue, Aug 11, 2015 at 11:43 PM, Ewen
> > > > > > Cheslack-Postava <
> > > > > > > > > > >> > > > >> ewen@confluent.io>
> > > > > > > > > > >> > > > >> wrote:
> > > > > > > > > > >> > > > >>
> > > > > > > > > > >> > > > >> > On Tue, Aug 11, 2015 at 11:29 PM, Jiangjie
> > Qin
> > > > > > > > > > >> > > > >> <jq...@linkedin.com.invalid>
> > > > > > > > > > >> > > > >> > wrote:
> > > > > > > > > > >> > > > >> >
> > > > > > > > > > >> > > > >> > > Ewen,
> > > > > > > > > > >> > > > >> > >
> > > > > > > > > > >> > > > >> > > Thanks for the explanation.
> > > > > > > > > > >> > > > >> > >
> > > > > > > > > > >> > > > >> > > For (1), I am more concerned about the
> > > failure
> > > > > case
> > > > > > > > > instead
> > > > > > > > > > >> of
> > > > > > > > > > >> > > > normal
> > > > > > > > > > >> > > > >> > case.
> > > > > > > > > > >> > > > >> > > What if a consumer somehow was kick out
> of
> > a
> > > > > group
> > > > > > > but
> > > > > > > > is
> > > > > > > > > > >> still
> > > > > > > > > > >> > > > >> consuming
> > > > > > > > > > >> > > > >> > > and committing offsets? Does that mean
> the
> > > new
> > > > > > owner
> > > > > > > > and
> > > > > > > > > > old
> > > > > > > > > > >> > owner
> > > > > > > > > > >> > > > >> might
> > > > > > > > > > >> > > > >> > > potentially consuming from and committing
> > > > offsets
> > > > > > for
> > > > > > > > the
> > > > > > > > > > >> same
> > > > > > > > > > >> > > > >> partition?
> > > > > > > > > > >> > > > >> > > In the old consumer, this won't happen
> > > because
> > > > > the
> > > > > > > new
> > > > > > > > > > >> consumer
> > > > > > > > > > >> > > will
> > > > > > > > > > >> > > > >> not
> > > > > > > > > > >> > > > >> > be
> > > > > > > > > > >> > > > >> > > able to start consumption unless the
> > previous
> > > > > owner
> > > > > > > has
> > > > > > > > > > >> released
> > > > > > > > > > >> > > its
> > > > > > > > > > >> > > > >> > > ownership. Basically, without the
> ownership
> > > > > > > guarantee,
> > > > > > > > I
> > > > > > > > > > >> don't
> > > > > > > > > > >> > see
> > > > > > > > > > >> > > > how
> > > > > > > > > > >> > > > >> > the
> > > > > > > > > > >> > > > >> > > communication among consumers themselves
> > > alone
> > > > > can
> > > > > > > > solve
> > > > > > > > > > the
> > > > > > > > > > >> > > problem
> > > > > > > > > > >> > > > >> > here.
> > > > > > > > > > >> > > > >> > >
> > > > > > > > > > >> > > > >> >
> > > > > > > > > > >> > > > >> > The generation ID check still applies to
> > offset
> > > > > > > commits.
> > > > > > > > If
> > > > > > > > > > >> one of
> > > > > > > > > > >> > > the
> > > > > > > > > > >> > > > >> > consumers is kicked out and misbehaving, it
> > can
> > > > > > > obviously
> > > > > > > > > > still
> > > > > > > > > > >> > > fetch
> > > > > > > > > > >> > > > >> and
> > > > > > > > > > >> > > > >> > process messages, but offset commits will
> not
> > > > work
> > > > > > > since
> > > > > > > > it
> > > > > > > > > > >> will
> > > > > > > > > > >> > not
> > > > > > > > > > >> > > > >> have
> > > > > > > > > > >> > > > >> > the current generation ID.
> > > > > > > > > > >> > > > >> >
> > > > > > > > > > >> > > > >> >
> > > > > > > > > > >> > > > >> > >
> > > > > > > > > > >> > > > >> > > For (2) and (3), now I understand how
> > > metadata
> > > > > are
> > > > > > > > used.
> > > > > > > > > > But
> > > > > > > > > > >> I
> > > > > > > > > > >> > > still
> > > > > > > > > > >> > > > >> > don't
> > > > > > > > > > >> > > > >> > > see why should we let the consumers to
> pass
> > > the
> > > > > > topic
> > > > > > > > > > >> > information
> > > > > > > > > > >> > > > >> across
> > > > > > > > > > >> > > > >> > > instead of letting coordinator give the
> > > > > > information.
> > > > > > > > The
> > > > > > > > > > >> single
> > > > > > > > > > >> > > > >> producer
> > > > > > > > > > >> > > > >> > > use case does not solve the ownership
> > problem
> > > > in
> > > > > > > > abnormal
> > > > > > > > > > >> case
> > > > > > > > > > >> > > > either,
> > > > > > > > > > >> > > > >> > > which seems to be a little bit
> vulnerable.
> > > > > > > > > > >> > > > >> > >
> > > > > > > > > > >> > > > >> >
> > > > > > > > > > >> > > > >> > One of the goals here was to generalize
> group
> > > > > > > membership
> > > > > > > > so
> > > > > > > > > > we
> > > > > > > > > > >> > can,
> > > > > > > > > > >> > > > for
> > > > > > > > > > >> > > > >> > example, use it for balancing Copycat tasks
> > > > across
> > > > > > > > workers.
> > > > > > > > > > >> > There's
> > > > > > > > > > >> > > no
> > > > > > > > > > >> > > > >> > topic subscription info in that case. The
> > > > metadata
> > > > > > for
> > > > > > > > > > copycat
> > > > > > > > > > >> > > workers
> > > > > > > > > > >> > > > >> > would instead need to somehow indicate the
> > > > current
> > > > > > set
> > > > > > > of
> > > > > > > > > > tasks
> > > > > > > > > > >> > that
> > > > > > > > > > >> > > > >> need
> > > > > > > > > > >> > > > >> > to be assigned to workers. By making the
> > > metadata
> > > > > > > > > completely
> > > > > > > > > > >> > opaque
> > > > > > > > > > >> > > to
> > > > > > > > > > >> > > > >> the
> > > > > > > > > > >> > > > >> > protocol, it becomes more generally useful
> > > since
> > > > it
> > > > > > > > focuses
> > > > > > > > > > >> > squarely
> > > > > > > > > > >> > > > on
> > > > > > > > > > >> > > > >> the
> > > > > > > > > > >> > > > >> > group membership problem, allowing for that
> > > > > > additional
> > > > > > > > bit
> > > > > > > > > of
> > > > > > > > > > >> > > metadata
> > > > > > > > > > >> > > > >> so
> > > > > > > > > > >> > > > >> > you don't just get a list of members, but
> > also
> > > > get
> > > > > a
> > > > > > > > little
> > > > > > > > > > >> bit of
> > > > > > > > > > >> > > > info
> > > > > > > > > > >> > > > >> > about each of them.
> > > > > > > > > > >> > > > >> >
> > > > > > > > > > >> > > > >> > A different option that we explored is to
> > use a
> > > > > sort
> > > > > > of
> > > > > > > > > mixed
> > > > > > > > > > >> > model
> > > > > > > > > > >> > > --
> > > > > > > > > > >> > > > >> > still bake all the topic subscriptions
> > directly
> > > > > into
> > > > > > > the
> > > > > > > > > > >> protocol
> > > > > > > > > > >> > > but
> > > > > > > > > > >> > > > >> also
> > > > > > > > > > >> > > > >> > include metadata. That would allow us to
> > > maintain
> > > > > the
> > > > > > > > > > existing
> > > > > > > > > > >> > > > >> > coordinator-driven approach to handling the
> > > > > metadata
> > > > > > > and
> > > > > > > > > > change
> > > > > > > > > > >> > > events
> > > > > > > > > > >> > > > >> like
> > > > > > > > > > >> > > > >> > the ones Onur pointed out. Then something
> > like
> > > > the
> > > > > > > > Copycat
> > > > > > > > > > >> workers
> > > > > > > > > > >> > > > would
> > > > > > > > > > >> > > > >> > just not fill in any topic subscriptions
> and
> > it
> > > > > would
> > > > > > > be
> > > > > > > > > > >> handled
> > > > > > > > > > >> > as
> > > > > > > > > > >> > > a
> > > > > > > > > > >> > > > >> > degenerate case. Based on the way I
> explained
> > > > that
> > > > > we
> > > > > > > can
> > > > > > > > > > >> handle
> > > > > > > > > > >> > > those
> > > > > > > > > > >> > > > >> > types of events, I personally feel its
> > cleaner
> > > > and
> > > > > a
> > > > > > > > nicer
> > > > > > > > > > >> > > > >> generalization
> > > > > > > > > > >> > > > >> > to not include the subscriptions in the
> join
> > > > group
> > > > > > > > > protocol,
> > > > > > > > > > >> > making
> > > > > > > > > > >> > > it
> > > > > > > > > > >> > > > >> part
> > > > > > > > > > >> > > > >> > of the metadata instead.
> > > > > > > > > > >> > > > >> >
> > > > > > > > > > >> > > > >> > For the single producer case, are you
> saying
> > it
> > > > > > doesn't
> > > > > > > > > solve
> > > > > > > > > > >> > > > ownership
> > > > > > > > > > >> > > > >> in
> > > > > > > > > > >> > > > >> > the abnormal case because a producer that
> > > doesn't
> > > > > > know
> > > > > > > it
> > > > > > > > > has
> > > > > > > > > > >> been
> > > > > > > > > > >> > > > >> kicked
> > > > > > > > > > >> > > > >> > out of the group yet can still produce data
> > > even
> > > > > > though
> > > > > > > > it
> > > > > > > > > > >> > shouldn't
> > > > > > > > > > >> > > > be
> > > > > > > > > > >> > > > >> > able to anymore? I definitely agree that
> that
> > > is
> > > > a
> > > > > > risk
> > > > > > > > --
> > > > > > > > > > this
> > > > > > > > > > >> > > > >> provides a
> > > > > > > > > > >> > > > >> > way to get closer to a true single-writer,
> > but
> > > > > there
> > > > > > > are
> > > > > > > > > > >> > definitely
> > > > > > > > > > >> > > > >> still
> > > > > > > > > > >> > > > >> > failure modes that this does not address.
> > > > > > > > > > >> > > > >> >
> > > > > > > > > > >> > > > >> > -Ewen
> > > > > > > > > > >> > > > >> >
> > > > > > > > > > >> > > > >> >
> > > > > > > > > > >> > > > >> > >
> > > > > > > > > > >> > > > >> > > Thanks,
> > > > > > > > > > >> > > > >> > >
> > > > > > > > > > >> > > > >> > > Jiangjie (Becket) Qin
> > > > > > > > > > >> > > > >> > >
> > > > > > > > > > >> > > > >> > >
> > > > > > > > > > >> > > > >> > > On Tue, Aug 11, 2015 at 11:06 PM, Ewen
> > > > > > > > Cheslack-Postava <
> > > > > > > > > > >> > > > >> > ewen@confluent.io
> > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > >> > > > >> > > wrote:
> > > > > > > > > > >> > > > >> > >
> > > > > > > > > > >> > > > >> > > > On Tue, Aug 11, 2015 at 10:15 PM,
> > Jiangjie
> > > > Qin
> > > > > > > > > > >> > > > >> > <jqin@linkedin.com.invalid
> > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > >> > > > >> > > > wrote:
> > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > >> > > > >> > > > > Hi Jason,
> > > > > > > > > > >> > > > >> > > > >
> > > > > > > > > > >> > > > >> > > > > Thanks for writing this up. It would
> be
> > > > > useful
> > > > > > to
> > > > > > > > > > >> generalize
> > > > > > > > > > >> > > the
> > > > > > > > > > >> > > > >> > group
> > > > > > > > > > >> > > > >> > > > > concept. I have a few questions
> below.
> > > > > > > > > > >> > > > >> > > > >
> > > > > > > > > > >> > > > >> > > > > 1. In old consumer actually the
> > partition
> > > > > > > > assignment
> > > > > > > > > > are
> > > > > > > > > > >> > done
> > > > > > > > > > >> > > by
> > > > > > > > > > >> > > > >> > > > consumers
> > > > > > > > > > >> > > > >> > > > > themselves. We used zookeeper to
> > > guarantee
> > > > > > that a
> > > > > > > > > > >> partition
> > > > > > > > > > >> > > will
> > > > > > > > > > >> > > > >> only
> > > > > > > > > > >> > > > >> > > be
> > > > > > > > > > >> > > > >> > > > > consumed by one consumer thread who
> > > > > > successfully
> > > > > > > > > > claimed
> > > > > > > > > > >> its
> > > > > > > > > > >> > > > >> > ownership.
> > > > > > > > > > >> > > > >> > > > > Does the new protocol plan to provide
> > the
> > > > > same
> > > > > > > > > > guarantee?
> > > > > > > > > > >> > > > >> > > > >
> > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > >> > > > >> > > > Once you have all the metadata from all
> > the
> > > > > > > > consumers,
> > > > > > > > > > >> > > assignment
> > > > > > > > > > >> > > > >> > should
> > > > > > > > > > >> > > > >> > > > just be a simple function mapping that
> > > > > > > > Map<ConsumerId,
> > > > > > > > > > >> > Metadata>
> > > > > > > > > > >> > > > to
> > > > > > > > > > >> > > > >> > > > Map<ConsumerId, List<TopicPartition>>.
> If
> > > > > > everyone
> > > > > > > is
> > > > > > > > > > >> > consistent
> > > > > > > > > > >> > > > in
> > > > > > > > > > >> > > > >> > > > computing that, you don't need ZK
> > involved
> > > at
> > > > > > all.
> > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > >> > > > >> > > > In practice, this shouldn't be that
> hard
> > to
> > > > > > ensure
> > > > > > > > for
> > > > > > > > > > most
> > > > > > > > > > >> > > > >> assignment
> > > > > > > > > > >> > > > >> > > > strategies just by having decent unit
> > > testing
> > > > > on
> > > > > > > > them.
> > > > > > > > > > You
> > > > > > > > > > >> > just
> > > > > > > > > > >> > > > >> have to
> > > > > > > > > > >> > > > >> > > do
> > > > > > > > > > >> > > > >> > > > things like ensure your assignment
> > strategy
> > > > > sorts
> > > > > > > > lists
> > > > > > > > > > >> into a
> > > > > > > > > > >> > > > >> > consistent
> > > > > > > > > > >> > > > >> > > > order.
> > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > >> > > > >> > > > You do give up the ability to use some
> > > > > techniques
> > > > > > > > (e.g.
> > > > > > > > > > any
> > > > > > > > > > >> > > > >> randomized
> > > > > > > > > > >> > > > >> > > > algorithm if you can't distribute the
> > seed
> > > w/
> > > > > the
> > > > > > > > > > metadata)
> > > > > > > > > > >> > and
> > > > > > > > > > >> > > > it's
> > > > > > > > > > >> > > > >> > true
> > > > > > > > > > >> > > > >> > > > that nothing validates the assignment,
> > but
> > > if
> > > > > > that
> > > > > > > > > > >> assignment
> > > > > > > > > > >> > > > >> algorithm
> > > > > > > > > > >> > > > >> > > > step is kept simple, small, and well
> > > tested,
> > > > > the
> > > > > > > risk
> > > > > > > > > is
> > > > > > > > > > >> very
> > > > > > > > > > >> > > > >> minimal.
> > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > >> > > > >> > > > >
> > > > > > > > > > >> > > > >> > > > > 2. It looks that both
> JoinGroupRequest
> > > and
> > > > > > > > > > >> JoinGroupResponse
> > > > > > > > > > >> > > has
> > > > > > > > > > >> > > > >> the
> > > > > > > > > > >> > > > >> > > > >
> > > > ProtocolMetadata.AssignmentStrategyMetadata,
> > > > > > what
> > > > > > > > > would
> > > > > > > > > > >> be
> > > > > > > > > > >> > the
> > > > > > > > > > >> > > > >> > metadata
> > > > > > > > > > >> > > > >> > > > be
> > > > > > > > > > >> > > > >> > > > > sent and returned by coordinator? How
> > > will
> > > > > the
> > > > > > > > > > >> coordinator
> > > > > > > > > > >> > > > handle
> > > > > > > > > > >> > > > >> the
> > > > > > > > > > >> > > > >> > > > > metadata?
> > > > > > > > > > >> > > > >> > > > >
> > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > >> > > > >> > > > The coordinator is basically just
> blindly
> > > > > > > > broadcasting
> > > > > > > > > > all
> > > > > > > > > > >> of
> > > > > > > > > > >> > it
> > > > > > > > > > >> > > > to
> > > > > > > > > > >> > > > >> > group
> > > > > > > > > > >> > > > >> > > > members so they have a consistent view.
> > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > >> > > > >> > > > So from the coordinators perspective,
> it
> > > sees
> > > > > > > > something
> > > > > > > > > > >> like:
> > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > >> > > > >> > > > Consumer 1 -> JoinGroupRequest with
> > > > > > GroupProtocols
> > > > > > > =
> > > > > > > > [
> > > > > > > > > > >> > > "consumer"
> > > > > > > > > > >> > > > >> > > > <Consumer1 opaque byte[]>]
> > > > > > > > > > >> > > > >> > > > Consumer 2 -> JoinGroupRequest with
> > > > > > GroupProtocols
> > > > > > > =
> > > > > > > > [
> > > > > > > > > > >> > > "consumer"
> > > > > > > > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > >> > > > >> > > > Then, in the responses would look like:
> > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > >> > > > >> > > > Consumer 1 <- JoinGroupResponse with
> > > > > > GroupProtocol
> > > > > > > =
> > > > > > > > > > >> > "consumer"
> > > > > > > > > > >> > > > and
> > > > > > > > > > >> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1
> > > opaque
> > > > > > > > byte[]>,
> > > > > > > > > > >> > Consumer
> > > > > > > > > > >> > > 2
> > > > > > > > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > > > > > > > >> > > > >> > > > Consumer 2 <- JoinGroupResponse with
> > > > > > GroupProtocol
> > > > > > > =
> > > > > > > > > > >> > "consumer"
> > > > > > > > > > >> > > > and
> > > > > > > > > > >> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1
> > > opaque
> > > > > > > > byte[]>,
> > > > > > > > > > >> > Consumer
> > > > > > > > > > >> > > 2
> > > > > > > > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > >> > > > >> > > > So all the responses include all the
> > > metadata
> > > > > for
> > > > > > > > every
> > > > > > > > > > >> member
> > > > > > > > > > >> > > in
> > > > > > > > > > >> > > > >> the
> > > > > > > > > > >> > > > >> > > > group, and everyone can use that to
> > > > > consistently
> > > > > > > > decide
> > > > > > > > > > on
> > > > > > > > > > >> > > > >> assignment.
> > > > > > > > > > >> > > > >> > > The
> > > > > > > > > > >> > > > >> > > > broker doesn't care and cannot even
> > > > understand
> > > > > > the
> > > > > > > > > > metadata
> > > > > > > > > > >> > > since
> > > > > > > > > > >> > > > >> the
> > > > > > > > > > >> > > > >> > > data
> > > > > > > > > > >> > > > >> > > > format for it is dependent on the
> > > assignment
> > > > > > > strategy
> > > > > > > > > > being
> > > > > > > > > > >> > > used.
> > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > >> > > > >> > > > As another example that is *not* a
> > > consumer,
> > > > > > let's
> > > > > > > > say
> > > > > > > > > > you
> > > > > > > > > > >> > just
> > > > > > > > > > >> > > > >> want to
> > > > > > > > > > >> > > > >> > > > have a single writer in the group which
> > > > > everyone
> > > > > > > will
> > > > > > > > > > >> forward
> > > > > > > > > > >> > > > >> requests
> > > > > > > > > > >> > > > >> > > to.
> > > > > > > > > > >> > > > >> > > > To accomplish this, you could use a
> very
> > > dumb
> > > > > > > > > assignment
> > > > > > > > > > >> > > strategy:
> > > > > > > > > > >> > > > >> > there
> > > > > > > > > > >> > > > >> > > is
> > > > > > > > > > >> > > > >> > > > no metadata (empty byte[]) and all we
> > care
> > > > > about
> > > > > > is
> > > > > > > > who
> > > > > > > > > > is
> > > > > > > > > > >> the
> > > > > > > > > > >> > > > first
> > > > > > > > > > >> > > > >> > > member
> > > > > > > > > > >> > > > >> > > > in the group (e.g. when IDs are sorted
> > > > > > > > > > lexicographically).
> > > > > > > > > > >> > That
> > > > > > > > > > >> > > > >> member
> > > > > > > > > > >> > > > >> > is
> > > > > > > > > > >> > > > >> > > > selected as the writer. In that case,
> we
> > > > > actually
> > > > > > > > just
> > > > > > > > > > care
> > > > > > > > > > >> > > about
> > > > > > > > > > >> > > > >> the
> > > > > > > > > > >> > > > >> > > > membership list, there's no additional
> > info
> > > > > about
> > > > > > > > each
> > > > > > > > > > >> member
> > > > > > > > > > >> > > that
> > > > > > > > > > >> > > > >> is
> > > > > > > > > > >> > > > >> > > > required to determine who is the
> writer.
> > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > >> > > > >> > > > > 3. Do you mean that the number of
> > > > partitions
> > > > > in
> > > > > > > > > > >> > > > JoinGroupResponse
> > > > > > > > > > >> > > > >> > will
> > > > > > > > > > >> > > > >> > > be
> > > > > > > > > > >> > > > >> > > > > the max partition number of a topic
> > among
> > > > all
> > > > > > the
> > > > > > > > > > >> reported
> > > > > > > > > > >> > > > >> partition
> > > > > > > > > > >> > > > >> > > > number
> > > > > > > > > > >> > > > >> > > > > by consumers? Is there any reason not
> > > just
> > > > > let
> > > > > > > > > > >> Coordinator
> > > > > > > > > > >> > to
> > > > > > > > > > >> > > > >> return
> > > > > > > > > > >> > > > >> > > the
> > > > > > > > > > >> > > > >> > > > > number of partitions of a topic in
> its
> > > > > metadata
> > > > > > > > > cache?
> > > > > > > > > > >> > > > >> > > > >
> > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > >> > > > >> > > > Nothing from the embedded protocol is
> > > touched
> > > > > by
> > > > > > > the
> > > > > > > > > > >> broker.
> > > > > > > > > > >> > The
> > > > > > > > > > >> > > > >> broker
> > > > > > > > > > >> > > > >> > > > just collects opaque bytes of metadata,
> > > does
> > > > > the
> > > > > > > > > > selection
> > > > > > > > > > >> of
> > > > > > > > > > >> > > the
> > > > > > > > > > >> > > > >> > > strategy
> > > > > > > > > > >> > > > >> > > > if multiple are supported by some
> > > consumers,
> > > > > and
> > > > > > > then
> > > > > > > > > > >> returns
> > > > > > > > > > >> > > that
> > > > > > > > > > >> > > > >> > opaque
> > > > > > > > > > >> > > > >> > > > metadata for all the members back to
> > every
> > > > > > member.
> > > > > > > In
> > > > > > > > > > that
> > > > > > > > > > >> way
> > > > > > > > > > >> > > > they
> > > > > > > > > > >> > > > >> all
> > > > > > > > > > >> > > > >> > > > have a consistent view of the group.
> For
> > > > > regular
> > > > > > > > > > consumers,
> > > > > > > > > > >> > that
> > > > > > > > > > >> > > > >> view
> > > > > > > > > > >> > > > >> > of
> > > > > > > > > > >> > > > >> > > > the group includes information about
> how
> > > many
> > > > > > > > > partitions
> > > > > > > > > > >> each
> > > > > > > > > > >> > > > >> consumer
> > > > > > > > > > >> > > > >> > > > currently thinks the topics it is
> > > subscribed
> > > > to
> > > > > > > has.
> > > > > > > > > > These
> > > > > > > > > > >> > could
> > > > > > > > > > >> > > > be
> > > > > > > > > > >> > > > >> > > > inconsistent due to out of date
> metadata
> > > and
> > > > it
> > > > > > > would
> > > > > > > > > be
> > > > > > > > > > >> up to
> > > > > > > > > > >> > > the
> > > > > > > > > > >> > > > >> > > > assignment strategy on the *client* to
> > > > resolve
> > > > > > > that.
> > > > > > > > As
> > > > > > > > > > you
> > > > > > > > > > >> > > point
> > > > > > > > > > >> > > > >> out,
> > > > > > > > > > >> > > > >> > in
> > > > > > > > > > >> > > > >> > > > that case they could just take the max
> > > value
> > > > > that
> > > > > > > any
> > > > > > > > > > >> consumer
> > > > > > > > > > >> > > > >> reported
> > > > > > > > > > >> > > > >> > > > seeing and use that. The consumers that
> > > > notice
> > > > > > that
> > > > > > > > > their
> > > > > > > > > > >> > > metadata
> > > > > > > > > > >> > > > >> had
> > > > > > > > > > >> > > > >> > a
> > > > > > > > > > >> > > > >> > > > smaller # of partitions should also
> > > trigger a
> > > > > > > > metadata
> > > > > > > > > > >> update
> > > > > > > > > > >> > > when
> > > > > > > > > > >> > > > >> they
> > > > > > > > > > >> > > > >> > > see
> > > > > > > > > > >> > > > >> > > > someone else observing a larger # of
> > > > > partitions.
> > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > >> > > > >> > > > >
> > > > > > > > > > >> > > > >> > > > > Thanks,
> > > > > > > > > > >> > > > >> > > > >
> > > > > > > > > > >> > > > >> > > > > Jiangjie (Becket) Qin
> > > > > > > > > > >> > > > >> > > > >
> > > > > > > > > > >> > > > >> > > > >
> > > > > > > > > > >> > > > >> > > > >
> > > > > > > > > > >> > > > >> > > > >
> > > > > > > > > > >> > > > >> > > > > On Tue, Aug 11, 2015 at 1:19 PM,
> Jason
> > > > > > Gustafson
> > > > > > > <
> > > > > > > > > > >> > > > >> jason@confluent.io
> > > > > > > > > > >> > > > >> > >
> > > > > > > > > > >> > > > >> > > > > wrote:
> > > > > > > > > > >> > > > >> > > > >
> > > > > > > > > > >> > > > >> > > > > > Hi Kafka Devs,
> > > > > > > > > > >> > > > >> > > > > >
> > > > > > > > > > >> > > > >> > > > > > One of the nagging issues in the
> > > current
> > > > > > design
> > > > > > > > of
> > > > > > > > > > the
> > > > > > > > > > >> new
> > > > > > > > > > >> > > > >> consumer
> > > > > > > > > > >> > > > >> > > has
> > > > > > > > > > >> > > > >> > > > > > been the need to support a variety
> of
> > > > > > > assignment
> > > > > > > > > > >> > strategies.
> > > > > > > > > > >> > > > >> We've
> > > > > > > > > > >> > > > >> > > > > > encountered this in particular in
> the
> > > > > design
> > > > > > of
> > > > > > > > > > copycat
> > > > > > > > > > >> > and
> > > > > > > > > > >> > > > the
> > > > > > > > > > >> > > > >> > > > > processing
> > > > > > > > > > >> > > > >> > > > > > framework (KIP-28). From what I
> > > > understand,
> > > > > > > Samza
> > > > > > > > > > also
> > > > > > > > > > >> > has a
> > > > > > > > > > >> > > > >> number
> > > > > > > > > > >> > > > >> > > of
> > > > > > > > > > >> > > > >> > > > > use
> > > > > > > > > > >> > > > >> > > > > > cases with custom assignment needs.
> > The
> > > > new
> > > > > > > > > consumer
> > > > > > > > > > >> > > protocol
> > > > > > > > > > >> > > > >> > > supports
> > > > > > > > > > >> > > > >> > > > > new
> > > > > > > > > > >> > > > >> > > > > > assignment strategies by hooking
> them
> > > > into
> > > > > > the
> > > > > > > > > > broker.
> > > > > > > > > > >> For
> > > > > > > > > > >> > > > many
> > > > > > > > > > >> > > > >> > > > > > environments, this is a major pain
> > and
> > > in
> > > > > > some
> > > > > > > > > > cases, a
> > > > > > > > > > >> > > > >> > non-starter.
> > > > > > > > > > >> > > > >> > > It
> > > > > > > > > > >> > > > >> > > > > > also challenges the validation that
> > the
> > > > > > > > coordinator
> > > > > > > > > > can
> > > > > > > > > > >> > > > provide.
> > > > > > > > > > >> > > > >> > For
> > > > > > > > > > >> > > > >> > > > > > example, some assignment strategies
> > > call
> > > > > for
> > > > > > > > > > >> partitions to
> > > > > > > > > > >> > > be
> > > > > > > > > > >> > > > >> > > assigned
> > > > > > > > > > >> > > > >> > > > > > multiple times, which means that
> the
> > > > > > > coordinator
> > > > > > > > > can
> > > > > > > > > > >> only
> > > > > > > > > > >> > > > check
> > > > > > > > > > >> > > > >> > that
> > > > > > > > > > >> > > > >> > > > > > partitions have been assigned at
> > least
> > > > > once.
> > > > > > > > > > >> > > > >> > > > > >
> > > > > > > > > > >> > > > >> > > > > > To solve these issues, we'd like to
> > > > propose
> > > > > > > > moving
> > > > > > > > > > >> > > assignment
> > > > > > > > > > >> > > > to
> > > > > > > > > > >> > > > >> > the
> > > > > > > > > > >> > > > >> > > > > > client. I've written a wiki which
> > > > outlines
> > > > > > some
> > > > > > > > > > >> protocol
> > > > > > > > > > >> > > > >> changes to
> > > > > > > > > > >> > > > >> > > > > achieve
> > > > > > > > > > >> > > > >> > > > > > this:
> > > > > > > > > > >> > > > >> > > > > >
> > > > > > > > > > >> > > > >> > > > > >
> > > > > > > > > > >> > > > >> > > > >
> > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > >> > > > >> > >
> > > > > > > > > > >> > > > >> >
> > > > > > > > > > >> > > > >>
> > > > > > > > > > >> > > >
> > > > > > > > > > >> > >
> > > > > > > > > > >> >
> > > > > > > > > > >>
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> > > > > > > > > > >> > > > >> > > > > > .
> > > > > > > > > > >> > > > >> > > > > > To summarize briefly, instead of
> the
> > > > > > > coordinator
> > > > > > > > > > >> assigning
> > > > > > > > > > >> > > the
> > > > > > > > > > >> > > > >> > > > partitions
> > > > > > > > > > >> > > > >> > > > > > itself, all subscriptions are
> > forwarded
> > > > to
> > > > > > each
> > > > > > > > > > member
> > > > > > > > > > >> of
> > > > > > > > > > >> > > the
> > > > > > > > > > >> > > > >> group
> > > > > > > > > > >> > > > >> > > > which
> > > > > > > > > > >> > > > >> > > > > > then decides independently which
> > > > partitions
> > > > > > it
> > > > > > > > > should
> > > > > > > > > > >> > > consume.
> > > > > > > > > > >> > > > >> The
> > > > > > > > > > >> > > > >> > > > > protocol
> > > > > > > > > > >> > > > >> > > > > > provides a mechanism for the
> > > coordinator
> > > > to
> > > > > > > > > validate
> > > > > > > > > > >> that
> > > > > > > > > > >> > > all
> > > > > > > > > > >> > > > >> > > consumers
> > > > > > > > > > >> > > > >> > > > > use
> > > > > > > > > > >> > > > >> > > > > > the same assignment strategy, but
> it
> > > does
> > > > > not
> > > > > > > > > ensure
> > > > > > > > > > >> that
> > > > > > > > > > >> > > the
> > > > > > > > > > >> > > > >> > > resulting
> > > > > > > > > > >> > > > >> > > > > > assignment is "correct." This
> > provides
> > > a
> > > > > > > powerful
> > > > > > > > > > >> > capability
> > > > > > > > > > >> > > > for
> > > > > > > > > > >> > > > >> > > users
> > > > > > > > > > >> > > > >> > > > to
> > > > > > > > > > >> > > > >> > > > > > control the full data flow on the
> > > client
> > > > > > side.
> > > > > > > > They
> > > > > > > > > > >> > control
> > > > > > > > > > >> > > > how
> > > > > > > > > > >> > > > >> > data
> > > > > > > > > > >> > > > >> > > is
> > > > > > > > > > >> > > > >> > > > > > written to partitions through the
> > > > > Partitioner
> > > > > > > > > > interface
> > > > > > > > > > >> > and
> > > > > > > > > > >> > > > they
> > > > > > > > > > >> > > > >> > > > control
> > > > > > > > > > >> > > > >> > > > > > how data is consumed through the
> > > > assignment
> > > > > > > > > strategy,
> > > > > > > > > > >> all
> > > > > > > > > > >> > > > >> without
> > > > > > > > > > >> > > > >> > > > > touching
> > > > > > > > > > >> > > > >> > > > > > the server.
> > > > > > > > > > >> > > > >> > > > > >
> > > > > > > > > > >> > > > >> > > > > > Of course nothing comes for free.
> In
> > > > > > > particular,
> > > > > > > > > this
> > > > > > > > > > >> > change
> > > > > > > > > > >> > > > >> > removes
> > > > > > > > > > >> > > > >> > > > the
> > > > > > > > > > >> > > > >> > > > > > ability of the coordinator to
> > validate
> > > > that
> > > > > > > > commits
> > > > > > > > > > are
> > > > > > > > > > >> > made
> > > > > > > > > > >> > > > by
> > > > > > > > > > >> > > > >> > > > consumers
> > > > > > > > > > >> > > > >> > > > > > who were assigned the respective
> > > > partition.
> > > > > > > This
> > > > > > > > > > might
> > > > > > > > > > >> not
> > > > > > > > > > >> > > be
> > > > > > > > > > >> > > > >> too
> > > > > > > > > > >> > > > >> > bad
> > > > > > > > > > >> > > > >> > > > > since
> > > > > > > > > > >> > > > >> > > > > > we retain the ability to validate
> the
> > > > > > > generation
> > > > > > > > > id,
> > > > > > > > > > >> but
> > > > > > > > > > >> > it
> > > > > > > > > > >> > > > is a
> > > > > > > > > > >> > > > >> > > > > potential
> > > > > > > > > > >> > > > >> > > > > > concern. We have considered
> > alternative
> > > > > > > protocols
> > > > > > > > > > which
> > > > > > > > > > >> > add
> > > > > > > > > > >> > > a
> > > > > > > > > > >> > > > >> > second
> > > > > > > > > > >> > > > >> > > > > > round-trip to the protocol in order
> > to
> > > > give
> > > > > > the
> > > > > > > > > > >> > coordinator
> > > > > > > > > > >> > > > the
> > > > > > > > > > >> > > > >> > > ability
> > > > > > > > > > >> > > > >> > > > > to
> > > > > > > > > > >> > > > >> > > > > > confirm the assignment. As
> mentioned
> > > > above,
> > > > > > the
> > > > > > > > > > >> > coordinator
> > > > > > > > > > >> > > is
> > > > > > > > > > >> > > > >> > > somewhat
> > > > > > > > > > >> > > > >> > > > > > limited in what it can actually
> > > validate,
> > > > > but
> > > > > > > > this
> > > > > > > > > > >> would
> > > > > > > > > > >> > > > return
> > > > > > > > > > >> > > > >> its
> > > > > > > > > > >> > > > >> > > > > ability
> > > > > > > > > > >> > > > >> > > > > > to validate commits. The tradeoff
> is
> > > that
> > > > > it
> > > > > > > > > > increases
> > > > > > > > > > >> the
> > > > > > > > > > >> > > > >> > protocol's
> > > > > > > > > > >> > > > >> > > > > > complexity which means more ways
> for
> > > the
> > > > > > > protocol
> > > > > > > > > to
> > > > > > > > > > >> fail
> > > > > > > > > > >> > > and
> > > > > > > > > > >> > > > >> > > > > consequently
> > > > > > > > > > >> > > > >> > > > > > more edge cases in the code.
> > > > > > > > > > >> > > > >> > > > > >
> > > > > > > > > > >> > > > >> > > > > > It also misses an opportunity to
> > > > generalize
> > > > > > the
> > > > > > > > > group
> > > > > > > > > > >> > > > membership
> > > > > > > > > > >> > > > >> > > > protocol
> > > > > > > > > > >> > > > >> > > > > > for additional use cases. In fact,
> > > after
> > > > > > you've
> > > > > > > > > gone
> > > > > > > > > > to
> > > > > > > > > > >> > the
> > > > > > > > > > >> > > > >> trouble
> > > > > > > > > > >> > > > >> > > of
> > > > > > > > > > >> > > > >> > > > > > moving assignment to the client,
> the
> > > main
> > > > > > thing
> > > > > > > > > that
> > > > > > > > > > is
> > > > > > > > > > >> > left
> > > > > > > > > > >> > > > in
> > > > > > > > > > >> > > > >> > this
> > > > > > > > > > >> > > > >> > > > > > protocol is basically a general
> group
> > > > > > > management
> > > > > > > > > > >> > capability.
> > > > > > > > > > >> > > > >> This
> > > > > > > > > > >> > > > >> > is
> > > > > > > > > > >> > > > >> > > > > > exactly what is needed for a few
> > cases
> > > > that
> > > > > > are
> > > > > > > > > > >> currently
> > > > > > > > > > >> > > > under
> > > > > > > > > > >> > > > >> > > > > discussion
> > > > > > > > > > >> > > > >> > > > > > (e.g. copycat or single-writer
> > > producer).
> > > > > > We've
> > > > > > > > > taken
> > > > > > > > > > >> this
> > > > > > > > > > >> > > > >> further
> > > > > > > > > > >> > > > >> > > step
> > > > > > > > > > >> > > > >> > > > > in
> > > > > > > > > > >> > > > >> > > > > > the proposal and attempted to
> > envision
> > > > what
> > > > > > > that
> > > > > > > > > > >> general
> > > > > > > > > > >> > > > >> protocol
> > > > > > > > > > >> > > > >> > > might
> > > > > > > > > > >> > > > >> > > > > > look like and how it could be used
> > both
> > > > by
> > > > > > the
> > > > > > > > > > consumer
> > > > > > > > > > >> > and
> > > > > > > > > > >> > > > for
> > > > > > > > > > >> > > > >> > some
> > > > > > > > > > >> > > > >> > > of
> > > > > > > > > > >> > > > >> > > > > > these other cases.
> > > > > > > > > > >> > > > >> > > > > >
> > > > > > > > > > >> > > > >> > > > > > Anyway, since time is running out
> on
> > > the
> > > > > new
> > > > > > > > > > consumer,
> > > > > > > > > > >> we
> > > > > > > > > > >> > > have
> > > > > > > > > > >> > > > >> > > perhaps
> > > > > > > > > > >> > > > >> > > > > one
> > > > > > > > > > >> > > > >> > > > > > last chance to consider a
> significant
> > > > > change
> > > > > > in
> > > > > > > > the
> > > > > > > > > > >> > protocol
> > > > > > > > > > >> > > > >> like
> > > > > > > > > > >> > > > >> > > this,
> > > > > > > > > > >> > > > >> > > > > so
> > > > > > > > > > >> > > > >> > > > > > have a look at the wiki and share
> > your
> > > > > > > thoughts.
> > > > > > > > > I've
> > > > > > > > > > >> no
> > > > > > > > > > >> > > doubt
> > > > > > > > > > >> > > > >> that
> > > > > > > > > > >> > > > >> > > > some
> > > > > > > > > > >> > > > >> > > > > > ideas seem clearer in my mind than
> > they
> > > > do
> > > > > on
> > > > > > > > > paper,
> > > > > > > > > > so
> > > > > > > > > > >> > ask
> > > > > > > > > > >> > > > >> > questions
> > > > > > > > > > >> > > > >> > > > if
> > > > > > > > > > >> > > > >> > > > > > there is any confusion.
> > > > > > > > > > >> > > > >> > > > > >
> > > > > > > > > > >> > > > >> > > > > > Thanks!
> > > > > > > > > > >> > > > >> > > > > > Jason
> > > > > > > > > > >> > > > >> > > > > >
> > > > > > > > > > >> > > > >> > > > >
> > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > >> > > > >> > > > --
> > > > > > > > > > >> > > > >> > > > Thanks,
> > > > > > > > > > >> > > > >> > > > Ewen
> > > > > > > > > > >> > > > >> > > >
> > > > > > > > > > >> > > > >> > >
> > > > > > > > > > >> > > > >> >
> > > > > > > > > > >> > > > >> >
> > > > > > > > > > >> > > > >> >
> > > > > > > > > > >> > > > >> > --
> > > > > > > > > > >> > > > >> > Thanks,
> > > > > > > > > > >> > > > >> > Ewen
> > > > > > > > > > >> > > > >> >
> > > > > > > > > > >> > > > >>
> > > > > > > > > > >> > > > >
> > > > > > > > > > >> > > > >
> > > > > > > > > > >> > > >
> > > > > > > > > > >> > >
> > > > > > > > > > >> >
> > > > > > > > > > >>
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > --
> > > > > > > > > > > Thanks,
> > > > > > > > > > > Neha
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > --
> > > > > > > > > > Thanks,
> > > > > > > > > > Neha
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > > Thanks,
> > > > > > > > > Ewen
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Thanks,
> > > > > > > Ewen
> > > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Thanks,
> > > > Neha
> > > >
> > >
> >
> >
> >
> > --
> > Thanks,
> > Neha
> >
>



-- 
Thanks,
Ewen

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Jason Gustafson <ja...@confluent.io>.
Hey Becket,

Thanks for raising these concerns. I think the rolling upgrade problem is
handled quite a bit better with the new consumer if Onur's LeaveGroup patch
(or a variant) is accepted. Without it, the coordinator has to wait for the
full session timeout to detect that a node has left the group, which can
significantly delay rebalancing.

-Jason

On Sun, Aug 16, 2015 at 11:42 AM, Neha Narkhede <ne...@confluent.io> wrote:

> Hey Becket,
>
> These are all fair points. Regarding running Kafka as a service, it will be
> good for everyone to know some numbers around topic creation and changes
> around # of partitions. I don't think the test usage is a good one since no
> one should be creating and deleting topics in a loop on a production
> cluster.
>
> Regarding your point about mirror maker, I think we should definitely
> ensure that a mirror maker with a large topic subscription list should be
> well supported. The reason for the half an hour stalls in LinkedIn mirror
> makers is due to the fact that it still uses the old consumer. The 3 major
> reasons for long rebalance operations in the mirror maker using the old
> consumer are -
> 1. Every rebalance operation involves many writes to ZK. For large consumer
> groups and large number of partitions, this adds up to several seconds
> 2. The view of the members in a group is inconsistent and hence there are
> typically several rebalance attempts. Note that this is fixed in the new
> design where the group membership is always consistently communicated to
> all members.
> 3. The rebalance backoff time is high (of the order of seconds).
>
> The good news is that the new design has none of these problems. As we
> said, we will run some tests to ensure that the mirror maker case is
> handled well. Thank you for the feedback!
>
> Thanks,
> Neha
>
> On Sat, Aug 15, 2015 at 6:17 PM, Jiangjie Qin <jq...@linkedin.com.invalid>
> wrote:
>
> > Neha, Ewen and Jason,
> >
> > Maybe I am over concerning and I agree that it does depend on the
> metadata
> > change frequency. As Neha said, a few tests will be helpful. We can see
> how
> > it goes.
> >
> > What worries me is that in LinkedIn we are in the progress of running
> Kafka
> > as a service. That means user will have the ability to create/delete
> topics
> > and update their topic configurations programmatically or through UI
> using
> > LinkedIn internal cloud service platform. And some automated test will
> also
> > be consistently running to create topic, produce/consume some data, then
> > clean up the topics. This brings us some new challenges for mirror maker
> > because we need to make sure it actually copies data instead of spending
> > too much time on rebalance. As what we see now is that each rebalance
> will
> > probably take 30 seconds or more to finish even with some tricks and
> > tuning.
> >
> > Another related use case I want to bring up is that today when we want to
> > do a rolling upgrade of mirror maker (26 nodes), there will be two rounds
> > of rebalance to bounce each node, each rebalance takes about 30 seconds.
> So
> > bouncing 26 nodes takes roughly half an hour. Awkwardly, during the
> rolling
> > bounce, because mirror maker is keeping rebalancing, it actually does not
> > really copy any data! So the pipeline will literally stall for half an
> > hour! Since we are designing the new protocol, it will also be good it we
> > make sure this use case is addressed.
> >
> > Thanks,
> >
> > Jiangjie (Becket) Qin
> >
> > On Sat, Aug 15, 2015 at 10:50 AM, Neha Narkhede <ne...@confluent.io>
> wrote:
> >
> > > Becket,
> > >
> > > This is a clever approach for to ensure that only one thing
> communicates
> > > the metadata so even if it is stale, the entire group has the same
> view.
> > > However, the big assumption this makes is that the coordinator is that
> > one
> > > process that has the ability to know the metadata for group members,
> > which
> > > does not work for any non-consumer use case.
> > >
> > > I wonder if we may be complicating the design of 95% use cases for the
> > > remaining 5%. For instance, how many times do people create and remove
> > > topics or even add partitions? We operated LI clusters for a long time
> > and
> > > this wasn't a frequent event that would need us to optimize this design
> > > for.
> > >
> > > Also, this is something we can easily validate by running a few tests
> on
> > > the patch and I suggest we wait for that.
> > >
> > > Thanks,
> > > Neha
> > >
> > > On Sat, Aug 15, 2015 at 9:14 AM, Jason Gustafson <ja...@confluent.io>
> > > wrote:
> > >
> > > > Hey Jiangjie,
> > > >
> > > > I was thinking about the same problem. When metadata is changing
> > > > frequently, the clients may not be able to ever find agreement on the
> > > > current state. The server doesn't have this problem, as you say,
> > because
> > > it
> > > > can just take a snapshot and send that to the clients. Adding a
> > dampening
> > > > setting to the client would help if churn is sporadic, but not if it
> is
> > > > steady. I think the metadata would have to be changing really
> > frequently
> > > > for this to be a problem practically, but this is a case where the
> > > > server-side approach has an advantage.
> > > >
> > > > Including the metadata in the join group response would require
> making
> > > the
> > > > subscription available to the coordinator, right? We lose a little
> bit
> > of
> > > > the generality of the protocol, but it might not be too bad since
> most
> > > use
> > > > cases for reusing this protocol have a similar need for metadata (and
> > > they
> > > > can always pass an empty subscription if they don't). We've gone back
> > and
> > > > forth a few times on this, and I'm generally not opposed. It might
> help
> > > if
> > > > we try to quantify the impact of the metadata churn in practice. I
> > think
> > > > the rate of change would have to be in the low seconds for this to
> be a
> > > > real problem. It does seem nice though that we have a way to manage
> > even
> > > > this much churn when we do this.
> > > >
> > > > -Jason
> > > >
> > > >
> > > >
> > > > On Fri, Aug 14, 2015 at 9:03 PM, Jiangjie Qin
> > <jqin@linkedin.com.invalid
> > > >
> > > > wrote:
> > > >
> > > > > Ewen,
> > > > >
> > > > > I agree that if there is a churn in metadata, the consumers need
> > > several
> > > > > rounds of rebalances to succeed. The difference I am thinking is
> that
> > > > with
> > > > > coordinator as single source of truth, we can let the consumer
> finish
> > > one
> > > > > round of rebalance, work for a while and start the next round of
> > > > rebalance.
> > > > > If we purely depend on the consumers to synchronize by themselves
> > based
> > > > on
> > > > > different metadata sources, is it possible we have some groups
> > > spending a
> > > > > lot of time on rebalancing but not able to make too much progress
> in
> > > > > consuming?
> > > > >
> > > > > I'm thinking can we let consumers to fetch metadata only from their
> > > > > coordinator? So the rebalance can be done in the following way:
> > > > >
> > > > > 1. Consumers refresh their metadata periodically
> > > > > 2. If one of the consumer sees a change in metadata that triggers a
> > > > > rebalance, it sends JoinGroupRequest to coordinator.
> > > > > 3. Once the coordinator receives the first JoinGroupRequest of a
> > group,
> > > > it
> > > > > takes a snapshot of current metadata and the group enters
> > > > prepare-rebalance
> > > > > state.
> > > > > 4. The metadata snapshot will be used for this round of rebalance.
> > i.e.
> > > > the
> > > > > metadata snapshot will be sent to consumers in JoinGroupResponse.
> > > > > 4.1 If the consumers are subscribing to explicit topic lists (not
> > > regex),
> > > > > the JoinGroupResponse needs only contain the metadata of all topics
> > the
> > > > > group is interested.
> > > > > 4.2 If the consumers are subscribing using regex, all the topic
> > > metadata
> > > > > will be returned to the consumer.
> > > > > 5. Consumers get JoinGroupResponse, refresh metadata using the
> > metadata
> > > > in
> > > > > JoinGroupResponse, run algorithm to assign partitions and start
> > > consume.
> > > > > 6. Go back to 1.
> > > > >
> > > > > The benefit here is that we can let rebalance finish in one round,
> > and
> > > > all
> > > > > the rest of changes will be captured in next consumer metadata
> > refresh
> > > -
> > > > so
> > > > > we get group commit. One concern might be letting consumer refresh
> > > > metadata
> > > > > from coordinator might cause issue for big consumer groups. Maybe
> > that
> > > is
> > > > > OK because metadata refresh is infrequent.
> > > > >
> > > > > This approach actually is very similar to what is proposed now:
> > > rebalance
> > > > > is triggered by metadata refresh, consumer provides subscription
> list
> > > to
> > > > > pass around. The only difference is that we don't need metadata
> hash
> > > > > anymore because the metadata is guaranteed to be the same.
> Replacing
> > > > > metadata hash with actual metadata will not have too much overhead
> > for
> > > > > small subscription groups. There will be some overhead for regex
> > > > > subscriptions, but this can save the potential extra round of
> > metadata
> > > > > fetch and will only occur when consumer see metadata change, which
> is
> > > > > infrequent.
> > > > >
> > > > > Any thoughts?
> > > > >
> > > > > Thanks,
> > > > >
> > > > > Jiangjie (Becket) Qin
> > > > >
> > > > >
> > > > > On Fri, Aug 14, 2015 at 12:57 PM, Ewen Cheslack-Postava <
> > > > ewen@confluent.io
> > > > > >
> > > > > wrote:
> > > > >
> > > > > > On Fri, Aug 14, 2015 at 10:59 AM, Jiangjie Qin
> > > > <jqin@linkedin.com.invalid
> > > > > >
> > > > > > wrote:
> > > > > >
> > > > > > > Neha and Ewen,
> > > > > > >
> > > > > > > About the metadata change frequency. I guess it really depends
> on
> > > how
> > > > > > > frequent the metadata change might occur. If we run Kafka as a
> > > > > service, I
> > > > > > > can see that happens from time to time. As I can imagine people
> > > will
> > > > > > create
> > > > > > > some topic, test and maybe delete the topic in some automated
> > test.
> > > > If
> > > > > > so,
> > > > > > > the proposed protocol might be a little bit vulnerable.
> > > > > > >
> > > > > > > More specifically the scenario I am thinking is:
> > > > > > > 1. Consumer 0 periodically refresh metadata and detected a
> > metadata
> > > > > > change.
> > > > > > > So it sends a JoinGroupRequest with metadata_hash_0.
> > > > > > > 2. Consumer 1 was notified by controller to start a rebalance,
> so
> > > it
> > > > > > > refreshes its metadata and send a JoingGroupRequest with
> > > > > metadata_hash_1,
> > > > > > > which is different from metadata hash 0.
> > > > > > > 3. Rebalance failed and both consumer refresh there metadata
> > again
> > > > from
> > > > > > > different brokers.
> > > > > > > 4. Depending on the metadata change frequency(or some admin
> > > operation
> > > > > > like
> > > > > > > partition reassigment), they may or may not have the same
> > metadata
> > > > > > > returned, so the restart from 3 again.
> > > > > > >
> > > > > > > I agree that step 4 might not be a big concern if consumers
> > updates
> > > > > > > metadata at almost the same time, but I'm a little bit worried
> > > > whether
> > > > > > that
> > > > > > > assumption really stands because we do not have control over
> how
> > > > > frequent
> > > > > > > the metadata can change.
> > > > > > >
> > > > > > >
> > > > > > Is this really that different from what would happen if the
> > > coordinator
> > > > > > distributed the metadata to consumers? In that case you would
> > > trivially
> > > > > > have everyone in a consistent state, but those metadata changes
> > would
> > > > > still
> > > > > > cause churn and require JoinGroup rounds, during which processing
> > is
> > > > > > stalled for the nodes that are waiting on other members to
> re-join
> > > the
> > > > > > group.
> > > > > >
> > > > > > -Ewen
> > > > > >
> > > > > >
> > > > > > > Thanks,
> > > > > > >
> > > > > > > Jiangjie (Becket) Qin
> > > > > > >
> > > > > > > On Fri, Aug 14, 2015 at 2:03 AM, Ewen Cheslack-Postava <
> > > > > > ewen@confluent.io>
> > > > > > > wrote:
> > > > > > >
> > > > > > > > On Thu, Aug 13, 2015 at 11:07 PM, Neha Narkhede <
> > > neha@confluent.io
> > > > >
> > > > > > > wrote:
> > > > > > > >
> > > > > > > > > Becket,
> > > > > > > > >
> > > > > > > > > As you say, the metadata hash addresses the concern you
> > > > originally
> > > > > > > raised
> > > > > > > > > about large topic subscriptions. Can you please list other
> > > > problems
> > > > > > you
> > > > > > > > are
> > > > > > > > > raising more clearly? It is more helpful to know problems
> > that
> > > > the
> > > > > > > > proposal
> > > > > > > > > does not address or addresses poorly.
> > > > > > > > >
> > > > > > > > > Regarding other things you said -
> > > > > > > > >
> > > > > > > > > it is required that each
> > > > > > > > > > consumer refresh their metadata before sending a
> > > > JoinGroupRequest
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > > This is required for wildcard topic subscriptions anyway.
> So
> > > this
> > > > > > > > proposal
> > > > > > > > > does not introduce a regression. We had agreed earlier that
> > it
> > > > does
> > > > > > not
> > > > > > > > > make sense for the server to deserialize regular
> expressions
> > > sent
> > > > > by
> > > > > > > the
> > > > > > > > > consumer.
> > > > > > > > >
> > > > > > > >
> > > > > > > > I don't think consumers need to do a metadata refresh before
> > > > sending
> > > > > a
> > > > > > > > JoinGroupRequest. Metadata changes that affect assignment are
> > > rare
> > > > --
> > > > > > it
> > > > > > > > requires changing the number of partitions in a topic. But
> you
> > > > might
> > > > > > > send a
> > > > > > > > JoinGroupRequest simply because a new member is trying to
> join
> > > the
> > > > > > group.
> > > > > > > > That case is presumably much more common.
> > > > > > > >
> > > > > > > > I think it's actually a good idea to have the first JoinGroup
> > > cycle
> > > > > > fail
> > > > > > > in
> > > > > > > > some cases, and has little impact. Lets say the metadata does
> > > > change
> > > > > > > > because partitions are added. Then we might fail in the first
> > > > round,
> > > > > > but
> > > > > > > > then all members detect that issue *immediately*, refresh
> their
> > > > > > metadata,
> > > > > > > > and submit a new join group request. This second cycle does
> not
> > > > > > require a
> > > > > > > > full heartbeat cycle. It happens much more quickly because
> > > everyone
> > > > > > > > detected the inconsistency based on the first
> > JoinGroupResponse.
> > > > The
> > > > > > > > inconsistency should be resolved very quickly (barring other
> > > > failures
> > > > > > > like
> > > > > > > > a member leaving mid-rebalance)
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > > the metadata might still be inconsistent if there is a
> > topic
> > > or
> > > > > > > > partition
> > > > > > > > > > change because the
> > > > > > > > > > UpdateMetadataRequest from controller might be handled at
> > > > > different
> > > > > > > > time.
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > > Topic metadata does not change frequently and even if it
> > did, a
> > > > > > couple
> > > > > > > > > rebalance attempts will be needed whether the coordinator
> > > drives
> > > > > the
> > > > > > > > > assignments or the consumer. Because guess how the
> > coordinator
> > > > > knows
> > > > > > > > about
> > > > > > > > > the topic metadata changes -- indirectly through either a
> zk
> > > > > callback
> > > > > > > or
> > > > > > > > > UpdateMetadataRequest, so it is completely possible the
> > > > coordinator
> > > > > > > sees
> > > > > > > > > the topic metadata changes in batches, not all at once.
> > > > > > > > >
> > > > > > > >
> > > > > > > > > On Thu, Aug 13, 2015 at 10:50 PM, Neha Narkhede <
> > > > neha@confluent.io
> > > > > >
> > > > > > > > wrote:
> > > > > > > > >
> > > > > > > > > > Ewen/Jason,
> > > > > > > > > >
> > > > > > > > > > The metadata hash is a clever approach and certainly
> > > addresses
> > > > > the
> > > > > > > > > problem
> > > > > > > > > > of large metadata for consumers like mirror maker. Few
> > > > comments -
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >    1. In the interest of simplifying the format of the
> > > > consumer's
> > > > > > > > > >    metadata - Why not just always include only the topic
> > > names
> > > > in
> > > > > > the
> > > > > > > > > metadata
> > > > > > > > > >    followed by the metadata hash? If the metadata hash
> > check
> > > > > > > succeeds,
> > > > > > > > > each
> > > > > > > > > >    consumer uses the # of partitions it had fetched. If
> it
> > > > > fails, a
> > > > > > > > > rebalance
> > > > > > > > > >    happens and the metadata is not used anyway.
> > > > > > > > >
> > > > > > > >
> > > > > > > > Doing this requires that every consumer always fetch the full
> > > > > metadata.
> > > > > > > The
> > > > > > > > most common use case is consumers that just want to consume
> one
> > > or
> > > > a
> > > > > > > couple
> > > > > > > > of topics, in which case grabbing all metadata for the entire
> > > > cluster
> > > > > > is
> > > > > > > > wasteful. If I subscribe only to topic A, why make all
> > consumers
> > > > grab
> > > > > > > > metadata for the entire topic (and need to rebalance every
> time
> > > it
> > > > > > > > changes!). Including the # of partitions for each topic lets
> > you
> > > > > avoid
> > > > > > > > having to grab the global set of metadata.
> > > > > > > >
> > > > > > > > So if you're just subscribing to one or a couple of topics,
> why
> > > not
> > > > > > just
> > > > > > > > compute the hash by filtering out everything but the topics
> you
> > > are
> > > > > > > > subscribed to? The problem there is if you ever add/remove
> > > > > > subscriptions
> > > > > > > > and want to support rolling upgrades. If the group was
> > subscribed
> > > > to
> > > > > > > topic
> > > > > > > > A, but later changes require subscribing to A + B, then to
> > > achieve
> > > > a
> > > > > > > > seamless rolling upgrade would require one (old) consumer to
> be
> > > > > > > subscribing
> > > > > > > > to A and one (new) consumer to be subscribing to A+B. If we
> > > > computed
> > > > > > > > metadata hashes based on filtered metadata, those two would
> > > > disagree
> > > > > > and
> > > > > > > we
> > > > > > > > could not perform assignment while the upgrade was in
> progress.
> > > > > > > >
> > > > > > > > The solution is to differentiate between the cases when a
> very
> > > > small
> > > > > > > amount
> > > > > > > > of the metadata is needed (one or a couple of topic
> > > subscriptions;
> > > > > > > > communicate and share this via metadata in the JoinGroup
> > > protocol)
> > > > vs
> > > > > > > when
> > > > > > > > *all* the metadata is needed (regex subscription; verify
> > > agreement
> > > > > via
> > > > > > > > hash).
> > > > > > > >
> > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > > >    2. Do you need a topic list and topic regex to be
> > > separate?
> > > > A
> > > > > > > single
> > > > > > > > > >    topic or list of topics can be expressed as a regex.
> > > > > > > > >
> > > > > > > >
> > > > > > > > See above note about collecting all metadata when you really
> > only
> > > > > need
> > > > > > it
> > > > > > > > for 1 or 2 topics. There's probably some debate to be had
> about
> > > > > whether
> > > > > > > > this cost would be too high -- every consumer would need to
> > > request
> > > > > the
> > > > > > > > metadata for all topics, and they'd need to request that all
> > > every
> > > > > time
> > > > > > > > they might be out of date.
> > > > > > > >
> > > > > > > Are we going to allow consumers in the same group to subscribe
> to
> > > > > > different
> > > > > > > topic set? If we do, we need to let them refresh metadata for
> all
> > > the
> > > > > > > topics a group is consuming from. If we don't then in the
> > protocol
> > > we
> > > > > > only
> > > > > > > need a subscription set hash.
> > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > > >    3. Let's include a version explicitly at the beginning
> > of
> > > > the
> > > > > > > > > >    ProtocolMetadata. The version dictates how to
> > deserialize
> > > > the
> > > > > > > > > >    ProtocolMetadata blob and is consistent with the rest
> of
> > > > > Kafka.
> > > > > > > > >
> > > > > > > >
> > > > > > > > If I'm understanding correctly, in JoinGroupRequest I would
> > > change
> > > > > > > >
> > > > > > > > GroupProtocols          => [Protocol ProtocolMetadata]
> > > > > > > >
> > > > > > > > to
> > > > > > > >
> > > > > > > > GroupProtocols          => [Protocol ProtocolVersion
> > > > > ProtocolMetadata]
> > > > > > > >
> > > > > > > > We had been talking about just baking the version into the
> > > Protocol
> > > > > > > field,
> > > > > > > > but making it separate seems perfectly reasonable to me.
> Jason,
> > > any
> > > > > > issue
> > > > > > > > with splitting the version out into a separate field like
> this?
> > > > > > > >
> > > > > > > > >
> > > > > > > > > > That can simplify the metadata format to the following:
> > > > > > > > > >
> > > > > > > > > > GroupType => "consumer"
> > > > > > > > > >>
> > > > > > > > > >> Protocol => AssignmentStrategy
> > > > > > > > > >>   AssignmentStrategy   => String
> > > > > > > > > >>
> > > > > > > > > >> ProtocolMetadata => Version Subscription
> > > > > > AssignmentStrategyMetadata
> > > > > > > > > >
> > > > > > > > > >     Version                    => String
> > > > > > > > > >
> > > > > > > > > >   Subscription                 => TopicRegex MetadataHash
> > > > > > > > > >>     TopicRegex                 => String
> > > > > > > > > >>     MetadataHash               => String
> > > > > > > > > >>   AssignmentStrategyMetadata   => bytes
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > On Thu, Aug 13, 2015 at 6:28 PM, Jiangjie Qin
> > > > > > > > <jqin@linkedin.com.invalid
> > > > > > > > > >
> > > > > > > > > > wrote:
> > > > > > > > > >
> > > > > > > > > >> Ewen and Jason,
> > > > > > > > > >>
> > > > > > > > > >> Thanks for the reply. Sorry I missed the metadata hash.
> > Yes,
> > > > > that
> > > > > > > is a
> > > > > > > > > >> clever approach and would solve my concern about the
> data
> > > > > passing
> > > > > > > > > around.
> > > > > > > > > >> I
> > > > > > > > > >> can see both pros and cons from doing this, though. The
> > > > > advantage
> > > > > > is
> > > > > > > > we
> > > > > > > > > >> don't need the topic metadata in JoinGroupResponse
> > anymore.
> > > > The
> > > > > > > > downside
> > > > > > > > > >> is
> > > > > > > > > >> that now rebalance have extra dependency on the
> consensus
> > of
> > > > > > > metadata
> > > > > > > > of
> > > > > > > > > >> all consumers, which is obtained separately. So it is
> > > required
> > > > > > that
> > > > > > > > each
> > > > > > > > > >> consumer refresh their metadata before sending a
> > > > > JoinGroupRequest,
> > > > > > > > > >> otherwise in some cases (e.g. wildcard consumers) will
> > > almost
> > > > > > > > certainly
> > > > > > > > > >> fail for the first rebalance attempt. Even if we do
> that,
> > > > since
> > > > > > the
> > > > > > > > > >> consumers are getting metadata from different brokers,
> the
> > > > > > metadata
> > > > > > > > > might
> > > > > > > > > >> still be inconsistent if there is a topic or partition
> > > change
> > > > > > > because
> > > > > > > > > the
> > > > > > > > > >> UpdateMetadataRequest from controller might be handled
> at
> > > > > > different
> > > > > > > > > time.
> > > > > > > > > >> Just want to make sure we think through the cases so the
> > > > > protocol
> > > > > > > does
> > > > > > > > > not
> > > > > > > > > >> cause us unexpected issues.
> > > > > > > > > >>
> > > > > > > > > >> About the number of consumers, I think with the current
> > > > > liveliness
> > > > > > > > > >> definition, we can tolerate churns by bumping up the
> > session
> > > > > > > timeout.
> > > > > > > > > Also
> > > > > > > > > >> I guess we will see an increasing number of consumers
> for
> > > new
> > > > > > > > consumer,
> > > > > > > > > >> because every the old consumer thread will probably
> > become a
> > > > > > > consumer.
> > > > > > > > > >>
> > > > > > > > > >> It is a valid concern for consumers that have large
> > > > subscription
> > > > > > > set.
> > > > > > > > > This
> > > > > > > > > >> might not be avoided though for client side assignment
> > > > approach.
> > > > > > One
> > > > > > > > > >> solution is having topic names associate with a topic
> ID.
> > > And
> > > > > only
> > > > > > > use
> > > > > > > > > >> topic ID in JoinGroupRequest and JoinGroupResponse,
> There
> > > is a
> > > > > > > > > discussion
> > > > > > > > > >> thread about this to solve the topic renaming case but
> > this
> > > > is a
> > > > > > > > > >> completely
> > > > > > > > > >> different discussion.
> > > > > > > > > >>
> > > > > > > > > >> Thanks,
> > > > > > > > > >>
> > > > > > > > > >> Jiangjie (Becket) Qin
> > > > > > > > > >>
> > > > > > > > > >>
> > > > > > > > > >>
> > > > > > > > > >> On Thu, Aug 13, 2015 at 2:14 PM, Jason Gustafson <
> > > > > > > jason@confluent.io>
> > > > > > > > > >> wrote:
> > > > > > > > > >>
> > > > > > > > > >> > Thanks Jiangjie, that information helps. I agree the
> > > > protocol
> > > > > > must
> > > > > > > > > >> consider
> > > > > > > > > >> > scalability. My point was that the synchronization
> > barrier
> > > > in
> > > > > > the
> > > > > > > > > >> current
> > > > > > > > > >> > protocol already effectively limits the number of
> > > consumers
> > > > > > since
> > > > > > > it
> > > > > > > > > >> > provides no way to gracefully handle churn. It
> wouldn't
> > be
> > > > > worth
> > > > > > > > > >> worrying
> > > > > > > > > >> > about scaling up to 100,000 members, for example,
> > because
> > > > > > there's
> > > > > > > no
> > > > > > > > > way
> > > > > > > > > >> > the group would be stable. So we just need to set some
> > > clear
> > > > > > > > > >> expectations
> > > > > > > > > >> > on the size we can scale to, and that can help inform
> > the
> > > > > > > discussion
> > > > > > > > > on
> > > > > > > > > >> the
> > > > > > > > > >> > size of messages in this protocol.
> > > > > > > > > >> >
> > > > > > > > > >> > Ewen and I were discussing this morning along similar
> > > lines
> > > > to
> > > > > > > what
> > > > > > > > > >> you're
> > > > > > > > > >> > suggesting. However, even if the coordinator decides
> on
> > > the
> > > > > > > metadata
> > > > > > > > > for
> > > > > > > > > >> > the group, each member still needs to communicate its
> > > > > > > subscriptions
> > > > > > > > to
> > > > > > > > > >> the
> > > > > > > > > >> > rest of the group. This is nice for the regex case
> since
> > > the
> > > > > > regex
> > > > > > > > is
> > > > > > > > > >> > probably small, but if the members have a large topic
> > > list,
> > > > > then
> > > > > > > we
> > > > > > > > > have
> > > > > > > > > >> > the same problem. One thing I was thinking about was
> > > whether
> > > > > we
> > > > > > > > really
> > > > > > > > > >> need
> > > > > > > > > >> > to handle different subscriptions for every member. If
> > the
> > > > > > > > coordinator
> > > > > > > > > >> > could guarantee that all members had the same
> > > subscription,
> > > > > then
> > > > > > > > there
> > > > > > > > > >> > would be no need for the coordinator to return the
> > > > > subscriptions
> > > > > > > for
> > > > > > > > > >> each
> > > > > > > > > >> > member. However, this would prevent graceful upgrades.
> > We
> > > > > might
> > > > > > be
> > > > > > > > > able
> > > > > > > > > >> to
> > > > > > > > > >> > fix that problem by allowing the consumer to provide
> two
> > > > > > > > subscriptions
> > > > > > > > > >> to
> > > > > > > > > >> > allowing rolling updates, but that starts to sound
> > pretty
> > > > > nasty.
> > > > > > > > > >> >
> > > > > > > > > >> > -Jason
> > > > > > > > > >> >
> > > > > > > > > >> > On Thu, Aug 13, 2015 at 1:41 PM, Jiangjie Qin
> > > > > > > > > <jqin@linkedin.com.invalid
> > > > > > > > > >> >
> > > > > > > > > >> > wrote:
> > > > > > > > > >> >
> > > > > > > > > >> > > Jason,
> > > > > > > > > >> > >
> > > > > > > > > >> > > The protocol has to consider the scalability. The
> > > protocol
> > > > > in
> > > > > > > the
> > > > > > > > > wiki
> > > > > > > > > >> > > means the JoinGroupResoponse size would be:
> > > > > > > > > >> > > NumberOfTopics * (AvgTopicNameLength + 4) *
> > > > > > > (NumberOfConsumers)^2
> > > > > > > > > >> > >
> > > > > > > > > >> > > To give some real number, we have 26-node Mirror
> Maker
> > > > > > cluster,
> > > > > > > > each
> > > > > > > > > >> > with 4
> > > > > > > > > >> > > consumers. That is 104 consumers using regex ".*".
> And
> > > > most
> > > > > of
> > > > > > > our
> > > > > > > > > >> > clusters
> > > > > > > > > >> > > have around 3000 topics, whose topic name are
> > typically
> > > > > around
> > > > > > > 20
> > > > > > > > > >> > > characters.
> > > > > > > > > >> > >
> > > > > > > > > >> > > I think the key issue for client side partition
> > > assignment
> > > > > > logic
> > > > > > > > is
> > > > > > > > > to
> > > > > > > > > >> > make
> > > > > > > > > >> > > sure 1) all the clients run the same algorithm. 2)
> all
> > > the
> > > > > > > clients
> > > > > > > > > >> make
> > > > > > > > > >> > > decision on the same topic metadata. The second
> > purpose
> > > > can
> > > > > be
> > > > > > > > done
> > > > > > > > > by
> > > > > > > > > >> > > simply letting coordinator provide the topic
> metadata
> > > and
> > > > > all
> > > > > > > then
> > > > > > > > > >> member
> > > > > > > > > >> > > information as source of truth. Is it necessary to
> > pass
> > > > > topic
> > > > > > > > > >> metadata of
> > > > > > > > > >> > > each consumer around? Can we keep the protocol
> > metadata
> > > > > field
> > > > > > > > > >> completely
> > > > > > > > > >> > > independent of topic metadata? I think In the
> > > > > > JoinGroupResponse,
> > > > > > > > we
> > > > > > > > > >> > should
> > > > > > > > > >> > > have only one copy of topic metadata provided by
> > > > coordinator
> > > > > > and
> > > > > > > > is
> > > > > > > > > >> > outside
> > > > > > > > > >> > > of protocol metadata. If user decides to put some
> > > metadata
> > > > > in
> > > > > > > the
> > > > > > > > > >> > > JoinGroupRequest and let coordinator pass around,
> they
> > > are
> > > > > > > > > responsible
> > > > > > > > > >> > for
> > > > > > > > > >> > > understanding the risk.
> > > > > > > > > >> > >
> > > > > > > > > >> > > Thanks,
> > > > > > > > > >> > >
> > > > > > > > > >> > > Jiangjie (Becket) Qin
> > > > > > > > > >> > >
> > > > > > > > > >> > >
> > > > > > > > > >> > > On Thu, Aug 13, 2015 at 12:41 PM, Jason Gustafson <
> > > > > > > > > jason@confluent.io
> > > > > > > > > >> >
> > > > > > > > > >> > > wrote:
> > > > > > > > > >> > >
> > > > > > > > > >> > > > Hey Onur and Jiangjie,
> > > > > > > > > >> > > >
> > > > > > > > > >> > > > I've updated that wiki with a proposal to add
> regex
> > > > > > > > subscriptions
> > > > > > > > > to
> > > > > > > > > >> > the
> > > > > > > > > >> > > > consumer metadata. Can you have a look to see if
> it
> > > > > > addresses
> > > > > > > > your
> > > > > > > > > >> > > concern?
> > > > > > > > > >> > > > In general, I think we should be a little careful
> > when
> > > > we
> > > > > > are
> > > > > > > > > >> talking
> > > > > > > > > >> > > about
> > > > > > > > > >> > > > the scalability of the protocol. Regardless of
> > whether
> > > > > > > > assignment
> > > > > > > > > is
> > > > > > > > > >> > done
> > > > > > > > > >> > > > on the server or the client, the protocol assumes
> a
> > > > > > relatively
> > > > > > > > > >> stable
> > > > > > > > > >> > > > configuration. When the number of consumers
> > increases
> > > > > > beyond a
> > > > > > > > > >> certain
> > > > > > > > > >> > > > limit, then membership churn becomes a major
> > concern.
> > > > > > > Similarly
> > > > > > > > > >> there
> > > > > > > > > >> > is
> > > > > > > > > >> > > a
> > > > > > > > > >> > > > notion of metadata churn when topics are added,
> > > deleted,
> > > > > or
> > > > > > > > > >> resized. If
> > > > > > > > > >> > > > either membership or metadata changes, then the
> > > protocol
> > > > > > > forces
> > > > > > > > > all
> > > > > > > > > >> > > > consumers to stop consumption and rejoin the
> group.
> > If
> > > > > this
> > > > > > > > > happens
> > > > > > > > > >> > often
> > > > > > > > > >> > > > enough, then it can severely impact the ability of
> > the
> > > > > > > consumer
> > > > > > > > to
> > > > > > > > > >> make
> > > > > > > > > >> > > > progress. The point is that the protocol may
> already
> > > be
> > > > > > > unsuited
> > > > > > > > > to
> > > > > > > > > >> > cases
> > > > > > > > > >> > > > where there are either a large number of consumers
> > or
> > > > > > topics.
> > > > > > > I
> > > > > > > > > >> wonder
> > > > > > > > > >> > if
> > > > > > > > > >> > > > you guys can share your thoughts about your
> scaling
> > > > > > > > expectations?
> > > > > > > > > >> > > >
> > > > > > > > > >> > > > -Jason
> > > > > > > > > >> > > >
> > > > > > > > > >> > > >
> > > > > > > > > >> > > >
> > > > > > > > > >> > > >
> > > > > > > > > >> > > > On Wed, Aug 12, 2015 at 12:28 PM, Jason Gustafson
> <
> > > > > > > > > >> jason@confluent.io>
> > > > > > > > > >> > > > wrote:
> > > > > > > > > >> > > >
> > > > > > > > > >> > > > > Hey Jiangjie,
> > > > > > > > > >> > > > >
> > > > > > > > > >> > > > > That's a great point. In the worst case (the
> > mirror
> > > > > maker
> > > > > > > > case I
> > > > > > > > > >> > > guess),
> > > > > > > > > >> > > > > the join group response can be massive. This
> would
> > > be
> > > > > > > > especially
> > > > > > > > > >> > deadly
> > > > > > > > > >> > > > > when there is a lot of churn in the group (e.g.
> > in a
> > > > > > rolling
> > > > > > > > > >> > upgrade).
> > > > > > > > > >> > > > The
> > > > > > > > > >> > > > > current protocol is not great for this case
> > either,
> > > > but
> > > > > > it's
> > > > > > > > > >> > > > significantly
> > > > > > > > > >> > > > > better. Here are a couple ways to deal with the
> > > size:
> > > > > > > > > >> > > > >
> > > > > > > > > >> > > > > 1. First, we could have the coordinator compress
> > the
> > > > > > > > responses.
> > > > > > > > > >> This
> > > > > > > > > >> > > > would
> > > > > > > > > >> > > > > probably be pretty effective if applied across
> the
> > > > > > metadata
> > > > > > > > from
> > > > > > > > > >> all
> > > > > > > > > >> > > > > members.
> > > > > > > > > >> > > > >
> > > > > > > > > >> > > > > 2. I think the regex case is the main problem.
> Is
> > > that
> > > > > > > right?
> > > > > > > > We
> > > > > > > > > >> > could
> > > > > > > > > >> > > > > extend the metadata to allow the consumer to
> embed
> > > its
> > > > > > regex
> > > > > > > > > >> > > subscription
> > > > > > > > > >> > > > > in the metadata directly (note this might be a
> > good
> > > > idea
> > > > > > > > > >> regardless
> > > > > > > > > >> > of
> > > > > > > > > >> > > > the
> > > > > > > > > >> > > > > rest of this proposal). To support regex on the
> > > > > consumer,
> > > > > > we
> > > > > > > > > must
> > > > > > > > > >> > fetch
> > > > > > > > > >> > > > > metadata for all topics. Rather than having all
> > > regex
> > > > > > > > > subscribers
> > > > > > > > > >> > embed
> > > > > > > > > >> > > > all
> > > > > > > > > >> > > > > of this metadata in their join group requests,
> > they
> > > > > could
> > > > > > > > > instead
> > > > > > > > > >> > > embed a
> > > > > > > > > >> > > > > hash of it. Then after the join group responses
> > are
> > > > > > > received,
> > > > > > > > > they
> > > > > > > > > >> > just
> > > > > > > > > >> > > > > need to check that the hashes are the same. If
> > there
> > > > is
> > > > > a
> > > > > > > > > mismatch
> > > > > > > > > >> > > (which
> > > > > > > > > >> > > > > should only occur when topics are created,
> > deleted,
> > > or
> > > > > > > > resized),
> > > > > > > > > >> then
> > > > > > > > > >> > > the
> > > > > > > > > >> > > > > group members must refetch the metadata and
> rejoin
> > > the
> > > > > > > group.
> > > > > > > > > >> This is
> > > > > > > > > >> > > > also
> > > > > > > > > >> > > > > how the current protocol behaves when there is a
> > > > change
> > > > > in
> > > > > > > the
> > > > > > > > > >> topic
> > > > > > > > > >> > > > > metadata affecting the group--someone (either
> the
> > > > > > > coordinator
> > > > > > > > or
> > > > > > > > > >> the
> > > > > > > > > >> > > > > consumer) detects the change and forces the
> group
> > to
> > > > > > > > rebalance.
> > > > > > > > > >> > > > >
> > > > > > > > > >> > > > > What do you think?
> > > > > > > > > >> > > > >
> > > > > > > > > >> > > > > (Also I think adding groupId/generationId to
> fetch
> > > and
> > > > > > > produce
> > > > > > > > > >> > requests
> > > > > > > > > >> > > > > seems like an interesting line of thought.)
> > > > > > > > > >> > > > >
> > > > > > > > > >> > > > > -Jason
> > > > > > > > > >> > > > >
> > > > > > > > > >> > > > >
> > > > > > > > > >> > > > >
> > > > > > > > > >> > > > > On Wed, Aug 12, 2015 at 10:57 AM, Jiangjie Qin
> > > > > > > > > >> > > <jqin@linkedin.com.invalid
> > > > > > > > > >> > > > >
> > > > > > > > > >> > > > > wrote:
> > > > > > > > > >> > > > >
> > > > > > > > > >> > > > >> Hey Ewen,
> > > > > > > > > >> > > > >>
> > > > > > > > > >> > > > >> Onur and I discussed this a little bit more.
> And
> > we
> > > > are
> > > > > > > still
> > > > > > > > > >> > worrying
> > > > > > > > > >> > > > >> about passing all the metadata of all consumers
> > > > around.
> > > > > > > > > >> > > > >>
> > > > > > > > > >> > > > >> Let's say I have a cluster has 10,000 topics,
> the
> > > > > average
> > > > > > > > topic
> > > > > > > > > >> name
> > > > > > > > > >> > > > >> length
> > > > > > > > > >> > > > >> is 10 bytes. In this case, the opaque metadata
> > will
> > > > > have
> > > > > > > 10 *
> > > > > > > > > >> > 10,000 =
> > > > > > > > > >> > > > >> 100KB for topic name, for each topic, there is
> a
> > > > 4-byte
> > > > > > > > integer
> > > > > > > > > >> of
> > > > > > > > > >> > > > number
> > > > > > > > > >> > > > >> of partitions, that's another 40KB. So one
> global
> > > > topic
> > > > > > > > > metadata
> > > > > > > > > >> > will
> > > > > > > > > >> > > > have
> > > > > > > > > >> > > > >> 140KB data. If I have 100 consumers who are
> using
> > > > > > wildcard
> > > > > > > to
> > > > > > > > > >> > consume
> > > > > > > > > >> > > > from
> > > > > > > > > >> > > > >> all the topics. That means the protocol
> metadata
> > > end
> > > > up
> > > > > > in
> > > > > > > > the
> > > > > > > > > >> > > > >> JoinGroupResponse will be 140KB * 100 = 14MB.
> And
> > > the
> > > > > > > > > >> > > JoinGroupResponse
> > > > > > > > > >> > > > >> will need to be sent to 100 different
> consumers,
> > > that
> > > > > > means
> > > > > > > > > 14MB
> > > > > > > > > >> *
> > > > > > > > > >> > > 100 =
> > > > > > > > > >> > > > >> 1.4GB need to be sent by the consumer
> coordinator
> > > for
> > > > > one
> > > > > > > > > >> rebalance.
> > > > > > > > > >> > > How
> > > > > > > > > >> > > > >> would that work?
> > > > > > > > > >> > > > >>
> > > > > > > > > >> > > > >> Also, having two consumers (old owner and new
> > > owner)
> > > > > > > > consuming
> > > > > > > > > >> from
> > > > > > > > > >> > > the
> > > > > > > > > >> > > > >> same partition might also be a problem. e.g.
> > people
> > > > are
> > > > > > > > > updating
> > > > > > > > > >> > > > database.
> > > > > > > > > >> > > > >> One thing might worth doing is to add GroupId
> and
> > > > > > > Generation
> > > > > > > > ID
> > > > > > > > > >> to
> > > > > > > > > >> > > > >> ProducerRequest and FetchRequest as well. This
> > will
> > > > > also
> > > > > > > help
> > > > > > > > > >> with
> > > > > > > > > >> > the
> > > > > > > > > >> > > > >> single producer use case. However, this is
> > probably
> > > > > > > > orthogonal
> > > > > > > > > to
> > > > > > > > > >> > this
> > > > > > > > > >> > > > >> thread given the current new consumer also has
> > this
> > > > > > problem
> > > > > > > > > and I
> > > > > > > > > >> > > > believe
> > > > > > > > > >> > > > >> we need to fix it.
> > > > > > > > > >> > > > >>
> > > > > > > > > >> > > > >> Thanks,
> > > > > > > > > >> > > > >>
> > > > > > > > > >> > > > >> Jiangjie (Becket) Qin
> > > > > > > > > >> > > > >>
> > > > > > > > > >> > > > >> On Tue, Aug 11, 2015 at 11:43 PM, Ewen
> > > > > Cheslack-Postava <
> > > > > > > > > >> > > > >> ewen@confluent.io>
> > > > > > > > > >> > > > >> wrote:
> > > > > > > > > >> > > > >>
> > > > > > > > > >> > > > >> > On Tue, Aug 11, 2015 at 11:29 PM, Jiangjie
> Qin
> > > > > > > > > >> > > > >> <jq...@linkedin.com.invalid>
> > > > > > > > > >> > > > >> > wrote:
> > > > > > > > > >> > > > >> >
> > > > > > > > > >> > > > >> > > Ewen,
> > > > > > > > > >> > > > >> > >
> > > > > > > > > >> > > > >> > > Thanks for the explanation.
> > > > > > > > > >> > > > >> > >
> > > > > > > > > >> > > > >> > > For (1), I am more concerned about the
> > failure
> > > > case
> > > > > > > > instead
> > > > > > > > > >> of
> > > > > > > > > >> > > > normal
> > > > > > > > > >> > > > >> > case.
> > > > > > > > > >> > > > >> > > What if a consumer somehow was kick out of
> a
> > > > group
> > > > > > but
> > > > > > > is
> > > > > > > > > >> still
> > > > > > > > > >> > > > >> consuming
> > > > > > > > > >> > > > >> > > and committing offsets? Does that mean the
> > new
> > > > > owner
> > > > > > > and
> > > > > > > > > old
> > > > > > > > > >> > owner
> > > > > > > > > >> > > > >> might
> > > > > > > > > >> > > > >> > > potentially consuming from and committing
> > > offsets
> > > > > for
> > > > > > > the
> > > > > > > > > >> same
> > > > > > > > > >> > > > >> partition?
> > > > > > > > > >> > > > >> > > In the old consumer, this won't happen
> > because
> > > > the
> > > > > > new
> > > > > > > > > >> consumer
> > > > > > > > > >> > > will
> > > > > > > > > >> > > > >> not
> > > > > > > > > >> > > > >> > be
> > > > > > > > > >> > > > >> > > able to start consumption unless the
> previous
> > > > owner
> > > > > > has
> > > > > > > > > >> released
> > > > > > > > > >> > > its
> > > > > > > > > >> > > > >> > > ownership. Basically, without the ownership
> > > > > > guarantee,
> > > > > > > I
> > > > > > > > > >> don't
> > > > > > > > > >> > see
> > > > > > > > > >> > > > how
> > > > > > > > > >> > > > >> > the
> > > > > > > > > >> > > > >> > > communication among consumers themselves
> > alone
> > > > can
> > > > > > > solve
> > > > > > > > > the
> > > > > > > > > >> > > problem
> > > > > > > > > >> > > > >> > here.
> > > > > > > > > >> > > > >> > >
> > > > > > > > > >> > > > >> >
> > > > > > > > > >> > > > >> > The generation ID check still applies to
> offset
> > > > > > commits.
> > > > > > > If
> > > > > > > > > >> one of
> > > > > > > > > >> > > the
> > > > > > > > > >> > > > >> > consumers is kicked out and misbehaving, it
> can
> > > > > > obviously
> > > > > > > > > still
> > > > > > > > > >> > > fetch
> > > > > > > > > >> > > > >> and
> > > > > > > > > >> > > > >> > process messages, but offset commits will not
> > > work
> > > > > > since
> > > > > > > it
> > > > > > > > > >> will
> > > > > > > > > >> > not
> > > > > > > > > >> > > > >> have
> > > > > > > > > >> > > > >> > the current generation ID.
> > > > > > > > > >> > > > >> >
> > > > > > > > > >> > > > >> >
> > > > > > > > > >> > > > >> > >
> > > > > > > > > >> > > > >> > > For (2) and (3), now I understand how
> > metadata
> > > > are
> > > > > > > used.
> > > > > > > > > But
> > > > > > > > > >> I
> > > > > > > > > >> > > still
> > > > > > > > > >> > > > >> > don't
> > > > > > > > > >> > > > >> > > see why should we let the consumers to pass
> > the
> > > > > topic
> > > > > > > > > >> > information
> > > > > > > > > >> > > > >> across
> > > > > > > > > >> > > > >> > > instead of letting coordinator give the
> > > > > information.
> > > > > > > The
> > > > > > > > > >> single
> > > > > > > > > >> > > > >> producer
> > > > > > > > > >> > > > >> > > use case does not solve the ownership
> problem
> > > in
> > > > > > > abnormal
> > > > > > > > > >> case
> > > > > > > > > >> > > > either,
> > > > > > > > > >> > > > >> > > which seems to be a little bit vulnerable.
> > > > > > > > > >> > > > >> > >
> > > > > > > > > >> > > > >> >
> > > > > > > > > >> > > > >> > One of the goals here was to generalize group
> > > > > > membership
> > > > > > > so
> > > > > > > > > we
> > > > > > > > > >> > can,
> > > > > > > > > >> > > > for
> > > > > > > > > >> > > > >> > example, use it for balancing Copycat tasks
> > > across
> > > > > > > workers.
> > > > > > > > > >> > There's
> > > > > > > > > >> > > no
> > > > > > > > > >> > > > >> > topic subscription info in that case. The
> > > metadata
> > > > > for
> > > > > > > > > copycat
> > > > > > > > > >> > > workers
> > > > > > > > > >> > > > >> > would instead need to somehow indicate the
> > > current
> > > > > set
> > > > > > of
> > > > > > > > > tasks
> > > > > > > > > >> > that
> > > > > > > > > >> > > > >> need
> > > > > > > > > >> > > > >> > to be assigned to workers. By making the
> > metadata
> > > > > > > > completely
> > > > > > > > > >> > opaque
> > > > > > > > > >> > > to
> > > > > > > > > >> > > > >> the
> > > > > > > > > >> > > > >> > protocol, it becomes more generally useful
> > since
> > > it
> > > > > > > focuses
> > > > > > > > > >> > squarely
> > > > > > > > > >> > > > on
> > > > > > > > > >> > > > >> the
> > > > > > > > > >> > > > >> > group membership problem, allowing for that
> > > > > additional
> > > > > > > bit
> > > > > > > > of
> > > > > > > > > >> > > metadata
> > > > > > > > > >> > > > >> so
> > > > > > > > > >> > > > >> > you don't just get a list of members, but
> also
> > > get
> > > > a
> > > > > > > little
> > > > > > > > > >> bit of
> > > > > > > > > >> > > > info
> > > > > > > > > >> > > > >> > about each of them.
> > > > > > > > > >> > > > >> >
> > > > > > > > > >> > > > >> > A different option that we explored is to
> use a
> > > > sort
> > > > > of
> > > > > > > > mixed
> > > > > > > > > >> > model
> > > > > > > > > >> > > --
> > > > > > > > > >> > > > >> > still bake all the topic subscriptions
> directly
> > > > into
> > > > > > the
> > > > > > > > > >> protocol
> > > > > > > > > >> > > but
> > > > > > > > > >> > > > >> also
> > > > > > > > > >> > > > >> > include metadata. That would allow us to
> > maintain
> > > > the
> > > > > > > > > existing
> > > > > > > > > >> > > > >> > coordinator-driven approach to handling the
> > > > metadata
> > > > > > and
> > > > > > > > > change
> > > > > > > > > >> > > events
> > > > > > > > > >> > > > >> like
> > > > > > > > > >> > > > >> > the ones Onur pointed out. Then something
> like
> > > the
> > > > > > > Copycat
> > > > > > > > > >> workers
> > > > > > > > > >> > > > would
> > > > > > > > > >> > > > >> > just not fill in any topic subscriptions and
> it
> > > > would
> > > > > > be
> > > > > > > > > >> handled
> > > > > > > > > >> > as
> > > > > > > > > >> > > a
> > > > > > > > > >> > > > >> > degenerate case. Based on the way I explained
> > > that
> > > > we
> > > > > > can
> > > > > > > > > >> handle
> > > > > > > > > >> > > those
> > > > > > > > > >> > > > >> > types of events, I personally feel its
> cleaner
> > > and
> > > > a
> > > > > > > nicer
> > > > > > > > > >> > > > >> generalization
> > > > > > > > > >> > > > >> > to not include the subscriptions in the join
> > > group
> > > > > > > > protocol,
> > > > > > > > > >> > making
> > > > > > > > > >> > > it
> > > > > > > > > >> > > > >> part
> > > > > > > > > >> > > > >> > of the metadata instead.
> > > > > > > > > >> > > > >> >
> > > > > > > > > >> > > > >> > For the single producer case, are you saying
> it
> > > > > doesn't
> > > > > > > > solve
> > > > > > > > > >> > > > ownership
> > > > > > > > > >> > > > >> in
> > > > > > > > > >> > > > >> > the abnormal case because a producer that
> > doesn't
> > > > > know
> > > > > > it
> > > > > > > > has
> > > > > > > > > >> been
> > > > > > > > > >> > > > >> kicked
> > > > > > > > > >> > > > >> > out of the group yet can still produce data
> > even
> > > > > though
> > > > > > > it
> > > > > > > > > >> > shouldn't
> > > > > > > > > >> > > > be
> > > > > > > > > >> > > > >> > able to anymore? I definitely agree that that
> > is
> > > a
> > > > > risk
> > > > > > > --
> > > > > > > > > this
> > > > > > > > > >> > > > >> provides a
> > > > > > > > > >> > > > >> > way to get closer to a true single-writer,
> but
> > > > there
> > > > > > are
> > > > > > > > > >> > definitely
> > > > > > > > > >> > > > >> still
> > > > > > > > > >> > > > >> > failure modes that this does not address.
> > > > > > > > > >> > > > >> >
> > > > > > > > > >> > > > >> > -Ewen
> > > > > > > > > >> > > > >> >
> > > > > > > > > >> > > > >> >
> > > > > > > > > >> > > > >> > >
> > > > > > > > > >> > > > >> > > Thanks,
> > > > > > > > > >> > > > >> > >
> > > > > > > > > >> > > > >> > > Jiangjie (Becket) Qin
> > > > > > > > > >> > > > >> > >
> > > > > > > > > >> > > > >> > >
> > > > > > > > > >> > > > >> > > On Tue, Aug 11, 2015 at 11:06 PM, Ewen
> > > > > > > Cheslack-Postava <
> > > > > > > > > >> > > > >> > ewen@confluent.io
> > > > > > > > > >> > > > >> > > >
> > > > > > > > > >> > > > >> > > wrote:
> > > > > > > > > >> > > > >> > >
> > > > > > > > > >> > > > >> > > > On Tue, Aug 11, 2015 at 10:15 PM,
> Jiangjie
> > > Qin
> > > > > > > > > >> > > > >> > <jqin@linkedin.com.invalid
> > > > > > > > > >> > > > >> > > >
> > > > > > > > > >> > > > >> > > > wrote:
> > > > > > > > > >> > > > >> > > >
> > > > > > > > > >> > > > >> > > > > Hi Jason,
> > > > > > > > > >> > > > >> > > > >
> > > > > > > > > >> > > > >> > > > > Thanks for writing this up. It would be
> > > > useful
> > > > > to
> > > > > > > > > >> generalize
> > > > > > > > > >> > > the
> > > > > > > > > >> > > > >> > group
> > > > > > > > > >> > > > >> > > > > concept. I have a few questions below.
> > > > > > > > > >> > > > >> > > > >
> > > > > > > > > >> > > > >> > > > > 1. In old consumer actually the
> partition
> > > > > > > assignment
> > > > > > > > > are
> > > > > > > > > >> > done
> > > > > > > > > >> > > by
> > > > > > > > > >> > > > >> > > > consumers
> > > > > > > > > >> > > > >> > > > > themselves. We used zookeeper to
> > guarantee
> > > > > that a
> > > > > > > > > >> partition
> > > > > > > > > >> > > will
> > > > > > > > > >> > > > >> only
> > > > > > > > > >> > > > >> > > be
> > > > > > > > > >> > > > >> > > > > consumed by one consumer thread who
> > > > > successfully
> > > > > > > > > claimed
> > > > > > > > > >> its
> > > > > > > > > >> > > > >> > ownership.
> > > > > > > > > >> > > > >> > > > > Does the new protocol plan to provide
> the
> > > > same
> > > > > > > > > guarantee?
> > > > > > > > > >> > > > >> > > > >
> > > > > > > > > >> > > > >> > > >
> > > > > > > > > >> > > > >> > > > Once you have all the metadata from all
> the
> > > > > > > consumers,
> > > > > > > > > >> > > assignment
> > > > > > > > > >> > > > >> > should
> > > > > > > > > >> > > > >> > > > just be a simple function mapping that
> > > > > > > Map<ConsumerId,
> > > > > > > > > >> > Metadata>
> > > > > > > > > >> > > > to
> > > > > > > > > >> > > > >> > > > Map<ConsumerId, List<TopicPartition>>. If
> > > > > everyone
> > > > > > is
> > > > > > > > > >> > consistent
> > > > > > > > > >> > > > in
> > > > > > > > > >> > > > >> > > > computing that, you don't need ZK
> involved
> > at
> > > > > all.
> > > > > > > > > >> > > > >> > > >
> > > > > > > > > >> > > > >> > > > In practice, this shouldn't be that hard
> to
> > > > > ensure
> > > > > > > for
> > > > > > > > > most
> > > > > > > > > >> > > > >> assignment
> > > > > > > > > >> > > > >> > > > strategies just by having decent unit
> > testing
> > > > on
> > > > > > > them.
> > > > > > > > > You
> > > > > > > > > >> > just
> > > > > > > > > >> > > > >> have to
> > > > > > > > > >> > > > >> > > do
> > > > > > > > > >> > > > >> > > > things like ensure your assignment
> strategy
> > > > sorts
> > > > > > > lists
> > > > > > > > > >> into a
> > > > > > > > > >> > > > >> > consistent
> > > > > > > > > >> > > > >> > > > order.
> > > > > > > > > >> > > > >> > > >
> > > > > > > > > >> > > > >> > > > You do give up the ability to use some
> > > > techniques
> > > > > > > (e.g.
> > > > > > > > > any
> > > > > > > > > >> > > > >> randomized
> > > > > > > > > >> > > > >> > > > algorithm if you can't distribute the
> seed
> > w/
> > > > the
> > > > > > > > > metadata)
> > > > > > > > > >> > and
> > > > > > > > > >> > > > it's
> > > > > > > > > >> > > > >> > true
> > > > > > > > > >> > > > >> > > > that nothing validates the assignment,
> but
> > if
> > > > > that
> > > > > > > > > >> assignment
> > > > > > > > > >> > > > >> algorithm
> > > > > > > > > >> > > > >> > > > step is kept simple, small, and well
> > tested,
> > > > the
> > > > > > risk
> > > > > > > > is
> > > > > > > > > >> very
> > > > > > > > > >> > > > >> minimal.
> > > > > > > > > >> > > > >> > > >
> > > > > > > > > >> > > > >> > > >
> > > > > > > > > >> > > > >> > > > >
> > > > > > > > > >> > > > >> > > > > 2. It looks that both JoinGroupRequest
> > and
> > > > > > > > > >> JoinGroupResponse
> > > > > > > > > >> > > has
> > > > > > > > > >> > > > >> the
> > > > > > > > > >> > > > >> > > > >
> > > ProtocolMetadata.AssignmentStrategyMetadata,
> > > > > what
> > > > > > > > would
> > > > > > > > > >> be
> > > > > > > > > >> > the
> > > > > > > > > >> > > > >> > metadata
> > > > > > > > > >> > > > >> > > > be
> > > > > > > > > >> > > > >> > > > > sent and returned by coordinator? How
> > will
> > > > the
> > > > > > > > > >> coordinator
> > > > > > > > > >> > > > handle
> > > > > > > > > >> > > > >> the
> > > > > > > > > >> > > > >> > > > > metadata?
> > > > > > > > > >> > > > >> > > > >
> > > > > > > > > >> > > > >> > > >
> > > > > > > > > >> > > > >> > > > The coordinator is basically just blindly
> > > > > > > broadcasting
> > > > > > > > > all
> > > > > > > > > >> of
> > > > > > > > > >> > it
> > > > > > > > > >> > > > to
> > > > > > > > > >> > > > >> > group
> > > > > > > > > >> > > > >> > > > members so they have a consistent view.
> > > > > > > > > >> > > > >> > > >
> > > > > > > > > >> > > > >> > > > So from the coordinators perspective, it
> > sees
> > > > > > > something
> > > > > > > > > >> like:
> > > > > > > > > >> > > > >> > > >
> > > > > > > > > >> > > > >> > > > Consumer 1 -> JoinGroupRequest with
> > > > > GroupProtocols
> > > > > > =
> > > > > > > [
> > > > > > > > > >> > > "consumer"
> > > > > > > > > >> > > > >> > > > <Consumer1 opaque byte[]>]
> > > > > > > > > >> > > > >> > > > Consumer 2 -> JoinGroupRequest with
> > > > > GroupProtocols
> > > > > > =
> > > > > > > [
> > > > > > > > > >> > > "consumer"
> > > > > > > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > > > > > > >> > > > >> > > >
> > > > > > > > > >> > > > >> > > > Then, in the responses would look like:
> > > > > > > > > >> > > > >> > > >
> > > > > > > > > >> > > > >> > > > Consumer 1 <- JoinGroupResponse with
> > > > > GroupProtocol
> > > > > > =
> > > > > > > > > >> > "consumer"
> > > > > > > > > >> > > > and
> > > > > > > > > >> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1
> > opaque
> > > > > > > byte[]>,
> > > > > > > > > >> > Consumer
> > > > > > > > > >> > > 2
> > > > > > > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > > > > > > >> > > > >> > > > Consumer 2 <- JoinGroupResponse with
> > > > > GroupProtocol
> > > > > > =
> > > > > > > > > >> > "consumer"
> > > > > > > > > >> > > > and
> > > > > > > > > >> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1
> > opaque
> > > > > > > byte[]>,
> > > > > > > > > >> > Consumer
> > > > > > > > > >> > > 2
> > > > > > > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > > > > > > >> > > > >> > > >
> > > > > > > > > >> > > > >> > > > So all the responses include all the
> > metadata
> > > > for
> > > > > > > every
> > > > > > > > > >> member
> > > > > > > > > >> > > in
> > > > > > > > > >> > > > >> the
> > > > > > > > > >> > > > >> > > > group, and everyone can use that to
> > > > consistently
> > > > > > > decide
> > > > > > > > > on
> > > > > > > > > >> > > > >> assignment.
> > > > > > > > > >> > > > >> > > The
> > > > > > > > > >> > > > >> > > > broker doesn't care and cannot even
> > > understand
> > > > > the
> > > > > > > > > metadata
> > > > > > > > > >> > > since
> > > > > > > > > >> > > > >> the
> > > > > > > > > >> > > > >> > > data
> > > > > > > > > >> > > > >> > > > format for it is dependent on the
> > assignment
> > > > > > strategy
> > > > > > > > > being
> > > > > > > > > >> > > used.
> > > > > > > > > >> > > > >> > > >
> > > > > > > > > >> > > > >> > > > As another example that is *not* a
> > consumer,
> > > > > let's
> > > > > > > say
> > > > > > > > > you
> > > > > > > > > >> > just
> > > > > > > > > >> > > > >> want to
> > > > > > > > > >> > > > >> > > > have a single writer in the group which
> > > > everyone
> > > > > > will
> > > > > > > > > >> forward
> > > > > > > > > >> > > > >> requests
> > > > > > > > > >> > > > >> > > to.
> > > > > > > > > >> > > > >> > > > To accomplish this, you could use a very
> > dumb
> > > > > > > > assignment
> > > > > > > > > >> > > strategy:
> > > > > > > > > >> > > > >> > there
> > > > > > > > > >> > > > >> > > is
> > > > > > > > > >> > > > >> > > > no metadata (empty byte[]) and all we
> care
> > > > about
> > > > > is
> > > > > > > who
> > > > > > > > > is
> > > > > > > > > >> the
> > > > > > > > > >> > > > first
> > > > > > > > > >> > > > >> > > member
> > > > > > > > > >> > > > >> > > > in the group (e.g. when IDs are sorted
> > > > > > > > > lexicographically).
> > > > > > > > > >> > That
> > > > > > > > > >> > > > >> member
> > > > > > > > > >> > > > >> > is
> > > > > > > > > >> > > > >> > > > selected as the writer. In that case, we
> > > > actually
> > > > > > > just
> > > > > > > > > care
> > > > > > > > > >> > > about
> > > > > > > > > >> > > > >> the
> > > > > > > > > >> > > > >> > > > membership list, there's no additional
> info
> > > > about
> > > > > > > each
> > > > > > > > > >> member
> > > > > > > > > >> > > that
> > > > > > > > > >> > > > >> is
> > > > > > > > > >> > > > >> > > > required to determine who is the writer.
> > > > > > > > > >> > > > >> > > >
> > > > > > > > > >> > > > >> > > >
> > > > > > > > > >> > > > >> > > > > 3. Do you mean that the number of
> > > partitions
> > > > in
> > > > > > > > > >> > > > JoinGroupResponse
> > > > > > > > > >> > > > >> > will
> > > > > > > > > >> > > > >> > > be
> > > > > > > > > >> > > > >> > > > > the max partition number of a topic
> among
> > > all
> > > > > the
> > > > > > > > > >> reported
> > > > > > > > > >> > > > >> partition
> > > > > > > > > >> > > > >> > > > number
> > > > > > > > > >> > > > >> > > > > by consumers? Is there any reason not
> > just
> > > > let
> > > > > > > > > >> Coordinator
> > > > > > > > > >> > to
> > > > > > > > > >> > > > >> return
> > > > > > > > > >> > > > >> > > the
> > > > > > > > > >> > > > >> > > > > number of partitions of a topic in its
> > > > metadata
> > > > > > > > cache?
> > > > > > > > > >> > > > >> > > > >
> > > > > > > > > >> > > > >> > > >
> > > > > > > > > >> > > > >> > > > Nothing from the embedded protocol is
> > touched
> > > > by
> > > > > > the
> > > > > > > > > >> broker.
> > > > > > > > > >> > The
> > > > > > > > > >> > > > >> broker
> > > > > > > > > >> > > > >> > > > just collects opaque bytes of metadata,
> > does
> > > > the
> > > > > > > > > selection
> > > > > > > > > >> of
> > > > > > > > > >> > > the
> > > > > > > > > >> > > > >> > > strategy
> > > > > > > > > >> > > > >> > > > if multiple are supported by some
> > consumers,
> > > > and
> > > > > > then
> > > > > > > > > >> returns
> > > > > > > > > >> > > that
> > > > > > > > > >> > > > >> > opaque
> > > > > > > > > >> > > > >> > > > metadata for all the members back to
> every
> > > > > member.
> > > > > > In
> > > > > > > > > that
> > > > > > > > > >> way
> > > > > > > > > >> > > > they
> > > > > > > > > >> > > > >> all
> > > > > > > > > >> > > > >> > > > have a consistent view of the group. For
> > > > regular
> > > > > > > > > consumers,
> > > > > > > > > >> > that
> > > > > > > > > >> > > > >> view
> > > > > > > > > >> > > > >> > of
> > > > > > > > > >> > > > >> > > > the group includes information about how
> > many
> > > > > > > > partitions
> > > > > > > > > >> each
> > > > > > > > > >> > > > >> consumer
> > > > > > > > > >> > > > >> > > > currently thinks the topics it is
> > subscribed
> > > to
> > > > > > has.
> > > > > > > > > These
> > > > > > > > > >> > could
> > > > > > > > > >> > > > be
> > > > > > > > > >> > > > >> > > > inconsistent due to out of date metadata
> > and
> > > it
> > > > > > would
> > > > > > > > be
> > > > > > > > > >> up to
> > > > > > > > > >> > > the
> > > > > > > > > >> > > > >> > > > assignment strategy on the *client* to
> > > resolve
> > > > > > that.
> > > > > > > As
> > > > > > > > > you
> > > > > > > > > >> > > point
> > > > > > > > > >> > > > >> out,
> > > > > > > > > >> > > > >> > in
> > > > > > > > > >> > > > >> > > > that case they could just take the max
> > value
> > > > that
> > > > > > any
> > > > > > > > > >> consumer
> > > > > > > > > >> > > > >> reported
> > > > > > > > > >> > > > >> > > > seeing and use that. The consumers that
> > > notice
> > > > > that
> > > > > > > > their
> > > > > > > > > >> > > metadata
> > > > > > > > > >> > > > >> had
> > > > > > > > > >> > > > >> > a
> > > > > > > > > >> > > > >> > > > smaller # of partitions should also
> > trigger a
> > > > > > > metadata
> > > > > > > > > >> update
> > > > > > > > > >> > > when
> > > > > > > > > >> > > > >> they
> > > > > > > > > >> > > > >> > > see
> > > > > > > > > >> > > > >> > > > someone else observing a larger # of
> > > > partitions.
> > > > > > > > > >> > > > >> > > >
> > > > > > > > > >> > > > >> > > >
> > > > > > > > > >> > > > >> > > > >
> > > > > > > > > >> > > > >> > > > > Thanks,
> > > > > > > > > >> > > > >> > > > >
> > > > > > > > > >> > > > >> > > > > Jiangjie (Becket) Qin
> > > > > > > > > >> > > > >> > > > >
> > > > > > > > > >> > > > >> > > > >
> > > > > > > > > >> > > > >> > > > >
> > > > > > > > > >> > > > >> > > > >
> > > > > > > > > >> > > > >> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason
> > > > > Gustafson
> > > > > > <
> > > > > > > > > >> > > > >> jason@confluent.io
> > > > > > > > > >> > > > >> > >
> > > > > > > > > >> > > > >> > > > > wrote:
> > > > > > > > > >> > > > >> > > > >
> > > > > > > > > >> > > > >> > > > > > Hi Kafka Devs,
> > > > > > > > > >> > > > >> > > > > >
> > > > > > > > > >> > > > >> > > > > > One of the nagging issues in the
> > current
> > > > > design
> > > > > > > of
> > > > > > > > > the
> > > > > > > > > >> new
> > > > > > > > > >> > > > >> consumer
> > > > > > > > > >> > > > >> > > has
> > > > > > > > > >> > > > >> > > > > > been the need to support a variety of
> > > > > > assignment
> > > > > > > > > >> > strategies.
> > > > > > > > > >> > > > >> We've
> > > > > > > > > >> > > > >> > > > > > encountered this in particular in the
> > > > design
> > > > > of
> > > > > > > > > copycat
> > > > > > > > > >> > and
> > > > > > > > > >> > > > the
> > > > > > > > > >> > > > >> > > > > processing
> > > > > > > > > >> > > > >> > > > > > framework (KIP-28). From what I
> > > understand,
> > > > > > Samza
> > > > > > > > > also
> > > > > > > > > >> > has a
> > > > > > > > > >> > > > >> number
> > > > > > > > > >> > > > >> > > of
> > > > > > > > > >> > > > >> > > > > use
> > > > > > > > > >> > > > >> > > > > > cases with custom assignment needs.
> The
> > > new
> > > > > > > > consumer
> > > > > > > > > >> > > protocol
> > > > > > > > > >> > > > >> > > supports
> > > > > > > > > >> > > > >> > > > > new
> > > > > > > > > >> > > > >> > > > > > assignment strategies by hooking them
> > > into
> > > > > the
> > > > > > > > > broker.
> > > > > > > > > >> For
> > > > > > > > > >> > > > many
> > > > > > > > > >> > > > >> > > > > > environments, this is a major pain
> and
> > in
> > > > > some
> > > > > > > > > cases, a
> > > > > > > > > >> > > > >> > non-starter.
> > > > > > > > > >> > > > >> > > It
> > > > > > > > > >> > > > >> > > > > > also challenges the validation that
> the
> > > > > > > coordinator
> > > > > > > > > can
> > > > > > > > > >> > > > provide.
> > > > > > > > > >> > > > >> > For
> > > > > > > > > >> > > > >> > > > > > example, some assignment strategies
> > call
> > > > for
> > > > > > > > > >> partitions to
> > > > > > > > > >> > > be
> > > > > > > > > >> > > > >> > > assigned
> > > > > > > > > >> > > > >> > > > > > multiple times, which means that the
> > > > > > coordinator
> > > > > > > > can
> > > > > > > > > >> only
> > > > > > > > > >> > > > check
> > > > > > > > > >> > > > >> > that
> > > > > > > > > >> > > > >> > > > > > partitions have been assigned at
> least
> > > > once.
> > > > > > > > > >> > > > >> > > > > >
> > > > > > > > > >> > > > >> > > > > > To solve these issues, we'd like to
> > > propose
> > > > > > > moving
> > > > > > > > > >> > > assignment
> > > > > > > > > >> > > > to
> > > > > > > > > >> > > > >> > the
> > > > > > > > > >> > > > >> > > > > > client. I've written a wiki which
> > > outlines
> > > > > some
> > > > > > > > > >> protocol
> > > > > > > > > >> > > > >> changes to
> > > > > > > > > >> > > > >> > > > > achieve
> > > > > > > > > >> > > > >> > > > > > this:
> > > > > > > > > >> > > > >> > > > > >
> > > > > > > > > >> > > > >> > > > > >
> > > > > > > > > >> > > > >> > > > >
> > > > > > > > > >> > > > >> > > >
> > > > > > > > > >> > > > >> > >
> > > > > > > > > >> > > > >> >
> > > > > > > > > >> > > > >>
> > > > > > > > > >> > > >
> > > > > > > > > >> > >
> > > > > > > > > >> >
> > > > > > > > > >>
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> > > > > > > > > >> > > > >> > > > > > .
> > > > > > > > > >> > > > >> > > > > > To summarize briefly, instead of the
> > > > > > coordinator
> > > > > > > > > >> assigning
> > > > > > > > > >> > > the
> > > > > > > > > >> > > > >> > > > partitions
> > > > > > > > > >> > > > >> > > > > > itself, all subscriptions are
> forwarded
> > > to
> > > > > each
> > > > > > > > > member
> > > > > > > > > >> of
> > > > > > > > > >> > > the
> > > > > > > > > >> > > > >> group
> > > > > > > > > >> > > > >> > > > which
> > > > > > > > > >> > > > >> > > > > > then decides independently which
> > > partitions
> > > > > it
> > > > > > > > should
> > > > > > > > > >> > > consume.
> > > > > > > > > >> > > > >> The
> > > > > > > > > >> > > > >> > > > > protocol
> > > > > > > > > >> > > > >> > > > > > provides a mechanism for the
> > coordinator
> > > to
> > > > > > > > validate
> > > > > > > > > >> that
> > > > > > > > > >> > > all
> > > > > > > > > >> > > > >> > > consumers
> > > > > > > > > >> > > > >> > > > > use
> > > > > > > > > >> > > > >> > > > > > the same assignment strategy, but it
> > does
> > > > not
> > > > > > > > ensure
> > > > > > > > > >> that
> > > > > > > > > >> > > the
> > > > > > > > > >> > > > >> > > resulting
> > > > > > > > > >> > > > >> > > > > > assignment is "correct." This
> provides
> > a
> > > > > > powerful
> > > > > > > > > >> > capability
> > > > > > > > > >> > > > for
> > > > > > > > > >> > > > >> > > users
> > > > > > > > > >> > > > >> > > > to
> > > > > > > > > >> > > > >> > > > > > control the full data flow on the
> > client
> > > > > side.
> > > > > > > They
> > > > > > > > > >> > control
> > > > > > > > > >> > > > how
> > > > > > > > > >> > > > >> > data
> > > > > > > > > >> > > > >> > > is
> > > > > > > > > >> > > > >> > > > > > written to partitions through the
> > > > Partitioner
> > > > > > > > > interface
> > > > > > > > > >> > and
> > > > > > > > > >> > > > they
> > > > > > > > > >> > > > >> > > > control
> > > > > > > > > >> > > > >> > > > > > how data is consumed through the
> > > assignment
> > > > > > > > strategy,
> > > > > > > > > >> all
> > > > > > > > > >> > > > >> without
> > > > > > > > > >> > > > >> > > > > touching
> > > > > > > > > >> > > > >> > > > > > the server.
> > > > > > > > > >> > > > >> > > > > >
> > > > > > > > > >> > > > >> > > > > > Of course nothing comes for free. In
> > > > > > particular,
> > > > > > > > this
> > > > > > > > > >> > change
> > > > > > > > > >> > > > >> > removes
> > > > > > > > > >> > > > >> > > > the
> > > > > > > > > >> > > > >> > > > > > ability of the coordinator to
> validate
> > > that
> > > > > > > commits
> > > > > > > > > are
> > > > > > > > > >> > made
> > > > > > > > > >> > > > by
> > > > > > > > > >> > > > >> > > > consumers
> > > > > > > > > >> > > > >> > > > > > who were assigned the respective
> > > partition.
> > > > > > This
> > > > > > > > > might
> > > > > > > > > >> not
> > > > > > > > > >> > > be
> > > > > > > > > >> > > > >> too
> > > > > > > > > >> > > > >> > bad
> > > > > > > > > >> > > > >> > > > > since
> > > > > > > > > >> > > > >> > > > > > we retain the ability to validate the
> > > > > > generation
> > > > > > > > id,
> > > > > > > > > >> but
> > > > > > > > > >> > it
> > > > > > > > > >> > > > is a
> > > > > > > > > >> > > > >> > > > > potential
> > > > > > > > > >> > > > >> > > > > > concern. We have considered
> alternative
> > > > > > protocols
> > > > > > > > > which
> > > > > > > > > >> > add
> > > > > > > > > >> > > a
> > > > > > > > > >> > > > >> > second
> > > > > > > > > >> > > > >> > > > > > round-trip to the protocol in order
> to
> > > give
> > > > > the
> > > > > > > > > >> > coordinator
> > > > > > > > > >> > > > the
> > > > > > > > > >> > > > >> > > ability
> > > > > > > > > >> > > > >> > > > > to
> > > > > > > > > >> > > > >> > > > > > confirm the assignment. As mentioned
> > > above,
> > > > > the
> > > > > > > > > >> > coordinator
> > > > > > > > > >> > > is
> > > > > > > > > >> > > > >> > > somewhat
> > > > > > > > > >> > > > >> > > > > > limited in what it can actually
> > validate,
> > > > but
> > > > > > > this
> > > > > > > > > >> would
> > > > > > > > > >> > > > return
> > > > > > > > > >> > > > >> its
> > > > > > > > > >> > > > >> > > > > ability
> > > > > > > > > >> > > > >> > > > > > to validate commits. The tradeoff is
> > that
> > > > it
> > > > > > > > > increases
> > > > > > > > > >> the
> > > > > > > > > >> > > > >> > protocol's
> > > > > > > > > >> > > > >> > > > > > complexity which means more ways for
> > the
> > > > > > protocol
> > > > > > > > to
> > > > > > > > > >> fail
> > > > > > > > > >> > > and
> > > > > > > > > >> > > > >> > > > > consequently
> > > > > > > > > >> > > > >> > > > > > more edge cases in the code.
> > > > > > > > > >> > > > >> > > > > >
> > > > > > > > > >> > > > >> > > > > > It also misses an opportunity to
> > > generalize
> > > > > the
> > > > > > > > group
> > > > > > > > > >> > > > membership
> > > > > > > > > >> > > > >> > > > protocol
> > > > > > > > > >> > > > >> > > > > > for additional use cases. In fact,
> > after
> > > > > you've
> > > > > > > > gone
> > > > > > > > > to
> > > > > > > > > >> > the
> > > > > > > > > >> > > > >> trouble
> > > > > > > > > >> > > > >> > > of
> > > > > > > > > >> > > > >> > > > > > moving assignment to the client, the
> > main
> > > > > thing
> > > > > > > > that
> > > > > > > > > is
> > > > > > > > > >> > left
> > > > > > > > > >> > > > in
> > > > > > > > > >> > > > >> > this
> > > > > > > > > >> > > > >> > > > > > protocol is basically a general group
> > > > > > management
> > > > > > > > > >> > capability.
> > > > > > > > > >> > > > >> This
> > > > > > > > > >> > > > >> > is
> > > > > > > > > >> > > > >> > > > > > exactly what is needed for a few
> cases
> > > that
> > > > > are
> > > > > > > > > >> currently
> > > > > > > > > >> > > > under
> > > > > > > > > >> > > > >> > > > > discussion
> > > > > > > > > >> > > > >> > > > > > (e.g. copycat or single-writer
> > producer).
> > > > > We've
> > > > > > > > taken
> > > > > > > > > >> this
> > > > > > > > > >> > > > >> further
> > > > > > > > > >> > > > >> > > step
> > > > > > > > > >> > > > >> > > > > in
> > > > > > > > > >> > > > >> > > > > > the proposal and attempted to
> envision
> > > what
> > > > > > that
> > > > > > > > > >> general
> > > > > > > > > >> > > > >> protocol
> > > > > > > > > >> > > > >> > > might
> > > > > > > > > >> > > > >> > > > > > look like and how it could be used
> both
> > > by
> > > > > the
> > > > > > > > > consumer
> > > > > > > > > >> > and
> > > > > > > > > >> > > > for
> > > > > > > > > >> > > > >> > some
> > > > > > > > > >> > > > >> > > of
> > > > > > > > > >> > > > >> > > > > > these other cases.
> > > > > > > > > >> > > > >> > > > > >
> > > > > > > > > >> > > > >> > > > > > Anyway, since time is running out on
> > the
> > > > new
> > > > > > > > > consumer,
> > > > > > > > > >> we
> > > > > > > > > >> > > have
> > > > > > > > > >> > > > >> > > perhaps
> > > > > > > > > >> > > > >> > > > > one
> > > > > > > > > >> > > > >> > > > > > last chance to consider a significant
> > > > change
> > > > > in
> > > > > > > the
> > > > > > > > > >> > protocol
> > > > > > > > > >> > > > >> like
> > > > > > > > > >> > > > >> > > this,
> > > > > > > > > >> > > > >> > > > > so
> > > > > > > > > >> > > > >> > > > > > have a look at the wiki and share
> your
> > > > > > thoughts.
> > > > > > > > I've
> > > > > > > > > >> no
> > > > > > > > > >> > > doubt
> > > > > > > > > >> > > > >> that
> > > > > > > > > >> > > > >> > > > some
> > > > > > > > > >> > > > >> > > > > > ideas seem clearer in my mind than
> they
> > > do
> > > > on
> > > > > > > > paper,
> > > > > > > > > so
> > > > > > > > > >> > ask
> > > > > > > > > >> > > > >> > questions
> > > > > > > > > >> > > > >> > > > if
> > > > > > > > > >> > > > >> > > > > > there is any confusion.
> > > > > > > > > >> > > > >> > > > > >
> > > > > > > > > >> > > > >> > > > > > Thanks!
> > > > > > > > > >> > > > >> > > > > > Jason
> > > > > > > > > >> > > > >> > > > > >
> > > > > > > > > >> > > > >> > > > >
> > > > > > > > > >> > > > >> > > >
> > > > > > > > > >> > > > >> > > >
> > > > > > > > > >> > > > >> > > >
> > > > > > > > > >> > > > >> > > > --
> > > > > > > > > >> > > > >> > > > Thanks,
> > > > > > > > > >> > > > >> > > > Ewen
> > > > > > > > > >> > > > >> > > >
> > > > > > > > > >> > > > >> > >
> > > > > > > > > >> > > > >> >
> > > > > > > > > >> > > > >> >
> > > > > > > > > >> > > > >> >
> > > > > > > > > >> > > > >> > --
> > > > > > > > > >> > > > >> > Thanks,
> > > > > > > > > >> > > > >> > Ewen
> > > > > > > > > >> > > > >> >
> > > > > > > > > >> > > > >>
> > > > > > > > > >> > > > >
> > > > > > > > > >> > > > >
> > > > > > > > > >> > > >
> > > > > > > > > >> > >
> > > > > > > > > >> >
> > > > > > > > > >>
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > --
> > > > > > > > > > Thanks,
> > > > > > > > > > Neha
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > > Thanks,
> > > > > > > > > Neha
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > Thanks,
> > > > > > > > Ewen
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Thanks,
> > > > > > Ewen
> > > > > >
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Thanks,
> > > Neha
> > >
> >
>
>
>
> --
> Thanks,
> Neha
>

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Neha Narkhede <ne...@confluent.io>.
Hey Becket,

These are all fair points. Regarding running Kafka as a service, it will be
good for everyone to know some numbers around topic creation and changes
around # of partitions. I don't think the test usage is a good one since no
one should be creating and deleting topics in a loop on a production
cluster.

Regarding your point about mirror maker, I think we should definitely
ensure that a mirror maker with a large topic subscription list should be
well supported. The reason for the half an hour stalls in LinkedIn mirror
makers is due to the fact that it still uses the old consumer. The 3 major
reasons for long rebalance operations in the mirror maker using the old
consumer are -
1. Every rebalance operation involves many writes to ZK. For large consumer
groups and large number of partitions, this adds up to several seconds
2. The view of the members in a group is inconsistent and hence there are
typically several rebalance attempts. Note that this is fixed in the new
design where the group membership is always consistently communicated to
all members.
3. The rebalance backoff time is high (of the order of seconds).

The good news is that the new design has none of these problems. As we
said, we will run some tests to ensure that the mirror maker case is
handled well. Thank you for the feedback!

Thanks,
Neha

On Sat, Aug 15, 2015 at 6:17 PM, Jiangjie Qin <jq...@linkedin.com.invalid>
wrote:

> Neha, Ewen and Jason,
>
> Maybe I am over concerning and I agree that it does depend on the metadata
> change frequency. As Neha said, a few tests will be helpful. We can see how
> it goes.
>
> What worries me is that in LinkedIn we are in the progress of running Kafka
> as a service. That means user will have the ability to create/delete topics
> and update their topic configurations programmatically or through UI using
> LinkedIn internal cloud service platform. And some automated test will also
> be consistently running to create topic, produce/consume some data, then
> clean up the topics. This brings us some new challenges for mirror maker
> because we need to make sure it actually copies data instead of spending
> too much time on rebalance. As what we see now is that each rebalance will
> probably take 30 seconds or more to finish even with some tricks and
> tuning.
>
> Another related use case I want to bring up is that today when we want to
> do a rolling upgrade of mirror maker (26 nodes), there will be two rounds
> of rebalance to bounce each node, each rebalance takes about 30 seconds. So
> bouncing 26 nodes takes roughly half an hour. Awkwardly, during the rolling
> bounce, because mirror maker is keeping rebalancing, it actually does not
> really copy any data! So the pipeline will literally stall for half an
> hour! Since we are designing the new protocol, it will also be good it we
> make sure this use case is addressed.
>
> Thanks,
>
> Jiangjie (Becket) Qin
>
> On Sat, Aug 15, 2015 at 10:50 AM, Neha Narkhede <ne...@confluent.io> wrote:
>
> > Becket,
> >
> > This is a clever approach for to ensure that only one thing communicates
> > the metadata so even if it is stale, the entire group has the same view.
> > However, the big assumption this makes is that the coordinator is that
> one
> > process that has the ability to know the metadata for group members,
> which
> > does not work for any non-consumer use case.
> >
> > I wonder if we may be complicating the design of 95% use cases for the
> > remaining 5%. For instance, how many times do people create and remove
> > topics or even add partitions? We operated LI clusters for a long time
> and
> > this wasn't a frequent event that would need us to optimize this design
> > for.
> >
> > Also, this is something we can easily validate by running a few tests on
> > the patch and I suggest we wait for that.
> >
> > Thanks,
> > Neha
> >
> > On Sat, Aug 15, 2015 at 9:14 AM, Jason Gustafson <ja...@confluent.io>
> > wrote:
> >
> > > Hey Jiangjie,
> > >
> > > I was thinking about the same problem. When metadata is changing
> > > frequently, the clients may not be able to ever find agreement on the
> > > current state. The server doesn't have this problem, as you say,
> because
> > it
> > > can just take a snapshot and send that to the clients. Adding a
> dampening
> > > setting to the client would help if churn is sporadic, but not if it is
> > > steady. I think the metadata would have to be changing really
> frequently
> > > for this to be a problem practically, but this is a case where the
> > > server-side approach has an advantage.
> > >
> > > Including the metadata in the join group response would require making
> > the
> > > subscription available to the coordinator, right? We lose a little bit
> of
> > > the generality of the protocol, but it might not be too bad since most
> > use
> > > cases for reusing this protocol have a similar need for metadata (and
> > they
> > > can always pass an empty subscription if they don't). We've gone back
> and
> > > forth a few times on this, and I'm generally not opposed. It might help
> > if
> > > we try to quantify the impact of the metadata churn in practice. I
> think
> > > the rate of change would have to be in the low seconds for this to be a
> > > real problem. It does seem nice though that we have a way to manage
> even
> > > this much churn when we do this.
> > >
> > > -Jason
> > >
> > >
> > >
> > > On Fri, Aug 14, 2015 at 9:03 PM, Jiangjie Qin
> <jqin@linkedin.com.invalid
> > >
> > > wrote:
> > >
> > > > Ewen,
> > > >
> > > > I agree that if there is a churn in metadata, the consumers need
> > several
> > > > rounds of rebalances to succeed. The difference I am thinking is that
> > > with
> > > > coordinator as single source of truth, we can let the consumer finish
> > one
> > > > round of rebalance, work for a while and start the next round of
> > > rebalance.
> > > > If we purely depend on the consumers to synchronize by themselves
> based
> > > on
> > > > different metadata sources, is it possible we have some groups
> > spending a
> > > > lot of time on rebalancing but not able to make too much progress in
> > > > consuming?
> > > >
> > > > I'm thinking can we let consumers to fetch metadata only from their
> > > > coordinator? So the rebalance can be done in the following way:
> > > >
> > > > 1. Consumers refresh their metadata periodically
> > > > 2. If one of the consumer sees a change in metadata that triggers a
> > > > rebalance, it sends JoinGroupRequest to coordinator.
> > > > 3. Once the coordinator receives the first JoinGroupRequest of a
> group,
> > > it
> > > > takes a snapshot of current metadata and the group enters
> > > prepare-rebalance
> > > > state.
> > > > 4. The metadata snapshot will be used for this round of rebalance.
> i.e.
> > > the
> > > > metadata snapshot will be sent to consumers in JoinGroupResponse.
> > > > 4.1 If the consumers are subscribing to explicit topic lists (not
> > regex),
> > > > the JoinGroupResponse needs only contain the metadata of all topics
> the
> > > > group is interested.
> > > > 4.2 If the consumers are subscribing using regex, all the topic
> > metadata
> > > > will be returned to the consumer.
> > > > 5. Consumers get JoinGroupResponse, refresh metadata using the
> metadata
> > > in
> > > > JoinGroupResponse, run algorithm to assign partitions and start
> > consume.
> > > > 6. Go back to 1.
> > > >
> > > > The benefit here is that we can let rebalance finish in one round,
> and
> > > all
> > > > the rest of changes will be captured in next consumer metadata
> refresh
> > -
> > > so
> > > > we get group commit. One concern might be letting consumer refresh
> > > metadata
> > > > from coordinator might cause issue for big consumer groups. Maybe
> that
> > is
> > > > OK because metadata refresh is infrequent.
> > > >
> > > > This approach actually is very similar to what is proposed now:
> > rebalance
> > > > is triggered by metadata refresh, consumer provides subscription list
> > to
> > > > pass around. The only difference is that we don't need metadata hash
> > > > anymore because the metadata is guaranteed to be the same. Replacing
> > > > metadata hash with actual metadata will not have too much overhead
> for
> > > > small subscription groups. There will be some overhead for regex
> > > > subscriptions, but this can save the potential extra round of
> metadata
> > > > fetch and will only occur when consumer see metadata change, which is
> > > > infrequent.
> > > >
> > > > Any thoughts?
> > > >
> > > > Thanks,
> > > >
> > > > Jiangjie (Becket) Qin
> > > >
> > > >
> > > > On Fri, Aug 14, 2015 at 12:57 PM, Ewen Cheslack-Postava <
> > > ewen@confluent.io
> > > > >
> > > > wrote:
> > > >
> > > > > On Fri, Aug 14, 2015 at 10:59 AM, Jiangjie Qin
> > > <jqin@linkedin.com.invalid
> > > > >
> > > > > wrote:
> > > > >
> > > > > > Neha and Ewen,
> > > > > >
> > > > > > About the metadata change frequency. I guess it really depends on
> > how
> > > > > > frequent the metadata change might occur. If we run Kafka as a
> > > > service, I
> > > > > > can see that happens from time to time. As I can imagine people
> > will
> > > > > create
> > > > > > some topic, test and maybe delete the topic in some automated
> test.
> > > If
> > > > > so,
> > > > > > the proposed protocol might be a little bit vulnerable.
> > > > > >
> > > > > > More specifically the scenario I am thinking is:
> > > > > > 1. Consumer 0 periodically refresh metadata and detected a
> metadata
> > > > > change.
> > > > > > So it sends a JoinGroupRequest with metadata_hash_0.
> > > > > > 2. Consumer 1 was notified by controller to start a rebalance, so
> > it
> > > > > > refreshes its metadata and send a JoingGroupRequest with
> > > > metadata_hash_1,
> > > > > > which is different from metadata hash 0.
> > > > > > 3. Rebalance failed and both consumer refresh there metadata
> again
> > > from
> > > > > > different brokers.
> > > > > > 4. Depending on the metadata change frequency(or some admin
> > operation
> > > > > like
> > > > > > partition reassigment), they may or may not have the same
> metadata
> > > > > > returned, so the restart from 3 again.
> > > > > >
> > > > > > I agree that step 4 might not be a big concern if consumers
> updates
> > > > > > metadata at almost the same time, but I'm a little bit worried
> > > whether
> > > > > that
> > > > > > assumption really stands because we do not have control over how
> > > > frequent
> > > > > > the metadata can change.
> > > > > >
> > > > > >
> > > > > Is this really that different from what would happen if the
> > coordinator
> > > > > distributed the metadata to consumers? In that case you would
> > trivially
> > > > > have everyone in a consistent state, but those metadata changes
> would
> > > > still
> > > > > cause churn and require JoinGroup rounds, during which processing
> is
> > > > > stalled for the nodes that are waiting on other members to re-join
> > the
> > > > > group.
> > > > >
> > > > > -Ewen
> > > > >
> > > > >
> > > > > > Thanks,
> > > > > >
> > > > > > Jiangjie (Becket) Qin
> > > > > >
> > > > > > On Fri, Aug 14, 2015 at 2:03 AM, Ewen Cheslack-Postava <
> > > > > ewen@confluent.io>
> > > > > > wrote:
> > > > > >
> > > > > > > On Thu, Aug 13, 2015 at 11:07 PM, Neha Narkhede <
> > neha@confluent.io
> > > >
> > > > > > wrote:
> > > > > > >
> > > > > > > > Becket,
> > > > > > > >
> > > > > > > > As you say, the metadata hash addresses the concern you
> > > originally
> > > > > > raised
> > > > > > > > about large topic subscriptions. Can you please list other
> > > problems
> > > > > you
> > > > > > > are
> > > > > > > > raising more clearly? It is more helpful to know problems
> that
> > > the
> > > > > > > proposal
> > > > > > > > does not address or addresses poorly.
> > > > > > > >
> > > > > > > > Regarding other things you said -
> > > > > > > >
> > > > > > > > it is required that each
> > > > > > > > > consumer refresh their metadata before sending a
> > > JoinGroupRequest
> > > > > > > > >
> > > > > > > >
> > > > > > > > This is required for wildcard topic subscriptions anyway. So
> > this
> > > > > > > proposal
> > > > > > > > does not introduce a regression. We had agreed earlier that
> it
> > > does
> > > > > not
> > > > > > > > make sense for the server to deserialize regular expressions
> > sent
> > > > by
> > > > > > the
> > > > > > > > consumer.
> > > > > > > >
> > > > > > >
> > > > > > > I don't think consumers need to do a metadata refresh before
> > > sending
> > > > a
> > > > > > > JoinGroupRequest. Metadata changes that affect assignment are
> > rare
> > > --
> > > > > it
> > > > > > > requires changing the number of partitions in a topic. But you
> > > might
> > > > > > send a
> > > > > > > JoinGroupRequest simply because a new member is trying to join
> > the
> > > > > group.
> > > > > > > That case is presumably much more common.
> > > > > > >
> > > > > > > I think it's actually a good idea to have the first JoinGroup
> > cycle
> > > > > fail
> > > > > > in
> > > > > > > some cases, and has little impact. Lets say the metadata does
> > > change
> > > > > > > because partitions are added. Then we might fail in the first
> > > round,
> > > > > but
> > > > > > > then all members detect that issue *immediately*, refresh their
> > > > > metadata,
> > > > > > > and submit a new join group request. This second cycle does not
> > > > > require a
> > > > > > > full heartbeat cycle. It happens much more quickly because
> > everyone
> > > > > > > detected the inconsistency based on the first
> JoinGroupResponse.
> > > The
> > > > > > > inconsistency should be resolved very quickly (barring other
> > > failures
> > > > > > like
> > > > > > > a member leaving mid-rebalance)
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > > the metadata might still be inconsistent if there is a
> topic
> > or
> > > > > > > partition
> > > > > > > > > change because the
> > > > > > > > > UpdateMetadataRequest from controller might be handled at
> > > > different
> > > > > > > time.
> > > > > > > > >
> > > > > > > >
> > > > > > > > Topic metadata does not change frequently and even if it
> did, a
> > > > > couple
> > > > > > > > rebalance attempts will be needed whether the coordinator
> > drives
> > > > the
> > > > > > > > assignments or the consumer. Because guess how the
> coordinator
> > > > knows
> > > > > > > about
> > > > > > > > the topic metadata changes -- indirectly through either a zk
> > > > callback
> > > > > > or
> > > > > > > > UpdateMetadataRequest, so it is completely possible the
> > > coordinator
> > > > > > sees
> > > > > > > > the topic metadata changes in batches, not all at once.
> > > > > > > >
> > > > > > >
> > > > > > > > On Thu, Aug 13, 2015 at 10:50 PM, Neha Narkhede <
> > > neha@confluent.io
> > > > >
> > > > > > > wrote:
> > > > > > > >
> > > > > > > > > Ewen/Jason,
> > > > > > > > >
> > > > > > > > > The metadata hash is a clever approach and certainly
> > addresses
> > > > the
> > > > > > > > problem
> > > > > > > > > of large metadata for consumers like mirror maker. Few
> > > comments -
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >    1. In the interest of simplifying the format of the
> > > consumer's
> > > > > > > > >    metadata - Why not just always include only the topic
> > names
> > > in
> > > > > the
> > > > > > > > metadata
> > > > > > > > >    followed by the metadata hash? If the metadata hash
> check
> > > > > > succeeds,
> > > > > > > > each
> > > > > > > > >    consumer uses the # of partitions it had fetched. If it
> > > > fails, a
> > > > > > > > rebalance
> > > > > > > > >    happens and the metadata is not used anyway.
> > > > > > > >
> > > > > > >
> > > > > > > Doing this requires that every consumer always fetch the full
> > > > metadata.
> > > > > > The
> > > > > > > most common use case is consumers that just want to consume one
> > or
> > > a
> > > > > > couple
> > > > > > > of topics, in which case grabbing all metadata for the entire
> > > cluster
> > > > > is
> > > > > > > wasteful. If I subscribe only to topic A, why make all
> consumers
> > > grab
> > > > > > > metadata for the entire topic (and need to rebalance every time
> > it
> > > > > > > changes!). Including the # of partitions for each topic lets
> you
> > > > avoid
> > > > > > > having to grab the global set of metadata.
> > > > > > >
> > > > > > > So if you're just subscribing to one or a couple of topics, why
> > not
> > > > > just
> > > > > > > compute the hash by filtering out everything but the topics you
> > are
> > > > > > > subscribed to? The problem there is if you ever add/remove
> > > > > subscriptions
> > > > > > > and want to support rolling upgrades. If the group was
> subscribed
> > > to
> > > > > > topic
> > > > > > > A, but later changes require subscribing to A + B, then to
> > achieve
> > > a
> > > > > > > seamless rolling upgrade would require one (old) consumer to be
> > > > > > subscribing
> > > > > > > to A and one (new) consumer to be subscribing to A+B. If we
> > > computed
> > > > > > > metadata hashes based on filtered metadata, those two would
> > > disagree
> > > > > and
> > > > > > we
> > > > > > > could not perform assignment while the upgrade was in progress.
> > > > > > >
> > > > > > > The solution is to differentiate between the cases when a very
> > > small
> > > > > > amount
> > > > > > > of the metadata is needed (one or a couple of topic
> > subscriptions;
> > > > > > > communicate and share this via metadata in the JoinGroup
> > protocol)
> > > vs
> > > > > > when
> > > > > > > *all* the metadata is needed (regex subscription; verify
> > agreement
> > > > via
> > > > > > > hash).
> > > > > > >
> > > > > >
> > > > > > >
> > > > > > >
> > > > > > > > >    2. Do you need a topic list and topic regex to be
> > separate?
> > > A
> > > > > > single
> > > > > > > > >    topic or list of topics can be expressed as a regex.
> > > > > > > >
> > > > > > >
> > > > > > > See above note about collecting all metadata when you really
> only
> > > > need
> > > > > it
> > > > > > > for 1 or 2 topics. There's probably some debate to be had about
> > > > whether
> > > > > > > this cost would be too high -- every consumer would need to
> > request
> > > > the
> > > > > > > metadata for all topics, and they'd need to request that all
> > every
> > > > time
> > > > > > > they might be out of date.
> > > > > > >
> > > > > > Are we going to allow consumers in the same group to subscribe to
> > > > > different
> > > > > > topic set? If we do, we need to let them refresh metadata for all
> > the
> > > > > > topics a group is consuming from. If we don't then in the
> protocol
> > we
> > > > > only
> > > > > > need a subscription set hash.
> > > > > >
> > > > > > >
> > > > > > >
> > > > > > > > >    3. Let's include a version explicitly at the beginning
> of
> > > the
> > > > > > > > >    ProtocolMetadata. The version dictates how to
> deserialize
> > > the
> > > > > > > > >    ProtocolMetadata blob and is consistent with the rest of
> > > > Kafka.
> > > > > > > >
> > > > > > >
> > > > > > > If I'm understanding correctly, in JoinGroupRequest I would
> > change
> > > > > > >
> > > > > > > GroupProtocols          => [Protocol ProtocolMetadata]
> > > > > > >
> > > > > > > to
> > > > > > >
> > > > > > > GroupProtocols          => [Protocol ProtocolVersion
> > > > ProtocolMetadata]
> > > > > > >
> > > > > > > We had been talking about just baking the version into the
> > Protocol
> > > > > > field,
> > > > > > > but making it separate seems perfectly reasonable to me. Jason,
> > any
> > > > > issue
> > > > > > > with splitting the version out into a separate field like this?
> > > > > > >
> > > > > > > >
> > > > > > > > > That can simplify the metadata format to the following:
> > > > > > > > >
> > > > > > > > > GroupType => "consumer"
> > > > > > > > >>
> > > > > > > > >> Protocol => AssignmentStrategy
> > > > > > > > >>   AssignmentStrategy   => String
> > > > > > > > >>
> > > > > > > > >> ProtocolMetadata => Version Subscription
> > > > > AssignmentStrategyMetadata
> > > > > > > > >
> > > > > > > > >     Version                    => String
> > > > > > > > >
> > > > > > > > >   Subscription                 => TopicRegex MetadataHash
> > > > > > > > >>     TopicRegex                 => String
> > > > > > > > >>     MetadataHash               => String
> > > > > > > > >>   AssignmentStrategyMetadata   => bytes
> > > > > > > >
> > > > > > > >
> > > > > > > > >
> > > > > > > > > On Thu, Aug 13, 2015 at 6:28 PM, Jiangjie Qin
> > > > > > > <jqin@linkedin.com.invalid
> > > > > > > > >
> > > > > > > > > wrote:
> > > > > > > > >
> > > > > > > > >> Ewen and Jason,
> > > > > > > > >>
> > > > > > > > >> Thanks for the reply. Sorry I missed the metadata hash.
> Yes,
> > > > that
> > > > > > is a
> > > > > > > > >> clever approach and would solve my concern about the data
> > > > passing
> > > > > > > > around.
> > > > > > > > >> I
> > > > > > > > >> can see both pros and cons from doing this, though. The
> > > > advantage
> > > > > is
> > > > > > > we
> > > > > > > > >> don't need the topic metadata in JoinGroupResponse
> anymore.
> > > The
> > > > > > > downside
> > > > > > > > >> is
> > > > > > > > >> that now rebalance have extra dependency on the consensus
> of
> > > > > > metadata
> > > > > > > of
> > > > > > > > >> all consumers, which is obtained separately. So it is
> > required
> > > > > that
> > > > > > > each
> > > > > > > > >> consumer refresh their metadata before sending a
> > > > JoinGroupRequest,
> > > > > > > > >> otherwise in some cases (e.g. wildcard consumers) will
> > almost
> > > > > > > certainly
> > > > > > > > >> fail for the first rebalance attempt. Even if we do that,
> > > since
> > > > > the
> > > > > > > > >> consumers are getting metadata from different brokers, the
> > > > > metadata
> > > > > > > > might
> > > > > > > > >> still be inconsistent if there is a topic or partition
> > change
> > > > > > because
> > > > > > > > the
> > > > > > > > >> UpdateMetadataRequest from controller might be handled at
> > > > > different
> > > > > > > > time.
> > > > > > > > >> Just want to make sure we think through the cases so the
> > > > protocol
> > > > > > does
> > > > > > > > not
> > > > > > > > >> cause us unexpected issues.
> > > > > > > > >>
> > > > > > > > >> About the number of consumers, I think with the current
> > > > liveliness
> > > > > > > > >> definition, we can tolerate churns by bumping up the
> session
> > > > > > timeout.
> > > > > > > > Also
> > > > > > > > >> I guess we will see an increasing number of consumers for
> > new
> > > > > > > consumer,
> > > > > > > > >> because every the old consumer thread will probably
> become a
> > > > > > consumer.
> > > > > > > > >>
> > > > > > > > >> It is a valid concern for consumers that have large
> > > subscription
> > > > > > set.
> > > > > > > > This
> > > > > > > > >> might not be avoided though for client side assignment
> > > approach.
> > > > > One
> > > > > > > > >> solution is having topic names associate with a topic ID.
> > And
> > > > only
> > > > > > use
> > > > > > > > >> topic ID in JoinGroupRequest and JoinGroupResponse, There
> > is a
> > > > > > > > discussion
> > > > > > > > >> thread about this to solve the topic renaming case but
> this
> > > is a
> > > > > > > > >> completely
> > > > > > > > >> different discussion.
> > > > > > > > >>
> > > > > > > > >> Thanks,
> > > > > > > > >>
> > > > > > > > >> Jiangjie (Becket) Qin
> > > > > > > > >>
> > > > > > > > >>
> > > > > > > > >>
> > > > > > > > >> On Thu, Aug 13, 2015 at 2:14 PM, Jason Gustafson <
> > > > > > jason@confluent.io>
> > > > > > > > >> wrote:
> > > > > > > > >>
> > > > > > > > >> > Thanks Jiangjie, that information helps. I agree the
> > > protocol
> > > > > must
> > > > > > > > >> consider
> > > > > > > > >> > scalability. My point was that the synchronization
> barrier
> > > in
> > > > > the
> > > > > > > > >> current
> > > > > > > > >> > protocol already effectively limits the number of
> > consumers
> > > > > since
> > > > > > it
> > > > > > > > >> > provides no way to gracefully handle churn. It wouldn't
> be
> > > > worth
> > > > > > > > >> worrying
> > > > > > > > >> > about scaling up to 100,000 members, for example,
> because
> > > > > there's
> > > > > > no
> > > > > > > > way
> > > > > > > > >> > the group would be stable. So we just need to set some
> > clear
> > > > > > > > >> expectations
> > > > > > > > >> > on the size we can scale to, and that can help inform
> the
> > > > > > discussion
> > > > > > > > on
> > > > > > > > >> the
> > > > > > > > >> > size of messages in this protocol.
> > > > > > > > >> >
> > > > > > > > >> > Ewen and I were discussing this morning along similar
> > lines
> > > to
> > > > > > what
> > > > > > > > >> you're
> > > > > > > > >> > suggesting. However, even if the coordinator decides on
> > the
> > > > > > metadata
> > > > > > > > for
> > > > > > > > >> > the group, each member still needs to communicate its
> > > > > > subscriptions
> > > > > > > to
> > > > > > > > >> the
> > > > > > > > >> > rest of the group. This is nice for the regex case since
> > the
> > > > > regex
> > > > > > > is
> > > > > > > > >> > probably small, but if the members have a large topic
> > list,
> > > > then
> > > > > > we
> > > > > > > > have
> > > > > > > > >> > the same problem. One thing I was thinking about was
> > whether
> > > > we
> > > > > > > really
> > > > > > > > >> need
> > > > > > > > >> > to handle different subscriptions for every member. If
> the
> > > > > > > coordinator
> > > > > > > > >> > could guarantee that all members had the same
> > subscription,
> > > > then
> > > > > > > there
> > > > > > > > >> > would be no need for the coordinator to return the
> > > > subscriptions
> > > > > > for
> > > > > > > > >> each
> > > > > > > > >> > member. However, this would prevent graceful upgrades.
> We
> > > > might
> > > > > be
> > > > > > > > able
> > > > > > > > >> to
> > > > > > > > >> > fix that problem by allowing the consumer to provide two
> > > > > > > subscriptions
> > > > > > > > >> to
> > > > > > > > >> > allowing rolling updates, but that starts to sound
> pretty
> > > > nasty.
> > > > > > > > >> >
> > > > > > > > >> > -Jason
> > > > > > > > >> >
> > > > > > > > >> > On Thu, Aug 13, 2015 at 1:41 PM, Jiangjie Qin
> > > > > > > > <jqin@linkedin.com.invalid
> > > > > > > > >> >
> > > > > > > > >> > wrote:
> > > > > > > > >> >
> > > > > > > > >> > > Jason,
> > > > > > > > >> > >
> > > > > > > > >> > > The protocol has to consider the scalability. The
> > protocol
> > > > in
> > > > > > the
> > > > > > > > wiki
> > > > > > > > >> > > means the JoinGroupResoponse size would be:
> > > > > > > > >> > > NumberOfTopics * (AvgTopicNameLength + 4) *
> > > > > > (NumberOfConsumers)^2
> > > > > > > > >> > >
> > > > > > > > >> > > To give some real number, we have 26-node Mirror Maker
> > > > > cluster,
> > > > > > > each
> > > > > > > > >> > with 4
> > > > > > > > >> > > consumers. That is 104 consumers using regex ".*". And
> > > most
> > > > of
> > > > > > our
> > > > > > > > >> > clusters
> > > > > > > > >> > > have around 3000 topics, whose topic name are
> typically
> > > > around
> > > > > > 20
> > > > > > > > >> > > characters.
> > > > > > > > >> > >
> > > > > > > > >> > > I think the key issue for client side partition
> > assignment
> > > > > logic
> > > > > > > is
> > > > > > > > to
> > > > > > > > >> > make
> > > > > > > > >> > > sure 1) all the clients run the same algorithm. 2) all
> > the
> > > > > > clients
> > > > > > > > >> make
> > > > > > > > >> > > decision on the same topic metadata. The second
> purpose
> > > can
> > > > be
> > > > > > > done
> > > > > > > > by
> > > > > > > > >> > > simply letting coordinator provide the topic metadata
> > and
> > > > all
> > > > > > then
> > > > > > > > >> member
> > > > > > > > >> > > information as source of truth. Is it necessary to
> pass
> > > > topic
> > > > > > > > >> metadata of
> > > > > > > > >> > > each consumer around? Can we keep the protocol
> metadata
> > > > field
> > > > > > > > >> completely
> > > > > > > > >> > > independent of topic metadata? I think In the
> > > > > JoinGroupResponse,
> > > > > > > we
> > > > > > > > >> > should
> > > > > > > > >> > > have only one copy of topic metadata provided by
> > > coordinator
> > > > > and
> > > > > > > is
> > > > > > > > >> > outside
> > > > > > > > >> > > of protocol metadata. If user decides to put some
> > metadata
> > > > in
> > > > > > the
> > > > > > > > >> > > JoinGroupRequest and let coordinator pass around, they
> > are
> > > > > > > > responsible
> > > > > > > > >> > for
> > > > > > > > >> > > understanding the risk.
> > > > > > > > >> > >
> > > > > > > > >> > > Thanks,
> > > > > > > > >> > >
> > > > > > > > >> > > Jiangjie (Becket) Qin
> > > > > > > > >> > >
> > > > > > > > >> > >
> > > > > > > > >> > > On Thu, Aug 13, 2015 at 12:41 PM, Jason Gustafson <
> > > > > > > > jason@confluent.io
> > > > > > > > >> >
> > > > > > > > >> > > wrote:
> > > > > > > > >> > >
> > > > > > > > >> > > > Hey Onur and Jiangjie,
> > > > > > > > >> > > >
> > > > > > > > >> > > > I've updated that wiki with a proposal to add regex
> > > > > > > subscriptions
> > > > > > > > to
> > > > > > > > >> > the
> > > > > > > > >> > > > consumer metadata. Can you have a look to see if it
> > > > > addresses
> > > > > > > your
> > > > > > > > >> > > concern?
> > > > > > > > >> > > > In general, I think we should be a little careful
> when
> > > we
> > > > > are
> > > > > > > > >> talking
> > > > > > > > >> > > about
> > > > > > > > >> > > > the scalability of the protocol. Regardless of
> whether
> > > > > > > assignment
> > > > > > > > is
> > > > > > > > >> > done
> > > > > > > > >> > > > on the server or the client, the protocol assumes a
> > > > > relatively
> > > > > > > > >> stable
> > > > > > > > >> > > > configuration. When the number of consumers
> increases
> > > > > beyond a
> > > > > > > > >> certain
> > > > > > > > >> > > > limit, then membership churn becomes a major
> concern.
> > > > > > Similarly
> > > > > > > > >> there
> > > > > > > > >> > is
> > > > > > > > >> > > a
> > > > > > > > >> > > > notion of metadata churn when topics are added,
> > deleted,
> > > > or
> > > > > > > > >> resized. If
> > > > > > > > >> > > > either membership or metadata changes, then the
> > protocol
> > > > > > forces
> > > > > > > > all
> > > > > > > > >> > > > consumers to stop consumption and rejoin the group.
> If
> > > > this
> > > > > > > > happens
> > > > > > > > >> > often
> > > > > > > > >> > > > enough, then it can severely impact the ability of
> the
> > > > > > consumer
> > > > > > > to
> > > > > > > > >> make
> > > > > > > > >> > > > progress. The point is that the protocol may already
> > be
> > > > > > unsuited
> > > > > > > > to
> > > > > > > > >> > cases
> > > > > > > > >> > > > where there are either a large number of consumers
> or
> > > > > topics.
> > > > > > I
> > > > > > > > >> wonder
> > > > > > > > >> > if
> > > > > > > > >> > > > you guys can share your thoughts about your scaling
> > > > > > > expectations?
> > > > > > > > >> > > >
> > > > > > > > >> > > > -Jason
> > > > > > > > >> > > >
> > > > > > > > >> > > >
> > > > > > > > >> > > >
> > > > > > > > >> > > >
> > > > > > > > >> > > > On Wed, Aug 12, 2015 at 12:28 PM, Jason Gustafson <
> > > > > > > > >> jason@confluent.io>
> > > > > > > > >> > > > wrote:
> > > > > > > > >> > > >
> > > > > > > > >> > > > > Hey Jiangjie,
> > > > > > > > >> > > > >
> > > > > > > > >> > > > > That's a great point. In the worst case (the
> mirror
> > > > maker
> > > > > > > case I
> > > > > > > > >> > > guess),
> > > > > > > > >> > > > > the join group response can be massive. This would
> > be
> > > > > > > especially
> > > > > > > > >> > deadly
> > > > > > > > >> > > > > when there is a lot of churn in the group (e.g.
> in a
> > > > > rolling
> > > > > > > > >> > upgrade).
> > > > > > > > >> > > > The
> > > > > > > > >> > > > > current protocol is not great for this case
> either,
> > > but
> > > > > it's
> > > > > > > > >> > > > significantly
> > > > > > > > >> > > > > better. Here are a couple ways to deal with the
> > size:
> > > > > > > > >> > > > >
> > > > > > > > >> > > > > 1. First, we could have the coordinator compress
> the
> > > > > > > responses.
> > > > > > > > >> This
> > > > > > > > >> > > > would
> > > > > > > > >> > > > > probably be pretty effective if applied across the
> > > > > metadata
> > > > > > > from
> > > > > > > > >> all
> > > > > > > > >> > > > > members.
> > > > > > > > >> > > > >
> > > > > > > > >> > > > > 2. I think the regex case is the main problem. Is
> > that
> > > > > > right?
> > > > > > > We
> > > > > > > > >> > could
> > > > > > > > >> > > > > extend the metadata to allow the consumer to embed
> > its
> > > > > regex
> > > > > > > > >> > > subscription
> > > > > > > > >> > > > > in the metadata directly (note this might be a
> good
> > > idea
> > > > > > > > >> regardless
> > > > > > > > >> > of
> > > > > > > > >> > > > the
> > > > > > > > >> > > > > rest of this proposal). To support regex on the
> > > > consumer,
> > > > > we
> > > > > > > > must
> > > > > > > > >> > fetch
> > > > > > > > >> > > > > metadata for all topics. Rather than having all
> > regex
> > > > > > > > subscribers
> > > > > > > > >> > embed
> > > > > > > > >> > > > all
> > > > > > > > >> > > > > of this metadata in their join group requests,
> they
> > > > could
> > > > > > > > instead
> > > > > > > > >> > > embed a
> > > > > > > > >> > > > > hash of it. Then after the join group responses
> are
> > > > > > received,
> > > > > > > > they
> > > > > > > > >> > just
> > > > > > > > >> > > > > need to check that the hashes are the same. If
> there
> > > is
> > > > a
> > > > > > > > mismatch
> > > > > > > > >> > > (which
> > > > > > > > >> > > > > should only occur when topics are created,
> deleted,
> > or
> > > > > > > resized),
> > > > > > > > >> then
> > > > > > > > >> > > the
> > > > > > > > >> > > > > group members must refetch the metadata and rejoin
> > the
> > > > > > group.
> > > > > > > > >> This is
> > > > > > > > >> > > > also
> > > > > > > > >> > > > > how the current protocol behaves when there is a
> > > change
> > > > in
> > > > > > the
> > > > > > > > >> topic
> > > > > > > > >> > > > > metadata affecting the group--someone (either the
> > > > > > coordinator
> > > > > > > or
> > > > > > > > >> the
> > > > > > > > >> > > > > consumer) detects the change and forces the group
> to
> > > > > > > rebalance.
> > > > > > > > >> > > > >
> > > > > > > > >> > > > > What do you think?
> > > > > > > > >> > > > >
> > > > > > > > >> > > > > (Also I think adding groupId/generationId to fetch
> > and
> > > > > > produce
> > > > > > > > >> > requests
> > > > > > > > >> > > > > seems like an interesting line of thought.)
> > > > > > > > >> > > > >
> > > > > > > > >> > > > > -Jason
> > > > > > > > >> > > > >
> > > > > > > > >> > > > >
> > > > > > > > >> > > > >
> > > > > > > > >> > > > > On Wed, Aug 12, 2015 at 10:57 AM, Jiangjie Qin
> > > > > > > > >> > > <jqin@linkedin.com.invalid
> > > > > > > > >> > > > >
> > > > > > > > >> > > > > wrote:
> > > > > > > > >> > > > >
> > > > > > > > >> > > > >> Hey Ewen,
> > > > > > > > >> > > > >>
> > > > > > > > >> > > > >> Onur and I discussed this a little bit more. And
> we
> > > are
> > > > > > still
> > > > > > > > >> > worrying
> > > > > > > > >> > > > >> about passing all the metadata of all consumers
> > > around.
> > > > > > > > >> > > > >>
> > > > > > > > >> > > > >> Let's say I have a cluster has 10,000 topics, the
> > > > average
> > > > > > > topic
> > > > > > > > >> name
> > > > > > > > >> > > > >> length
> > > > > > > > >> > > > >> is 10 bytes. In this case, the opaque metadata
> will
> > > > have
> > > > > > 10 *
> > > > > > > > >> > 10,000 =
> > > > > > > > >> > > > >> 100KB for topic name, for each topic, there is a
> > > 4-byte
> > > > > > > integer
> > > > > > > > >> of
> > > > > > > > >> > > > number
> > > > > > > > >> > > > >> of partitions, that's another 40KB. So one global
> > > topic
> > > > > > > > metadata
> > > > > > > > >> > will
> > > > > > > > >> > > > have
> > > > > > > > >> > > > >> 140KB data. If I have 100 consumers who are using
> > > > > wildcard
> > > > > > to
> > > > > > > > >> > consume
> > > > > > > > >> > > > from
> > > > > > > > >> > > > >> all the topics. That means the protocol metadata
> > end
> > > up
> > > > > in
> > > > > > > the
> > > > > > > > >> > > > >> JoinGroupResponse will be 140KB * 100 = 14MB. And
> > the
> > > > > > > > >> > > JoinGroupResponse
> > > > > > > > >> > > > >> will need to be sent to 100 different consumers,
> > that
> > > > > means
> > > > > > > > 14MB
> > > > > > > > >> *
> > > > > > > > >> > > 100 =
> > > > > > > > >> > > > >> 1.4GB need to be sent by the consumer coordinator
> > for
> > > > one
> > > > > > > > >> rebalance.
> > > > > > > > >> > > How
> > > > > > > > >> > > > >> would that work?
> > > > > > > > >> > > > >>
> > > > > > > > >> > > > >> Also, having two consumers (old owner and new
> > owner)
> > > > > > > consuming
> > > > > > > > >> from
> > > > > > > > >> > > the
> > > > > > > > >> > > > >> same partition might also be a problem. e.g.
> people
> > > are
> > > > > > > > updating
> > > > > > > > >> > > > database.
> > > > > > > > >> > > > >> One thing might worth doing is to add GroupId and
> > > > > > Generation
> > > > > > > ID
> > > > > > > > >> to
> > > > > > > > >> > > > >> ProducerRequest and FetchRequest as well. This
> will
> > > > also
> > > > > > help
> > > > > > > > >> with
> > > > > > > > >> > the
> > > > > > > > >> > > > >> single producer use case. However, this is
> probably
> > > > > > > orthogonal
> > > > > > > > to
> > > > > > > > >> > this
> > > > > > > > >> > > > >> thread given the current new consumer also has
> this
> > > > > problem
> > > > > > > > and I
> > > > > > > > >> > > > believe
> > > > > > > > >> > > > >> we need to fix it.
> > > > > > > > >> > > > >>
> > > > > > > > >> > > > >> Thanks,
> > > > > > > > >> > > > >>
> > > > > > > > >> > > > >> Jiangjie (Becket) Qin
> > > > > > > > >> > > > >>
> > > > > > > > >> > > > >> On Tue, Aug 11, 2015 at 11:43 PM, Ewen
> > > > Cheslack-Postava <
> > > > > > > > >> > > > >> ewen@confluent.io>
> > > > > > > > >> > > > >> wrote:
> > > > > > > > >> > > > >>
> > > > > > > > >> > > > >> > On Tue, Aug 11, 2015 at 11:29 PM, Jiangjie Qin
> > > > > > > > >> > > > >> <jq...@linkedin.com.invalid>
> > > > > > > > >> > > > >> > wrote:
> > > > > > > > >> > > > >> >
> > > > > > > > >> > > > >> > > Ewen,
> > > > > > > > >> > > > >> > >
> > > > > > > > >> > > > >> > > Thanks for the explanation.
> > > > > > > > >> > > > >> > >
> > > > > > > > >> > > > >> > > For (1), I am more concerned about the
> failure
> > > case
> > > > > > > instead
> > > > > > > > >> of
> > > > > > > > >> > > > normal
> > > > > > > > >> > > > >> > case.
> > > > > > > > >> > > > >> > > What if a consumer somehow was kick out of a
> > > group
> > > > > but
> > > > > > is
> > > > > > > > >> still
> > > > > > > > >> > > > >> consuming
> > > > > > > > >> > > > >> > > and committing offsets? Does that mean the
> new
> > > > owner
> > > > > > and
> > > > > > > > old
> > > > > > > > >> > owner
> > > > > > > > >> > > > >> might
> > > > > > > > >> > > > >> > > potentially consuming from and committing
> > offsets
> > > > for
> > > > > > the
> > > > > > > > >> same
> > > > > > > > >> > > > >> partition?
> > > > > > > > >> > > > >> > > In the old consumer, this won't happen
> because
> > > the
> > > > > new
> > > > > > > > >> consumer
> > > > > > > > >> > > will
> > > > > > > > >> > > > >> not
> > > > > > > > >> > > > >> > be
> > > > > > > > >> > > > >> > > able to start consumption unless the previous
> > > owner
> > > > > has
> > > > > > > > >> released
> > > > > > > > >> > > its
> > > > > > > > >> > > > >> > > ownership. Basically, without the ownership
> > > > > guarantee,
> > > > > > I
> > > > > > > > >> don't
> > > > > > > > >> > see
> > > > > > > > >> > > > how
> > > > > > > > >> > > > >> > the
> > > > > > > > >> > > > >> > > communication among consumers themselves
> alone
> > > can
> > > > > > solve
> > > > > > > > the
> > > > > > > > >> > > problem
> > > > > > > > >> > > > >> > here.
> > > > > > > > >> > > > >> > >
> > > > > > > > >> > > > >> >
> > > > > > > > >> > > > >> > The generation ID check still applies to offset
> > > > > commits.
> > > > > > If
> > > > > > > > >> one of
> > > > > > > > >> > > the
> > > > > > > > >> > > > >> > consumers is kicked out and misbehaving, it can
> > > > > obviously
> > > > > > > > still
> > > > > > > > >> > > fetch
> > > > > > > > >> > > > >> and
> > > > > > > > >> > > > >> > process messages, but offset commits will not
> > work
> > > > > since
> > > > > > it
> > > > > > > > >> will
> > > > > > > > >> > not
> > > > > > > > >> > > > >> have
> > > > > > > > >> > > > >> > the current generation ID.
> > > > > > > > >> > > > >> >
> > > > > > > > >> > > > >> >
> > > > > > > > >> > > > >> > >
> > > > > > > > >> > > > >> > > For (2) and (3), now I understand how
> metadata
> > > are
> > > > > > used.
> > > > > > > > But
> > > > > > > > >> I
> > > > > > > > >> > > still
> > > > > > > > >> > > > >> > don't
> > > > > > > > >> > > > >> > > see why should we let the consumers to pass
> the
> > > > topic
> > > > > > > > >> > information
> > > > > > > > >> > > > >> across
> > > > > > > > >> > > > >> > > instead of letting coordinator give the
> > > > information.
> > > > > > The
> > > > > > > > >> single
> > > > > > > > >> > > > >> producer
> > > > > > > > >> > > > >> > > use case does not solve the ownership problem
> > in
> > > > > > abnormal
> > > > > > > > >> case
> > > > > > > > >> > > > either,
> > > > > > > > >> > > > >> > > which seems to be a little bit vulnerable.
> > > > > > > > >> > > > >> > >
> > > > > > > > >> > > > >> >
> > > > > > > > >> > > > >> > One of the goals here was to generalize group
> > > > > membership
> > > > > > so
> > > > > > > > we
> > > > > > > > >> > can,
> > > > > > > > >> > > > for
> > > > > > > > >> > > > >> > example, use it for balancing Copycat tasks
> > across
> > > > > > workers.
> > > > > > > > >> > There's
> > > > > > > > >> > > no
> > > > > > > > >> > > > >> > topic subscription info in that case. The
> > metadata
> > > > for
> > > > > > > > copycat
> > > > > > > > >> > > workers
> > > > > > > > >> > > > >> > would instead need to somehow indicate the
> > current
> > > > set
> > > > > of
> > > > > > > > tasks
> > > > > > > > >> > that
> > > > > > > > >> > > > >> need
> > > > > > > > >> > > > >> > to be assigned to workers. By making the
> metadata
> > > > > > > completely
> > > > > > > > >> > opaque
> > > > > > > > >> > > to
> > > > > > > > >> > > > >> the
> > > > > > > > >> > > > >> > protocol, it becomes more generally useful
> since
> > it
> > > > > > focuses
> > > > > > > > >> > squarely
> > > > > > > > >> > > > on
> > > > > > > > >> > > > >> the
> > > > > > > > >> > > > >> > group membership problem, allowing for that
> > > > additional
> > > > > > bit
> > > > > > > of
> > > > > > > > >> > > metadata
> > > > > > > > >> > > > >> so
> > > > > > > > >> > > > >> > you don't just get a list of members, but also
> > get
> > > a
> > > > > > little
> > > > > > > > >> bit of
> > > > > > > > >> > > > info
> > > > > > > > >> > > > >> > about each of them.
> > > > > > > > >> > > > >> >
> > > > > > > > >> > > > >> > A different option that we explored is to use a
> > > sort
> > > > of
> > > > > > > mixed
> > > > > > > > >> > model
> > > > > > > > >> > > --
> > > > > > > > >> > > > >> > still bake all the topic subscriptions directly
> > > into
> > > > > the
> > > > > > > > >> protocol
> > > > > > > > >> > > but
> > > > > > > > >> > > > >> also
> > > > > > > > >> > > > >> > include metadata. That would allow us to
> maintain
> > > the
> > > > > > > > existing
> > > > > > > > >> > > > >> > coordinator-driven approach to handling the
> > > metadata
> > > > > and
> > > > > > > > change
> > > > > > > > >> > > events
> > > > > > > > >> > > > >> like
> > > > > > > > >> > > > >> > the ones Onur pointed out. Then something like
> > the
> > > > > > Copycat
> > > > > > > > >> workers
> > > > > > > > >> > > > would
> > > > > > > > >> > > > >> > just not fill in any topic subscriptions and it
> > > would
> > > > > be
> > > > > > > > >> handled
> > > > > > > > >> > as
> > > > > > > > >> > > a
> > > > > > > > >> > > > >> > degenerate case. Based on the way I explained
> > that
> > > we
> > > > > can
> > > > > > > > >> handle
> > > > > > > > >> > > those
> > > > > > > > >> > > > >> > types of events, I personally feel its cleaner
> > and
> > > a
> > > > > > nicer
> > > > > > > > >> > > > >> generalization
> > > > > > > > >> > > > >> > to not include the subscriptions in the join
> > group
> > > > > > > protocol,
> > > > > > > > >> > making
> > > > > > > > >> > > it
> > > > > > > > >> > > > >> part
> > > > > > > > >> > > > >> > of the metadata instead.
> > > > > > > > >> > > > >> >
> > > > > > > > >> > > > >> > For the single producer case, are you saying it
> > > > doesn't
> > > > > > > solve
> > > > > > > > >> > > > ownership
> > > > > > > > >> > > > >> in
> > > > > > > > >> > > > >> > the abnormal case because a producer that
> doesn't
> > > > know
> > > > > it
> > > > > > > has
> > > > > > > > >> been
> > > > > > > > >> > > > >> kicked
> > > > > > > > >> > > > >> > out of the group yet can still produce data
> even
> > > > though
> > > > > > it
> > > > > > > > >> > shouldn't
> > > > > > > > >> > > > be
> > > > > > > > >> > > > >> > able to anymore? I definitely agree that that
> is
> > a
> > > > risk
> > > > > > --
> > > > > > > > this
> > > > > > > > >> > > > >> provides a
> > > > > > > > >> > > > >> > way to get closer to a true single-writer, but
> > > there
> > > > > are
> > > > > > > > >> > definitely
> > > > > > > > >> > > > >> still
> > > > > > > > >> > > > >> > failure modes that this does not address.
> > > > > > > > >> > > > >> >
> > > > > > > > >> > > > >> > -Ewen
> > > > > > > > >> > > > >> >
> > > > > > > > >> > > > >> >
> > > > > > > > >> > > > >> > >
> > > > > > > > >> > > > >> > > Thanks,
> > > > > > > > >> > > > >> > >
> > > > > > > > >> > > > >> > > Jiangjie (Becket) Qin
> > > > > > > > >> > > > >> > >
> > > > > > > > >> > > > >> > >
> > > > > > > > >> > > > >> > > On Tue, Aug 11, 2015 at 11:06 PM, Ewen
> > > > > > Cheslack-Postava <
> > > > > > > > >> > > > >> > ewen@confluent.io
> > > > > > > > >> > > > >> > > >
> > > > > > > > >> > > > >> > > wrote:
> > > > > > > > >> > > > >> > >
> > > > > > > > >> > > > >> > > > On Tue, Aug 11, 2015 at 10:15 PM, Jiangjie
> > Qin
> > > > > > > > >> > > > >> > <jqin@linkedin.com.invalid
> > > > > > > > >> > > > >> > > >
> > > > > > > > >> > > > >> > > > wrote:
> > > > > > > > >> > > > >> > > >
> > > > > > > > >> > > > >> > > > > Hi Jason,
> > > > > > > > >> > > > >> > > > >
> > > > > > > > >> > > > >> > > > > Thanks for writing this up. It would be
> > > useful
> > > > to
> > > > > > > > >> generalize
> > > > > > > > >> > > the
> > > > > > > > >> > > > >> > group
> > > > > > > > >> > > > >> > > > > concept. I have a few questions below.
> > > > > > > > >> > > > >> > > > >
> > > > > > > > >> > > > >> > > > > 1. In old consumer actually the partition
> > > > > > assignment
> > > > > > > > are
> > > > > > > > >> > done
> > > > > > > > >> > > by
> > > > > > > > >> > > > >> > > > consumers
> > > > > > > > >> > > > >> > > > > themselves. We used zookeeper to
> guarantee
> > > > that a
> > > > > > > > >> partition
> > > > > > > > >> > > will
> > > > > > > > >> > > > >> only
> > > > > > > > >> > > > >> > > be
> > > > > > > > >> > > > >> > > > > consumed by one consumer thread who
> > > > successfully
> > > > > > > > claimed
> > > > > > > > >> its
> > > > > > > > >> > > > >> > ownership.
> > > > > > > > >> > > > >> > > > > Does the new protocol plan to provide the
> > > same
> > > > > > > > guarantee?
> > > > > > > > >> > > > >> > > > >
> > > > > > > > >> > > > >> > > >
> > > > > > > > >> > > > >> > > > Once you have all the metadata from all the
> > > > > > consumers,
> > > > > > > > >> > > assignment
> > > > > > > > >> > > > >> > should
> > > > > > > > >> > > > >> > > > just be a simple function mapping that
> > > > > > Map<ConsumerId,
> > > > > > > > >> > Metadata>
> > > > > > > > >> > > > to
> > > > > > > > >> > > > >> > > > Map<ConsumerId, List<TopicPartition>>. If
> > > > everyone
> > > > > is
> > > > > > > > >> > consistent
> > > > > > > > >> > > > in
> > > > > > > > >> > > > >> > > > computing that, you don't need ZK involved
> at
> > > > all.
> > > > > > > > >> > > > >> > > >
> > > > > > > > >> > > > >> > > > In practice, this shouldn't be that hard to
> > > > ensure
> > > > > > for
> > > > > > > > most
> > > > > > > > >> > > > >> assignment
> > > > > > > > >> > > > >> > > > strategies just by having decent unit
> testing
> > > on
> > > > > > them.
> > > > > > > > You
> > > > > > > > >> > just
> > > > > > > > >> > > > >> have to
> > > > > > > > >> > > > >> > > do
> > > > > > > > >> > > > >> > > > things like ensure your assignment strategy
> > > sorts
> > > > > > lists
> > > > > > > > >> into a
> > > > > > > > >> > > > >> > consistent
> > > > > > > > >> > > > >> > > > order.
> > > > > > > > >> > > > >> > > >
> > > > > > > > >> > > > >> > > > You do give up the ability to use some
> > > techniques
> > > > > > (e.g.
> > > > > > > > any
> > > > > > > > >> > > > >> randomized
> > > > > > > > >> > > > >> > > > algorithm if you can't distribute the seed
> w/
> > > the
> > > > > > > > metadata)
> > > > > > > > >> > and
> > > > > > > > >> > > > it's
> > > > > > > > >> > > > >> > true
> > > > > > > > >> > > > >> > > > that nothing validates the assignment, but
> if
> > > > that
> > > > > > > > >> assignment
> > > > > > > > >> > > > >> algorithm
> > > > > > > > >> > > > >> > > > step is kept simple, small, and well
> tested,
> > > the
> > > > > risk
> > > > > > > is
> > > > > > > > >> very
> > > > > > > > >> > > > >> minimal.
> > > > > > > > >> > > > >> > > >
> > > > > > > > >> > > > >> > > >
> > > > > > > > >> > > > >> > > > >
> > > > > > > > >> > > > >> > > > > 2. It looks that both JoinGroupRequest
> and
> > > > > > > > >> JoinGroupResponse
> > > > > > > > >> > > has
> > > > > > > > >> > > > >> the
> > > > > > > > >> > > > >> > > > >
> > ProtocolMetadata.AssignmentStrategyMetadata,
> > > > what
> > > > > > > would
> > > > > > > > >> be
> > > > > > > > >> > the
> > > > > > > > >> > > > >> > metadata
> > > > > > > > >> > > > >> > > > be
> > > > > > > > >> > > > >> > > > > sent and returned by coordinator? How
> will
> > > the
> > > > > > > > >> coordinator
> > > > > > > > >> > > > handle
> > > > > > > > >> > > > >> the
> > > > > > > > >> > > > >> > > > > metadata?
> > > > > > > > >> > > > >> > > > >
> > > > > > > > >> > > > >> > > >
> > > > > > > > >> > > > >> > > > The coordinator is basically just blindly
> > > > > > broadcasting
> > > > > > > > all
> > > > > > > > >> of
> > > > > > > > >> > it
> > > > > > > > >> > > > to
> > > > > > > > >> > > > >> > group
> > > > > > > > >> > > > >> > > > members so they have a consistent view.
> > > > > > > > >> > > > >> > > >
> > > > > > > > >> > > > >> > > > So from the coordinators perspective, it
> sees
> > > > > > something
> > > > > > > > >> like:
> > > > > > > > >> > > > >> > > >
> > > > > > > > >> > > > >> > > > Consumer 1 -> JoinGroupRequest with
> > > > GroupProtocols
> > > > > =
> > > > > > [
> > > > > > > > >> > > "consumer"
> > > > > > > > >> > > > >> > > > <Consumer1 opaque byte[]>]
> > > > > > > > >> > > > >> > > > Consumer 2 -> JoinGroupRequest with
> > > > GroupProtocols
> > > > > =
> > > > > > [
> > > > > > > > >> > > "consumer"
> > > > > > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > > > > > >> > > > >> > > >
> > > > > > > > >> > > > >> > > > Then, in the responses would look like:
> > > > > > > > >> > > > >> > > >
> > > > > > > > >> > > > >> > > > Consumer 1 <- JoinGroupResponse with
> > > > GroupProtocol
> > > > > =
> > > > > > > > >> > "consumer"
> > > > > > > > >> > > > and
> > > > > > > > >> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1
> opaque
> > > > > > byte[]>,
> > > > > > > > >> > Consumer
> > > > > > > > >> > > 2
> > > > > > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > > > > > >> > > > >> > > > Consumer 2 <- JoinGroupResponse with
> > > > GroupProtocol
> > > > > =
> > > > > > > > >> > "consumer"
> > > > > > > > >> > > > and
> > > > > > > > >> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1
> opaque
> > > > > > byte[]>,
> > > > > > > > >> > Consumer
> > > > > > > > >> > > 2
> > > > > > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > > > > > >> > > > >> > > >
> > > > > > > > >> > > > >> > > > So all the responses include all the
> metadata
> > > for
> > > > > > every
> > > > > > > > >> member
> > > > > > > > >> > > in
> > > > > > > > >> > > > >> the
> > > > > > > > >> > > > >> > > > group, and everyone can use that to
> > > consistently
> > > > > > decide
> > > > > > > > on
> > > > > > > > >> > > > >> assignment.
> > > > > > > > >> > > > >> > > The
> > > > > > > > >> > > > >> > > > broker doesn't care and cannot even
> > understand
> > > > the
> > > > > > > > metadata
> > > > > > > > >> > > since
> > > > > > > > >> > > > >> the
> > > > > > > > >> > > > >> > > data
> > > > > > > > >> > > > >> > > > format for it is dependent on the
> assignment
> > > > > strategy
> > > > > > > > being
> > > > > > > > >> > > used.
> > > > > > > > >> > > > >> > > >
> > > > > > > > >> > > > >> > > > As another example that is *not* a
> consumer,
> > > > let's
> > > > > > say
> > > > > > > > you
> > > > > > > > >> > just
> > > > > > > > >> > > > >> want to
> > > > > > > > >> > > > >> > > > have a single writer in the group which
> > > everyone
> > > > > will
> > > > > > > > >> forward
> > > > > > > > >> > > > >> requests
> > > > > > > > >> > > > >> > > to.
> > > > > > > > >> > > > >> > > > To accomplish this, you could use a very
> dumb
> > > > > > > assignment
> > > > > > > > >> > > strategy:
> > > > > > > > >> > > > >> > there
> > > > > > > > >> > > > >> > > is
> > > > > > > > >> > > > >> > > > no metadata (empty byte[]) and all we care
> > > about
> > > > is
> > > > > > who
> > > > > > > > is
> > > > > > > > >> the
> > > > > > > > >> > > > first
> > > > > > > > >> > > > >> > > member
> > > > > > > > >> > > > >> > > > in the group (e.g. when IDs are sorted
> > > > > > > > lexicographically).
> > > > > > > > >> > That
> > > > > > > > >> > > > >> member
> > > > > > > > >> > > > >> > is
> > > > > > > > >> > > > >> > > > selected as the writer. In that case, we
> > > actually
> > > > > > just
> > > > > > > > care
> > > > > > > > >> > > about
> > > > > > > > >> > > > >> the
> > > > > > > > >> > > > >> > > > membership list, there's no additional info
> > > about
> > > > > > each
> > > > > > > > >> member
> > > > > > > > >> > > that
> > > > > > > > >> > > > >> is
> > > > > > > > >> > > > >> > > > required to determine who is the writer.
> > > > > > > > >> > > > >> > > >
> > > > > > > > >> > > > >> > > >
> > > > > > > > >> > > > >> > > > > 3. Do you mean that the number of
> > partitions
> > > in
> > > > > > > > >> > > > JoinGroupResponse
> > > > > > > > >> > > > >> > will
> > > > > > > > >> > > > >> > > be
> > > > > > > > >> > > > >> > > > > the max partition number of a topic among
> > all
> > > > the
> > > > > > > > >> reported
> > > > > > > > >> > > > >> partition
> > > > > > > > >> > > > >> > > > number
> > > > > > > > >> > > > >> > > > > by consumers? Is there any reason not
> just
> > > let
> > > > > > > > >> Coordinator
> > > > > > > > >> > to
> > > > > > > > >> > > > >> return
> > > > > > > > >> > > > >> > > the
> > > > > > > > >> > > > >> > > > > number of partitions of a topic in its
> > > metadata
> > > > > > > cache?
> > > > > > > > >> > > > >> > > > >
> > > > > > > > >> > > > >> > > >
> > > > > > > > >> > > > >> > > > Nothing from the embedded protocol is
> touched
> > > by
> > > > > the
> > > > > > > > >> broker.
> > > > > > > > >> > The
> > > > > > > > >> > > > >> broker
> > > > > > > > >> > > > >> > > > just collects opaque bytes of metadata,
> does
> > > the
> > > > > > > > selection
> > > > > > > > >> of
> > > > > > > > >> > > the
> > > > > > > > >> > > > >> > > strategy
> > > > > > > > >> > > > >> > > > if multiple are supported by some
> consumers,
> > > and
> > > > > then
> > > > > > > > >> returns
> > > > > > > > >> > > that
> > > > > > > > >> > > > >> > opaque
> > > > > > > > >> > > > >> > > > metadata for all the members back to every
> > > > member.
> > > > > In
> > > > > > > > that
> > > > > > > > >> way
> > > > > > > > >> > > > they
> > > > > > > > >> > > > >> all
> > > > > > > > >> > > > >> > > > have a consistent view of the group. For
> > > regular
> > > > > > > > consumers,
> > > > > > > > >> > that
> > > > > > > > >> > > > >> view
> > > > > > > > >> > > > >> > of
> > > > > > > > >> > > > >> > > > the group includes information about how
> many
> > > > > > > partitions
> > > > > > > > >> each
> > > > > > > > >> > > > >> consumer
> > > > > > > > >> > > > >> > > > currently thinks the topics it is
> subscribed
> > to
> > > > > has.
> > > > > > > > These
> > > > > > > > >> > could
> > > > > > > > >> > > > be
> > > > > > > > >> > > > >> > > > inconsistent due to out of date metadata
> and
> > it
> > > > > would
> > > > > > > be
> > > > > > > > >> up to
> > > > > > > > >> > > the
> > > > > > > > >> > > > >> > > > assignment strategy on the *client* to
> > resolve
> > > > > that.
> > > > > > As
> > > > > > > > you
> > > > > > > > >> > > point
> > > > > > > > >> > > > >> out,
> > > > > > > > >> > > > >> > in
> > > > > > > > >> > > > >> > > > that case they could just take the max
> value
> > > that
> > > > > any
> > > > > > > > >> consumer
> > > > > > > > >> > > > >> reported
> > > > > > > > >> > > > >> > > > seeing and use that. The consumers that
> > notice
> > > > that
> > > > > > > their
> > > > > > > > >> > > metadata
> > > > > > > > >> > > > >> had
> > > > > > > > >> > > > >> > a
> > > > > > > > >> > > > >> > > > smaller # of partitions should also
> trigger a
> > > > > > metadata
> > > > > > > > >> update
> > > > > > > > >> > > when
> > > > > > > > >> > > > >> they
> > > > > > > > >> > > > >> > > see
> > > > > > > > >> > > > >> > > > someone else observing a larger # of
> > > partitions.
> > > > > > > > >> > > > >> > > >
> > > > > > > > >> > > > >> > > >
> > > > > > > > >> > > > >> > > > >
> > > > > > > > >> > > > >> > > > > Thanks,
> > > > > > > > >> > > > >> > > > >
> > > > > > > > >> > > > >> > > > > Jiangjie (Becket) Qin
> > > > > > > > >> > > > >> > > > >
> > > > > > > > >> > > > >> > > > >
> > > > > > > > >> > > > >> > > > >
> > > > > > > > >> > > > >> > > > >
> > > > > > > > >> > > > >> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason
> > > > Gustafson
> > > > > <
> > > > > > > > >> > > > >> jason@confluent.io
> > > > > > > > >> > > > >> > >
> > > > > > > > >> > > > >> > > > > wrote:
> > > > > > > > >> > > > >> > > > >
> > > > > > > > >> > > > >> > > > > > Hi Kafka Devs,
> > > > > > > > >> > > > >> > > > > >
> > > > > > > > >> > > > >> > > > > > One of the nagging issues in the
> current
> > > > design
> > > > > > of
> > > > > > > > the
> > > > > > > > >> new
> > > > > > > > >> > > > >> consumer
> > > > > > > > >> > > > >> > > has
> > > > > > > > >> > > > >> > > > > > been the need to support a variety of
> > > > > assignment
> > > > > > > > >> > strategies.
> > > > > > > > >> > > > >> We've
> > > > > > > > >> > > > >> > > > > > encountered this in particular in the
> > > design
> > > > of
> > > > > > > > copycat
> > > > > > > > >> > and
> > > > > > > > >> > > > the
> > > > > > > > >> > > > >> > > > > processing
> > > > > > > > >> > > > >> > > > > > framework (KIP-28). From what I
> > understand,
> > > > > Samza
> > > > > > > > also
> > > > > > > > >> > has a
> > > > > > > > >> > > > >> number
> > > > > > > > >> > > > >> > > of
> > > > > > > > >> > > > >> > > > > use
> > > > > > > > >> > > > >> > > > > > cases with custom assignment needs. The
> > new
> > > > > > > consumer
> > > > > > > > >> > > protocol
> > > > > > > > >> > > > >> > > supports
> > > > > > > > >> > > > >> > > > > new
> > > > > > > > >> > > > >> > > > > > assignment strategies by hooking them
> > into
> > > > the
> > > > > > > > broker.
> > > > > > > > >> For
> > > > > > > > >> > > > many
> > > > > > > > >> > > > >> > > > > > environments, this is a major pain and
> in
> > > > some
> > > > > > > > cases, a
> > > > > > > > >> > > > >> > non-starter.
> > > > > > > > >> > > > >> > > It
> > > > > > > > >> > > > >> > > > > > also challenges the validation that the
> > > > > > coordinator
> > > > > > > > can
> > > > > > > > >> > > > provide.
> > > > > > > > >> > > > >> > For
> > > > > > > > >> > > > >> > > > > > example, some assignment strategies
> call
> > > for
> > > > > > > > >> partitions to
> > > > > > > > >> > > be
> > > > > > > > >> > > > >> > > assigned
> > > > > > > > >> > > > >> > > > > > multiple times, which means that the
> > > > > coordinator
> > > > > > > can
> > > > > > > > >> only
> > > > > > > > >> > > > check
> > > > > > > > >> > > > >> > that
> > > > > > > > >> > > > >> > > > > > partitions have been assigned at least
> > > once.
> > > > > > > > >> > > > >> > > > > >
> > > > > > > > >> > > > >> > > > > > To solve these issues, we'd like to
> > propose
> > > > > > moving
> > > > > > > > >> > > assignment
> > > > > > > > >> > > > to
> > > > > > > > >> > > > >> > the
> > > > > > > > >> > > > >> > > > > > client. I've written a wiki which
> > outlines
> > > > some
> > > > > > > > >> protocol
> > > > > > > > >> > > > >> changes to
> > > > > > > > >> > > > >> > > > > achieve
> > > > > > > > >> > > > >> > > > > > this:
> > > > > > > > >> > > > >> > > > > >
> > > > > > > > >> > > > >> > > > > >
> > > > > > > > >> > > > >> > > > >
> > > > > > > > >> > > > >> > > >
> > > > > > > > >> > > > >> > >
> > > > > > > > >> > > > >> >
> > > > > > > > >> > > > >>
> > > > > > > > >> > > >
> > > > > > > > >> > >
> > > > > > > > >> >
> > > > > > > > >>
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> > > > > > > > >> > > > >> > > > > > .
> > > > > > > > >> > > > >> > > > > > To summarize briefly, instead of the
> > > > > coordinator
> > > > > > > > >> assigning
> > > > > > > > >> > > the
> > > > > > > > >> > > > >> > > > partitions
> > > > > > > > >> > > > >> > > > > > itself, all subscriptions are forwarded
> > to
> > > > each
> > > > > > > > member
> > > > > > > > >> of
> > > > > > > > >> > > the
> > > > > > > > >> > > > >> group
> > > > > > > > >> > > > >> > > > which
> > > > > > > > >> > > > >> > > > > > then decides independently which
> > partitions
> > > > it
> > > > > > > should
> > > > > > > > >> > > consume.
> > > > > > > > >> > > > >> The
> > > > > > > > >> > > > >> > > > > protocol
> > > > > > > > >> > > > >> > > > > > provides a mechanism for the
> coordinator
> > to
> > > > > > > validate
> > > > > > > > >> that
> > > > > > > > >> > > all
> > > > > > > > >> > > > >> > > consumers
> > > > > > > > >> > > > >> > > > > use
> > > > > > > > >> > > > >> > > > > > the same assignment strategy, but it
> does
> > > not
> > > > > > > ensure
> > > > > > > > >> that
> > > > > > > > >> > > the
> > > > > > > > >> > > > >> > > resulting
> > > > > > > > >> > > > >> > > > > > assignment is "correct." This provides
> a
> > > > > powerful
> > > > > > > > >> > capability
> > > > > > > > >> > > > for
> > > > > > > > >> > > > >> > > users
> > > > > > > > >> > > > >> > > > to
> > > > > > > > >> > > > >> > > > > > control the full data flow on the
> client
> > > > side.
> > > > > > They
> > > > > > > > >> > control
> > > > > > > > >> > > > how
> > > > > > > > >> > > > >> > data
> > > > > > > > >> > > > >> > > is
> > > > > > > > >> > > > >> > > > > > written to partitions through the
> > > Partitioner
> > > > > > > > interface
> > > > > > > > >> > and
> > > > > > > > >> > > > they
> > > > > > > > >> > > > >> > > > control
> > > > > > > > >> > > > >> > > > > > how data is consumed through the
> > assignment
> > > > > > > strategy,
> > > > > > > > >> all
> > > > > > > > >> > > > >> without
> > > > > > > > >> > > > >> > > > > touching
> > > > > > > > >> > > > >> > > > > > the server.
> > > > > > > > >> > > > >> > > > > >
> > > > > > > > >> > > > >> > > > > > Of course nothing comes for free. In
> > > > > particular,
> > > > > > > this
> > > > > > > > >> > change
> > > > > > > > >> > > > >> > removes
> > > > > > > > >> > > > >> > > > the
> > > > > > > > >> > > > >> > > > > > ability of the coordinator to validate
> > that
> > > > > > commits
> > > > > > > > are
> > > > > > > > >> > made
> > > > > > > > >> > > > by
> > > > > > > > >> > > > >> > > > consumers
> > > > > > > > >> > > > >> > > > > > who were assigned the respective
> > partition.
> > > > > This
> > > > > > > > might
> > > > > > > > >> not
> > > > > > > > >> > > be
> > > > > > > > >> > > > >> too
> > > > > > > > >> > > > >> > bad
> > > > > > > > >> > > > >> > > > > since
> > > > > > > > >> > > > >> > > > > > we retain the ability to validate the
> > > > > generation
> > > > > > > id,
> > > > > > > > >> but
> > > > > > > > >> > it
> > > > > > > > >> > > > is a
> > > > > > > > >> > > > >> > > > > potential
> > > > > > > > >> > > > >> > > > > > concern. We have considered alternative
> > > > > protocols
> > > > > > > > which
> > > > > > > > >> > add
> > > > > > > > >> > > a
> > > > > > > > >> > > > >> > second
> > > > > > > > >> > > > >> > > > > > round-trip to the protocol in order to
> > give
> > > > the
> > > > > > > > >> > coordinator
> > > > > > > > >> > > > the
> > > > > > > > >> > > > >> > > ability
> > > > > > > > >> > > > >> > > > > to
> > > > > > > > >> > > > >> > > > > > confirm the assignment. As mentioned
> > above,
> > > > the
> > > > > > > > >> > coordinator
> > > > > > > > >> > > is
> > > > > > > > >> > > > >> > > somewhat
> > > > > > > > >> > > > >> > > > > > limited in what it can actually
> validate,
> > > but
> > > > > > this
> > > > > > > > >> would
> > > > > > > > >> > > > return
> > > > > > > > >> > > > >> its
> > > > > > > > >> > > > >> > > > > ability
> > > > > > > > >> > > > >> > > > > > to validate commits. The tradeoff is
> that
> > > it
> > > > > > > > increases
> > > > > > > > >> the
> > > > > > > > >> > > > >> > protocol's
> > > > > > > > >> > > > >> > > > > > complexity which means more ways for
> the
> > > > > protocol
> > > > > > > to
> > > > > > > > >> fail
> > > > > > > > >> > > and
> > > > > > > > >> > > > >> > > > > consequently
> > > > > > > > >> > > > >> > > > > > more edge cases in the code.
> > > > > > > > >> > > > >> > > > > >
> > > > > > > > >> > > > >> > > > > > It also misses an opportunity to
> > generalize
> > > > the
> > > > > > > group
> > > > > > > > >> > > > membership
> > > > > > > > >> > > > >> > > > protocol
> > > > > > > > >> > > > >> > > > > > for additional use cases. In fact,
> after
> > > > you've
> > > > > > > gone
> > > > > > > > to
> > > > > > > > >> > the
> > > > > > > > >> > > > >> trouble
> > > > > > > > >> > > > >> > > of
> > > > > > > > >> > > > >> > > > > > moving assignment to the client, the
> main
> > > > thing
> > > > > > > that
> > > > > > > > is
> > > > > > > > >> > left
> > > > > > > > >> > > > in
> > > > > > > > >> > > > >> > this
> > > > > > > > >> > > > >> > > > > > protocol is basically a general group
> > > > > management
> > > > > > > > >> > capability.
> > > > > > > > >> > > > >> This
> > > > > > > > >> > > > >> > is
> > > > > > > > >> > > > >> > > > > > exactly what is needed for a few cases
> > that
> > > > are
> > > > > > > > >> currently
> > > > > > > > >> > > > under
> > > > > > > > >> > > > >> > > > > discussion
> > > > > > > > >> > > > >> > > > > > (e.g. copycat or single-writer
> producer).
> > > > We've
> > > > > > > taken
> > > > > > > > >> this
> > > > > > > > >> > > > >> further
> > > > > > > > >> > > > >> > > step
> > > > > > > > >> > > > >> > > > > in
> > > > > > > > >> > > > >> > > > > > the proposal and attempted to envision
> > what
> > > > > that
> > > > > > > > >> general
> > > > > > > > >> > > > >> protocol
> > > > > > > > >> > > > >> > > might
> > > > > > > > >> > > > >> > > > > > look like and how it could be used both
> > by
> > > > the
> > > > > > > > consumer
> > > > > > > > >> > and
> > > > > > > > >> > > > for
> > > > > > > > >> > > > >> > some
> > > > > > > > >> > > > >> > > of
> > > > > > > > >> > > > >> > > > > > these other cases.
> > > > > > > > >> > > > >> > > > > >
> > > > > > > > >> > > > >> > > > > > Anyway, since time is running out on
> the
> > > new
> > > > > > > > consumer,
> > > > > > > > >> we
> > > > > > > > >> > > have
> > > > > > > > >> > > > >> > > perhaps
> > > > > > > > >> > > > >> > > > > one
> > > > > > > > >> > > > >> > > > > > last chance to consider a significant
> > > change
> > > > in
> > > > > > the
> > > > > > > > >> > protocol
> > > > > > > > >> > > > >> like
> > > > > > > > >> > > > >> > > this,
> > > > > > > > >> > > > >> > > > > so
> > > > > > > > >> > > > >> > > > > > have a look at the wiki and share your
> > > > > thoughts.
> > > > > > > I've
> > > > > > > > >> no
> > > > > > > > >> > > doubt
> > > > > > > > >> > > > >> that
> > > > > > > > >> > > > >> > > > some
> > > > > > > > >> > > > >> > > > > > ideas seem clearer in my mind than they
> > do
> > > on
> > > > > > > paper,
> > > > > > > > so
> > > > > > > > >> > ask
> > > > > > > > >> > > > >> > questions
> > > > > > > > >> > > > >> > > > if
> > > > > > > > >> > > > >> > > > > > there is any confusion.
> > > > > > > > >> > > > >> > > > > >
> > > > > > > > >> > > > >> > > > > > Thanks!
> > > > > > > > >> > > > >> > > > > > Jason
> > > > > > > > >> > > > >> > > > > >
> > > > > > > > >> > > > >> > > > >
> > > > > > > > >> > > > >> > > >
> > > > > > > > >> > > > >> > > >
> > > > > > > > >> > > > >> > > >
> > > > > > > > >> > > > >> > > > --
> > > > > > > > >> > > > >> > > > Thanks,
> > > > > > > > >> > > > >> > > > Ewen
> > > > > > > > >> > > > >> > > >
> > > > > > > > >> > > > >> > >
> > > > > > > > >> > > > >> >
> > > > > > > > >> > > > >> >
> > > > > > > > >> > > > >> >
> > > > > > > > >> > > > >> > --
> > > > > > > > >> > > > >> > Thanks,
> > > > > > > > >> > > > >> > Ewen
> > > > > > > > >> > > > >> >
> > > > > > > > >> > > > >>
> > > > > > > > >> > > > >
> > > > > > > > >> > > > >
> > > > > > > > >> > > >
> > > > > > > > >> > >
> > > > > > > > >> >
> > > > > > > > >>
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > > Thanks,
> > > > > > > > > Neha
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > Thanks,
> > > > > > > > Neha
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Thanks,
> > > > > > > Ewen
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Thanks,
> > > > > Ewen
> > > > >
> > > >
> > >
> >
> >
> >
> > --
> > Thanks,
> > Neha
> >
>



-- 
Thanks,
Neha

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Jiangjie Qin <jq...@linkedin.com.INVALID>.
Neha, Ewen and Jason,

Maybe I am over concerning and I agree that it does depend on the metadata
change frequency. As Neha said, a few tests will be helpful. We can see how
it goes.

What worries me is that in LinkedIn we are in the progress of running Kafka
as a service. That means user will have the ability to create/delete topics
and update their topic configurations programmatically or through UI using
LinkedIn internal cloud service platform. And some automated test will also
be consistently running to create topic, produce/consume some data, then
clean up the topics. This brings us some new challenges for mirror maker
because we need to make sure it actually copies data instead of spending
too much time on rebalance. As what we see now is that each rebalance will
probably take 30 seconds or more to finish even with some tricks and tuning.

Another related use case I want to bring up is that today when we want to
do a rolling upgrade of mirror maker (26 nodes), there will be two rounds
of rebalance to bounce each node, each rebalance takes about 30 seconds. So
bouncing 26 nodes takes roughly half an hour. Awkwardly, during the rolling
bounce, because mirror maker is keeping rebalancing, it actually does not
really copy any data! So the pipeline will literally stall for half an
hour! Since we are designing the new protocol, it will also be good it we
make sure this use case is addressed.

Thanks,

Jiangjie (Becket) Qin

On Sat, Aug 15, 2015 at 10:50 AM, Neha Narkhede <ne...@confluent.io> wrote:

> Becket,
>
> This is a clever approach for to ensure that only one thing communicates
> the metadata so even if it is stale, the entire group has the same view.
> However, the big assumption this makes is that the coordinator is that one
> process that has the ability to know the metadata for group members, which
> does not work for any non-consumer use case.
>
> I wonder if we may be complicating the design of 95% use cases for the
> remaining 5%. For instance, how many times do people create and remove
> topics or even add partitions? We operated LI clusters for a long time and
> this wasn't a frequent event that would need us to optimize this design
> for.
>
> Also, this is something we can easily validate by running a few tests on
> the patch and I suggest we wait for that.
>
> Thanks,
> Neha
>
> On Sat, Aug 15, 2015 at 9:14 AM, Jason Gustafson <ja...@confluent.io>
> wrote:
>
> > Hey Jiangjie,
> >
> > I was thinking about the same problem. When metadata is changing
> > frequently, the clients may not be able to ever find agreement on the
> > current state. The server doesn't have this problem, as you say, because
> it
> > can just take a snapshot and send that to the clients. Adding a dampening
> > setting to the client would help if churn is sporadic, but not if it is
> > steady. I think the metadata would have to be changing really frequently
> > for this to be a problem practically, but this is a case where the
> > server-side approach has an advantage.
> >
> > Including the metadata in the join group response would require making
> the
> > subscription available to the coordinator, right? We lose a little bit of
> > the generality of the protocol, but it might not be too bad since most
> use
> > cases for reusing this protocol have a similar need for metadata (and
> they
> > can always pass an empty subscription if they don't). We've gone back and
> > forth a few times on this, and I'm generally not opposed. It might help
> if
> > we try to quantify the impact of the metadata churn in practice. I think
> > the rate of change would have to be in the low seconds for this to be a
> > real problem. It does seem nice though that we have a way to manage even
> > this much churn when we do this.
> >
> > -Jason
> >
> >
> >
> > On Fri, Aug 14, 2015 at 9:03 PM, Jiangjie Qin <jqin@linkedin.com.invalid
> >
> > wrote:
> >
> > > Ewen,
> > >
> > > I agree that if there is a churn in metadata, the consumers need
> several
> > > rounds of rebalances to succeed. The difference I am thinking is that
> > with
> > > coordinator as single source of truth, we can let the consumer finish
> one
> > > round of rebalance, work for a while and start the next round of
> > rebalance.
> > > If we purely depend on the consumers to synchronize by themselves based
> > on
> > > different metadata sources, is it possible we have some groups
> spending a
> > > lot of time on rebalancing but not able to make too much progress in
> > > consuming?
> > >
> > > I'm thinking can we let consumers to fetch metadata only from their
> > > coordinator? So the rebalance can be done in the following way:
> > >
> > > 1. Consumers refresh their metadata periodically
> > > 2. If one of the consumer sees a change in metadata that triggers a
> > > rebalance, it sends JoinGroupRequest to coordinator.
> > > 3. Once the coordinator receives the first JoinGroupRequest of a group,
> > it
> > > takes a snapshot of current metadata and the group enters
> > prepare-rebalance
> > > state.
> > > 4. The metadata snapshot will be used for this round of rebalance. i.e.
> > the
> > > metadata snapshot will be sent to consumers in JoinGroupResponse.
> > > 4.1 If the consumers are subscribing to explicit topic lists (not
> regex),
> > > the JoinGroupResponse needs only contain the metadata of all topics the
> > > group is interested.
> > > 4.2 If the consumers are subscribing using regex, all the topic
> metadata
> > > will be returned to the consumer.
> > > 5. Consumers get JoinGroupResponse, refresh metadata using the metadata
> > in
> > > JoinGroupResponse, run algorithm to assign partitions and start
> consume.
> > > 6. Go back to 1.
> > >
> > > The benefit here is that we can let rebalance finish in one round, and
> > all
> > > the rest of changes will be captured in next consumer metadata refresh
> -
> > so
> > > we get group commit. One concern might be letting consumer refresh
> > metadata
> > > from coordinator might cause issue for big consumer groups. Maybe that
> is
> > > OK because metadata refresh is infrequent.
> > >
> > > This approach actually is very similar to what is proposed now:
> rebalance
> > > is triggered by metadata refresh, consumer provides subscription list
> to
> > > pass around. The only difference is that we don't need metadata hash
> > > anymore because the metadata is guaranteed to be the same. Replacing
> > > metadata hash with actual metadata will not have too much overhead for
> > > small subscription groups. There will be some overhead for regex
> > > subscriptions, but this can save the potential extra round of metadata
> > > fetch and will only occur when consumer see metadata change, which is
> > > infrequent.
> > >
> > > Any thoughts?
> > >
> > > Thanks,
> > >
> > > Jiangjie (Becket) Qin
> > >
> > >
> > > On Fri, Aug 14, 2015 at 12:57 PM, Ewen Cheslack-Postava <
> > ewen@confluent.io
> > > >
> > > wrote:
> > >
> > > > On Fri, Aug 14, 2015 at 10:59 AM, Jiangjie Qin
> > <jqin@linkedin.com.invalid
> > > >
> > > > wrote:
> > > >
> > > > > Neha and Ewen,
> > > > >
> > > > > About the metadata change frequency. I guess it really depends on
> how
> > > > > frequent the metadata change might occur. If we run Kafka as a
> > > service, I
> > > > > can see that happens from time to time. As I can imagine people
> will
> > > > create
> > > > > some topic, test and maybe delete the topic in some automated test.
> > If
> > > > so,
> > > > > the proposed protocol might be a little bit vulnerable.
> > > > >
> > > > > More specifically the scenario I am thinking is:
> > > > > 1. Consumer 0 periodically refresh metadata and detected a metadata
> > > > change.
> > > > > So it sends a JoinGroupRequest with metadata_hash_0.
> > > > > 2. Consumer 1 was notified by controller to start a rebalance, so
> it
> > > > > refreshes its metadata and send a JoingGroupRequest with
> > > metadata_hash_1,
> > > > > which is different from metadata hash 0.
> > > > > 3. Rebalance failed and both consumer refresh there metadata again
> > from
> > > > > different brokers.
> > > > > 4. Depending on the metadata change frequency(or some admin
> operation
> > > > like
> > > > > partition reassigment), they may or may not have the same metadata
> > > > > returned, so the restart from 3 again.
> > > > >
> > > > > I agree that step 4 might not be a big concern if consumers updates
> > > > > metadata at almost the same time, but I'm a little bit worried
> > whether
> > > > that
> > > > > assumption really stands because we do not have control over how
> > > frequent
> > > > > the metadata can change.
> > > > >
> > > > >
> > > > Is this really that different from what would happen if the
> coordinator
> > > > distributed the metadata to consumers? In that case you would
> trivially
> > > > have everyone in a consistent state, but those metadata changes would
> > > still
> > > > cause churn and require JoinGroup rounds, during which processing is
> > > > stalled for the nodes that are waiting on other members to re-join
> the
> > > > group.
> > > >
> > > > -Ewen
> > > >
> > > >
> > > > > Thanks,
> > > > >
> > > > > Jiangjie (Becket) Qin
> > > > >
> > > > > On Fri, Aug 14, 2015 at 2:03 AM, Ewen Cheslack-Postava <
> > > > ewen@confluent.io>
> > > > > wrote:
> > > > >
> > > > > > On Thu, Aug 13, 2015 at 11:07 PM, Neha Narkhede <
> neha@confluent.io
> > >
> > > > > wrote:
> > > > > >
> > > > > > > Becket,
> > > > > > >
> > > > > > > As you say, the metadata hash addresses the concern you
> > originally
> > > > > raised
> > > > > > > about large topic subscriptions. Can you please list other
> > problems
> > > > you
> > > > > > are
> > > > > > > raising more clearly? It is more helpful to know problems that
> > the
> > > > > > proposal
> > > > > > > does not address or addresses poorly.
> > > > > > >
> > > > > > > Regarding other things you said -
> > > > > > >
> > > > > > > it is required that each
> > > > > > > > consumer refresh their metadata before sending a
> > JoinGroupRequest
> > > > > > > >
> > > > > > >
> > > > > > > This is required for wildcard topic subscriptions anyway. So
> this
> > > > > > proposal
> > > > > > > does not introduce a regression. We had agreed earlier that it
> > does
> > > > not
> > > > > > > make sense for the server to deserialize regular expressions
> sent
> > > by
> > > > > the
> > > > > > > consumer.
> > > > > > >
> > > > > >
> > > > > > I don't think consumers need to do a metadata refresh before
> > sending
> > > a
> > > > > > JoinGroupRequest. Metadata changes that affect assignment are
> rare
> > --
> > > > it
> > > > > > requires changing the number of partitions in a topic. But you
> > might
> > > > > send a
> > > > > > JoinGroupRequest simply because a new member is trying to join
> the
> > > > group.
> > > > > > That case is presumably much more common.
> > > > > >
> > > > > > I think it's actually a good idea to have the first JoinGroup
> cycle
> > > > fail
> > > > > in
> > > > > > some cases, and has little impact. Lets say the metadata does
> > change
> > > > > > because partitions are added. Then we might fail in the first
> > round,
> > > > but
> > > > > > then all members detect that issue *immediately*, refresh their
> > > > metadata,
> > > > > > and submit a new join group request. This second cycle does not
> > > > require a
> > > > > > full heartbeat cycle. It happens much more quickly because
> everyone
> > > > > > detected the inconsistency based on the first JoinGroupResponse.
> > The
> > > > > > inconsistency should be resolved very quickly (barring other
> > failures
> > > > > like
> > > > > > a member leaving mid-rebalance)
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > > >
> > > > > > >
> > > > > > > > the metadata might still be inconsistent if there is a topic
> or
> > > > > > partition
> > > > > > > > change because the
> > > > > > > > UpdateMetadataRequest from controller might be handled at
> > > different
> > > > > > time.
> > > > > > > >
> > > > > > >
> > > > > > > Topic metadata does not change frequently and even if it did, a
> > > > couple
> > > > > > > rebalance attempts will be needed whether the coordinator
> drives
> > > the
> > > > > > > assignments or the consumer. Because guess how the coordinator
> > > knows
> > > > > > about
> > > > > > > the topic metadata changes -- indirectly through either a zk
> > > callback
> > > > > or
> > > > > > > UpdateMetadataRequest, so it is completely possible the
> > coordinator
> > > > > sees
> > > > > > > the topic metadata changes in batches, not all at once.
> > > > > > >
> > > > > >
> > > > > > > On Thu, Aug 13, 2015 at 10:50 PM, Neha Narkhede <
> > neha@confluent.io
> > > >
> > > > > > wrote:
> > > > > > >
> > > > > > > > Ewen/Jason,
> > > > > > > >
> > > > > > > > The metadata hash is a clever approach and certainly
> addresses
> > > the
> > > > > > > problem
> > > > > > > > of large metadata for consumers like mirror maker. Few
> > comments -
> > > > > > > >
> > > > > > > >
> > > > > > > >    1. In the interest of simplifying the format of the
> > consumer's
> > > > > > > >    metadata - Why not just always include only the topic
> names
> > in
> > > > the
> > > > > > > metadata
> > > > > > > >    followed by the metadata hash? If the metadata hash check
> > > > > succeeds,
> > > > > > > each
> > > > > > > >    consumer uses the # of partitions it had fetched. If it
> > > fails, a
> > > > > > > rebalance
> > > > > > > >    happens and the metadata is not used anyway.
> > > > > > >
> > > > > >
> > > > > > Doing this requires that every consumer always fetch the full
> > > metadata.
> > > > > The
> > > > > > most common use case is consumers that just want to consume one
> or
> > a
> > > > > couple
> > > > > > of topics, in which case grabbing all metadata for the entire
> > cluster
> > > > is
> > > > > > wasteful. If I subscribe only to topic A, why make all consumers
> > grab
> > > > > > metadata for the entire topic (and need to rebalance every time
> it
> > > > > > changes!). Including the # of partitions for each topic lets you
> > > avoid
> > > > > > having to grab the global set of metadata.
> > > > > >
> > > > > > So if you're just subscribing to one or a couple of topics, why
> not
> > > > just
> > > > > > compute the hash by filtering out everything but the topics you
> are
> > > > > > subscribed to? The problem there is if you ever add/remove
> > > > subscriptions
> > > > > > and want to support rolling upgrades. If the group was subscribed
> > to
> > > > > topic
> > > > > > A, but later changes require subscribing to A + B, then to
> achieve
> > a
> > > > > > seamless rolling upgrade would require one (old) consumer to be
> > > > > subscribing
> > > > > > to A and one (new) consumer to be subscribing to A+B. If we
> > computed
> > > > > > metadata hashes based on filtered metadata, those two would
> > disagree
> > > > and
> > > > > we
> > > > > > could not perform assignment while the upgrade was in progress.
> > > > > >
> > > > > > The solution is to differentiate between the cases when a very
> > small
> > > > > amount
> > > > > > of the metadata is needed (one or a couple of topic
> subscriptions;
> > > > > > communicate and share this via metadata in the JoinGroup
> protocol)
> > vs
> > > > > when
> > > > > > *all* the metadata is needed (regex subscription; verify
> agreement
> > > via
> > > > > > hash).
> > > > > >
> > > > >
> > > > > >
> > > > > >
> > > > > > > >    2. Do you need a topic list and topic regex to be
> separate?
> > A
> > > > > single
> > > > > > > >    topic or list of topics can be expressed as a regex.
> > > > > > >
> > > > > >
> > > > > > See above note about collecting all metadata when you really only
> > > need
> > > > it
> > > > > > for 1 or 2 topics. There's probably some debate to be had about
> > > whether
> > > > > > this cost would be too high -- every consumer would need to
> request
> > > the
> > > > > > metadata for all topics, and they'd need to request that all
> every
> > > time
> > > > > > they might be out of date.
> > > > > >
> > > > > Are we going to allow consumers in the same group to subscribe to
> > > > different
> > > > > topic set? If we do, we need to let them refresh metadata for all
> the
> > > > > topics a group is consuming from. If we don't then in the protocol
> we
> > > > only
> > > > > need a subscription set hash.
> > > > >
> > > > > >
> > > > > >
> > > > > > > >    3. Let's include a version explicitly at the beginning of
> > the
> > > > > > > >    ProtocolMetadata. The version dictates how to deserialize
> > the
> > > > > > > >    ProtocolMetadata blob and is consistent with the rest of
> > > Kafka.
> > > > > > >
> > > > > >
> > > > > > If I'm understanding correctly, in JoinGroupRequest I would
> change
> > > > > >
> > > > > > GroupProtocols          => [Protocol ProtocolMetadata]
> > > > > >
> > > > > > to
> > > > > >
> > > > > > GroupProtocols          => [Protocol ProtocolVersion
> > > ProtocolMetadata]
> > > > > >
> > > > > > We had been talking about just baking the version into the
> Protocol
> > > > > field,
> > > > > > but making it separate seems perfectly reasonable to me. Jason,
> any
> > > > issue
> > > > > > with splitting the version out into a separate field like this?
> > > > > >
> > > > > > >
> > > > > > > > That can simplify the metadata format to the following:
> > > > > > > >
> > > > > > > > GroupType => "consumer"
> > > > > > > >>
> > > > > > > >> Protocol => AssignmentStrategy
> > > > > > > >>   AssignmentStrategy   => String
> > > > > > > >>
> > > > > > > >> ProtocolMetadata => Version Subscription
> > > > AssignmentStrategyMetadata
> > > > > > > >
> > > > > > > >     Version                    => String
> > > > > > > >
> > > > > > > >   Subscription                 => TopicRegex MetadataHash
> > > > > > > >>     TopicRegex                 => String
> > > > > > > >>     MetadataHash               => String
> > > > > > > >>   AssignmentStrategyMetadata   => bytes
> > > > > > >
> > > > > > >
> > > > > > > >
> > > > > > > > On Thu, Aug 13, 2015 at 6:28 PM, Jiangjie Qin
> > > > > > <jqin@linkedin.com.invalid
> > > > > > > >
> > > > > > > > wrote:
> > > > > > > >
> > > > > > > >> Ewen and Jason,
> > > > > > > >>
> > > > > > > >> Thanks for the reply. Sorry I missed the metadata hash. Yes,
> > > that
> > > > > is a
> > > > > > > >> clever approach and would solve my concern about the data
> > > passing
> > > > > > > around.
> > > > > > > >> I
> > > > > > > >> can see both pros and cons from doing this, though. The
> > > advantage
> > > > is
> > > > > > we
> > > > > > > >> don't need the topic metadata in JoinGroupResponse anymore.
> > The
> > > > > > downside
> > > > > > > >> is
> > > > > > > >> that now rebalance have extra dependency on the consensus of
> > > > > metadata
> > > > > > of
> > > > > > > >> all consumers, which is obtained separately. So it is
> required
> > > > that
> > > > > > each
> > > > > > > >> consumer refresh their metadata before sending a
> > > JoinGroupRequest,
> > > > > > > >> otherwise in some cases (e.g. wildcard consumers) will
> almost
> > > > > > certainly
> > > > > > > >> fail for the first rebalance attempt. Even if we do that,
> > since
> > > > the
> > > > > > > >> consumers are getting metadata from different brokers, the
> > > > metadata
> > > > > > > might
> > > > > > > >> still be inconsistent if there is a topic or partition
> change
> > > > > because
> > > > > > > the
> > > > > > > >> UpdateMetadataRequest from controller might be handled at
> > > > different
> > > > > > > time.
> > > > > > > >> Just want to make sure we think through the cases so the
> > > protocol
> > > > > does
> > > > > > > not
> > > > > > > >> cause us unexpected issues.
> > > > > > > >>
> > > > > > > >> About the number of consumers, I think with the current
> > > liveliness
> > > > > > > >> definition, we can tolerate churns by bumping up the session
> > > > > timeout.
> > > > > > > Also
> > > > > > > >> I guess we will see an increasing number of consumers for
> new
> > > > > > consumer,
> > > > > > > >> because every the old consumer thread will probably become a
> > > > > consumer.
> > > > > > > >>
> > > > > > > >> It is a valid concern for consumers that have large
> > subscription
> > > > > set.
> > > > > > > This
> > > > > > > >> might not be avoided though for client side assignment
> > approach.
> > > > One
> > > > > > > >> solution is having topic names associate with a topic ID.
> And
> > > only
> > > > > use
> > > > > > > >> topic ID in JoinGroupRequest and JoinGroupResponse, There
> is a
> > > > > > > discussion
> > > > > > > >> thread about this to solve the topic renaming case but this
> > is a
> > > > > > > >> completely
> > > > > > > >> different discussion.
> > > > > > > >>
> > > > > > > >> Thanks,
> > > > > > > >>
> > > > > > > >> Jiangjie (Becket) Qin
> > > > > > > >>
> > > > > > > >>
> > > > > > > >>
> > > > > > > >> On Thu, Aug 13, 2015 at 2:14 PM, Jason Gustafson <
> > > > > jason@confluent.io>
> > > > > > > >> wrote:
> > > > > > > >>
> > > > > > > >> > Thanks Jiangjie, that information helps. I agree the
> > protocol
> > > > must
> > > > > > > >> consider
> > > > > > > >> > scalability. My point was that the synchronization barrier
> > in
> > > > the
> > > > > > > >> current
> > > > > > > >> > protocol already effectively limits the number of
> consumers
> > > > since
> > > > > it
> > > > > > > >> > provides no way to gracefully handle churn. It wouldn't be
> > > worth
> > > > > > > >> worrying
> > > > > > > >> > about scaling up to 100,000 members, for example, because
> > > > there's
> > > > > no
> > > > > > > way
> > > > > > > >> > the group would be stable. So we just need to set some
> clear
> > > > > > > >> expectations
> > > > > > > >> > on the size we can scale to, and that can help inform the
> > > > > discussion
> > > > > > > on
> > > > > > > >> the
> > > > > > > >> > size of messages in this protocol.
> > > > > > > >> >
> > > > > > > >> > Ewen and I were discussing this morning along similar
> lines
> > to
> > > > > what
> > > > > > > >> you're
> > > > > > > >> > suggesting. However, even if the coordinator decides on
> the
> > > > > metadata
> > > > > > > for
> > > > > > > >> > the group, each member still needs to communicate its
> > > > > subscriptions
> > > > > > to
> > > > > > > >> the
> > > > > > > >> > rest of the group. This is nice for the regex case since
> the
> > > > regex
> > > > > > is
> > > > > > > >> > probably small, but if the members have a large topic
> list,
> > > then
> > > > > we
> > > > > > > have
> > > > > > > >> > the same problem. One thing I was thinking about was
> whether
> > > we
> > > > > > really
> > > > > > > >> need
> > > > > > > >> > to handle different subscriptions for every member. If the
> > > > > > coordinator
> > > > > > > >> > could guarantee that all members had the same
> subscription,
> > > then
> > > > > > there
> > > > > > > >> > would be no need for the coordinator to return the
> > > subscriptions
> > > > > for
> > > > > > > >> each
> > > > > > > >> > member. However, this would prevent graceful upgrades. We
> > > might
> > > > be
> > > > > > > able
> > > > > > > >> to
> > > > > > > >> > fix that problem by allowing the consumer to provide two
> > > > > > subscriptions
> > > > > > > >> to
> > > > > > > >> > allowing rolling updates, but that starts to sound pretty
> > > nasty.
> > > > > > > >> >
> > > > > > > >> > -Jason
> > > > > > > >> >
> > > > > > > >> > On Thu, Aug 13, 2015 at 1:41 PM, Jiangjie Qin
> > > > > > > <jqin@linkedin.com.invalid
> > > > > > > >> >
> > > > > > > >> > wrote:
> > > > > > > >> >
> > > > > > > >> > > Jason,
> > > > > > > >> > >
> > > > > > > >> > > The protocol has to consider the scalability. The
> protocol
> > > in
> > > > > the
> > > > > > > wiki
> > > > > > > >> > > means the JoinGroupResoponse size would be:
> > > > > > > >> > > NumberOfTopics * (AvgTopicNameLength + 4) *
> > > > > (NumberOfConsumers)^2
> > > > > > > >> > >
> > > > > > > >> > > To give some real number, we have 26-node Mirror Maker
> > > > cluster,
> > > > > > each
> > > > > > > >> > with 4
> > > > > > > >> > > consumers. That is 104 consumers using regex ".*". And
> > most
> > > of
> > > > > our
> > > > > > > >> > clusters
> > > > > > > >> > > have around 3000 topics, whose topic name are typically
> > > around
> > > > > 20
> > > > > > > >> > > characters.
> > > > > > > >> > >
> > > > > > > >> > > I think the key issue for client side partition
> assignment
> > > > logic
> > > > > > is
> > > > > > > to
> > > > > > > >> > make
> > > > > > > >> > > sure 1) all the clients run the same algorithm. 2) all
> the
> > > > > clients
> > > > > > > >> make
> > > > > > > >> > > decision on the same topic metadata. The second purpose
> > can
> > > be
> > > > > > done
> > > > > > > by
> > > > > > > >> > > simply letting coordinator provide the topic metadata
> and
> > > all
> > > > > then
> > > > > > > >> member
> > > > > > > >> > > information as source of truth. Is it necessary to pass
> > > topic
> > > > > > > >> metadata of
> > > > > > > >> > > each consumer around? Can we keep the protocol metadata
> > > field
> > > > > > > >> completely
> > > > > > > >> > > independent of topic metadata? I think In the
> > > > JoinGroupResponse,
> > > > > > we
> > > > > > > >> > should
> > > > > > > >> > > have only one copy of topic metadata provided by
> > coordinator
> > > > and
> > > > > > is
> > > > > > > >> > outside
> > > > > > > >> > > of protocol metadata. If user decides to put some
> metadata
> > > in
> > > > > the
> > > > > > > >> > > JoinGroupRequest and let coordinator pass around, they
> are
> > > > > > > responsible
> > > > > > > >> > for
> > > > > > > >> > > understanding the risk.
> > > > > > > >> > >
> > > > > > > >> > > Thanks,
> > > > > > > >> > >
> > > > > > > >> > > Jiangjie (Becket) Qin
> > > > > > > >> > >
> > > > > > > >> > >
> > > > > > > >> > > On Thu, Aug 13, 2015 at 12:41 PM, Jason Gustafson <
> > > > > > > jason@confluent.io
> > > > > > > >> >
> > > > > > > >> > > wrote:
> > > > > > > >> > >
> > > > > > > >> > > > Hey Onur and Jiangjie,
> > > > > > > >> > > >
> > > > > > > >> > > > I've updated that wiki with a proposal to add regex
> > > > > > subscriptions
> > > > > > > to
> > > > > > > >> > the
> > > > > > > >> > > > consumer metadata. Can you have a look to see if it
> > > > addresses
> > > > > > your
> > > > > > > >> > > concern?
> > > > > > > >> > > > In general, I think we should be a little careful when
> > we
> > > > are
> > > > > > > >> talking
> > > > > > > >> > > about
> > > > > > > >> > > > the scalability of the protocol. Regardless of whether
> > > > > > assignment
> > > > > > > is
> > > > > > > >> > done
> > > > > > > >> > > > on the server or the client, the protocol assumes a
> > > > relatively
> > > > > > > >> stable
> > > > > > > >> > > > configuration. When the number of consumers increases
> > > > beyond a
> > > > > > > >> certain
> > > > > > > >> > > > limit, then membership churn becomes a major concern.
> > > > > Similarly
> > > > > > > >> there
> > > > > > > >> > is
> > > > > > > >> > > a
> > > > > > > >> > > > notion of metadata churn when topics are added,
> deleted,
> > > or
> > > > > > > >> resized. If
> > > > > > > >> > > > either membership or metadata changes, then the
> protocol
> > > > > forces
> > > > > > > all
> > > > > > > >> > > > consumers to stop consumption and rejoin the group. If
> > > this
> > > > > > > happens
> > > > > > > >> > often
> > > > > > > >> > > > enough, then it can severely impact the ability of the
> > > > > consumer
> > > > > > to
> > > > > > > >> make
> > > > > > > >> > > > progress. The point is that the protocol may already
> be
> > > > > unsuited
> > > > > > > to
> > > > > > > >> > cases
> > > > > > > >> > > > where there are either a large number of consumers or
> > > > topics.
> > > > > I
> > > > > > > >> wonder
> > > > > > > >> > if
> > > > > > > >> > > > you guys can share your thoughts about your scaling
> > > > > > expectations?
> > > > > > > >> > > >
> > > > > > > >> > > > -Jason
> > > > > > > >> > > >
> > > > > > > >> > > >
> > > > > > > >> > > >
> > > > > > > >> > > >
> > > > > > > >> > > > On Wed, Aug 12, 2015 at 12:28 PM, Jason Gustafson <
> > > > > > > >> jason@confluent.io>
> > > > > > > >> > > > wrote:
> > > > > > > >> > > >
> > > > > > > >> > > > > Hey Jiangjie,
> > > > > > > >> > > > >
> > > > > > > >> > > > > That's a great point. In the worst case (the mirror
> > > maker
> > > > > > case I
> > > > > > > >> > > guess),
> > > > > > > >> > > > > the join group response can be massive. This would
> be
> > > > > > especially
> > > > > > > >> > deadly
> > > > > > > >> > > > > when there is a lot of churn in the group (e.g. in a
> > > > rolling
> > > > > > > >> > upgrade).
> > > > > > > >> > > > The
> > > > > > > >> > > > > current protocol is not great for this case either,
> > but
> > > > it's
> > > > > > > >> > > > significantly
> > > > > > > >> > > > > better. Here are a couple ways to deal with the
> size:
> > > > > > > >> > > > >
> > > > > > > >> > > > > 1. First, we could have the coordinator compress the
> > > > > > responses.
> > > > > > > >> This
> > > > > > > >> > > > would
> > > > > > > >> > > > > probably be pretty effective if applied across the
> > > > metadata
> > > > > > from
> > > > > > > >> all
> > > > > > > >> > > > > members.
> > > > > > > >> > > > >
> > > > > > > >> > > > > 2. I think the regex case is the main problem. Is
> that
> > > > > right?
> > > > > > We
> > > > > > > >> > could
> > > > > > > >> > > > > extend the metadata to allow the consumer to embed
> its
> > > > regex
> > > > > > > >> > > subscription
> > > > > > > >> > > > > in the metadata directly (note this might be a good
> > idea
> > > > > > > >> regardless
> > > > > > > >> > of
> > > > > > > >> > > > the
> > > > > > > >> > > > > rest of this proposal). To support regex on the
> > > consumer,
> > > > we
> > > > > > > must
> > > > > > > >> > fetch
> > > > > > > >> > > > > metadata for all topics. Rather than having all
> regex
> > > > > > > subscribers
> > > > > > > >> > embed
> > > > > > > >> > > > all
> > > > > > > >> > > > > of this metadata in their join group requests, they
> > > could
> > > > > > > instead
> > > > > > > >> > > embed a
> > > > > > > >> > > > > hash of it. Then after the join group responses are
> > > > > received,
> > > > > > > they
> > > > > > > >> > just
> > > > > > > >> > > > > need to check that the hashes are the same. If there
> > is
> > > a
> > > > > > > mismatch
> > > > > > > >> > > (which
> > > > > > > >> > > > > should only occur when topics are created, deleted,
> or
> > > > > > resized),
> > > > > > > >> then
> > > > > > > >> > > the
> > > > > > > >> > > > > group members must refetch the metadata and rejoin
> the
> > > > > group.
> > > > > > > >> This is
> > > > > > > >> > > > also
> > > > > > > >> > > > > how the current protocol behaves when there is a
> > change
> > > in
> > > > > the
> > > > > > > >> topic
> > > > > > > >> > > > > metadata affecting the group--someone (either the
> > > > > coordinator
> > > > > > or
> > > > > > > >> the
> > > > > > > >> > > > > consumer) detects the change and forces the group to
> > > > > > rebalance.
> > > > > > > >> > > > >
> > > > > > > >> > > > > What do you think?
> > > > > > > >> > > > >
> > > > > > > >> > > > > (Also I think adding groupId/generationId to fetch
> and
> > > > > produce
> > > > > > > >> > requests
> > > > > > > >> > > > > seems like an interesting line of thought.)
> > > > > > > >> > > > >
> > > > > > > >> > > > > -Jason
> > > > > > > >> > > > >
> > > > > > > >> > > > >
> > > > > > > >> > > > >
> > > > > > > >> > > > > On Wed, Aug 12, 2015 at 10:57 AM, Jiangjie Qin
> > > > > > > >> > > <jqin@linkedin.com.invalid
> > > > > > > >> > > > >
> > > > > > > >> > > > > wrote:
> > > > > > > >> > > > >
> > > > > > > >> > > > >> Hey Ewen,
> > > > > > > >> > > > >>
> > > > > > > >> > > > >> Onur and I discussed this a little bit more. And we
> > are
> > > > > still
> > > > > > > >> > worrying
> > > > > > > >> > > > >> about passing all the metadata of all consumers
> > around.
> > > > > > > >> > > > >>
> > > > > > > >> > > > >> Let's say I have a cluster has 10,000 topics, the
> > > average
> > > > > > topic
> > > > > > > >> name
> > > > > > > >> > > > >> length
> > > > > > > >> > > > >> is 10 bytes. In this case, the opaque metadata will
> > > have
> > > > > 10 *
> > > > > > > >> > 10,000 =
> > > > > > > >> > > > >> 100KB for topic name, for each topic, there is a
> > 4-byte
> > > > > > integer
> > > > > > > >> of
> > > > > > > >> > > > number
> > > > > > > >> > > > >> of partitions, that's another 40KB. So one global
> > topic
> > > > > > > metadata
> > > > > > > >> > will
> > > > > > > >> > > > have
> > > > > > > >> > > > >> 140KB data. If I have 100 consumers who are using
> > > > wildcard
> > > > > to
> > > > > > > >> > consume
> > > > > > > >> > > > from
> > > > > > > >> > > > >> all the topics. That means the protocol metadata
> end
> > up
> > > > in
> > > > > > the
> > > > > > > >> > > > >> JoinGroupResponse will be 140KB * 100 = 14MB. And
> the
> > > > > > > >> > > JoinGroupResponse
> > > > > > > >> > > > >> will need to be sent to 100 different consumers,
> that
> > > > means
> > > > > > > 14MB
> > > > > > > >> *
> > > > > > > >> > > 100 =
> > > > > > > >> > > > >> 1.4GB need to be sent by the consumer coordinator
> for
> > > one
> > > > > > > >> rebalance.
> > > > > > > >> > > How
> > > > > > > >> > > > >> would that work?
> > > > > > > >> > > > >>
> > > > > > > >> > > > >> Also, having two consumers (old owner and new
> owner)
> > > > > > consuming
> > > > > > > >> from
> > > > > > > >> > > the
> > > > > > > >> > > > >> same partition might also be a problem. e.g. people
> > are
> > > > > > > updating
> > > > > > > >> > > > database.
> > > > > > > >> > > > >> One thing might worth doing is to add GroupId and
> > > > > Generation
> > > > > > ID
> > > > > > > >> to
> > > > > > > >> > > > >> ProducerRequest and FetchRequest as well. This will
> > > also
> > > > > help
> > > > > > > >> with
> > > > > > > >> > the
> > > > > > > >> > > > >> single producer use case. However, this is probably
> > > > > > orthogonal
> > > > > > > to
> > > > > > > >> > this
> > > > > > > >> > > > >> thread given the current new consumer also has this
> > > > problem
> > > > > > > and I
> > > > > > > >> > > > believe
> > > > > > > >> > > > >> we need to fix it.
> > > > > > > >> > > > >>
> > > > > > > >> > > > >> Thanks,
> > > > > > > >> > > > >>
> > > > > > > >> > > > >> Jiangjie (Becket) Qin
> > > > > > > >> > > > >>
> > > > > > > >> > > > >> On Tue, Aug 11, 2015 at 11:43 PM, Ewen
> > > Cheslack-Postava <
> > > > > > > >> > > > >> ewen@confluent.io>
> > > > > > > >> > > > >> wrote:
> > > > > > > >> > > > >>
> > > > > > > >> > > > >> > On Tue, Aug 11, 2015 at 11:29 PM, Jiangjie Qin
> > > > > > > >> > > > >> <jq...@linkedin.com.invalid>
> > > > > > > >> > > > >> > wrote:
> > > > > > > >> > > > >> >
> > > > > > > >> > > > >> > > Ewen,
> > > > > > > >> > > > >> > >
> > > > > > > >> > > > >> > > Thanks for the explanation.
> > > > > > > >> > > > >> > >
> > > > > > > >> > > > >> > > For (1), I am more concerned about the failure
> > case
> > > > > > instead
> > > > > > > >> of
> > > > > > > >> > > > normal
> > > > > > > >> > > > >> > case.
> > > > > > > >> > > > >> > > What if a consumer somehow was kick out of a
> > group
> > > > but
> > > > > is
> > > > > > > >> still
> > > > > > > >> > > > >> consuming
> > > > > > > >> > > > >> > > and committing offsets? Does that mean the new
> > > owner
> > > > > and
> > > > > > > old
> > > > > > > >> > owner
> > > > > > > >> > > > >> might
> > > > > > > >> > > > >> > > potentially consuming from and committing
> offsets
> > > for
> > > > > the
> > > > > > > >> same
> > > > > > > >> > > > >> partition?
> > > > > > > >> > > > >> > > In the old consumer, this won't happen because
> > the
> > > > new
> > > > > > > >> consumer
> > > > > > > >> > > will
> > > > > > > >> > > > >> not
> > > > > > > >> > > > >> > be
> > > > > > > >> > > > >> > > able to start consumption unless the previous
> > owner
> > > > has
> > > > > > > >> released
> > > > > > > >> > > its
> > > > > > > >> > > > >> > > ownership. Basically, without the ownership
> > > > guarantee,
> > > > > I
> > > > > > > >> don't
> > > > > > > >> > see
> > > > > > > >> > > > how
> > > > > > > >> > > > >> > the
> > > > > > > >> > > > >> > > communication among consumers themselves alone
> > can
> > > > > solve
> > > > > > > the
> > > > > > > >> > > problem
> > > > > > > >> > > > >> > here.
> > > > > > > >> > > > >> > >
> > > > > > > >> > > > >> >
> > > > > > > >> > > > >> > The generation ID check still applies to offset
> > > > commits.
> > > > > If
> > > > > > > >> one of
> > > > > > > >> > > the
> > > > > > > >> > > > >> > consumers is kicked out and misbehaving, it can
> > > > obviously
> > > > > > > still
> > > > > > > >> > > fetch
> > > > > > > >> > > > >> and
> > > > > > > >> > > > >> > process messages, but offset commits will not
> work
> > > > since
> > > > > it
> > > > > > > >> will
> > > > > > > >> > not
> > > > > > > >> > > > >> have
> > > > > > > >> > > > >> > the current generation ID.
> > > > > > > >> > > > >> >
> > > > > > > >> > > > >> >
> > > > > > > >> > > > >> > >
> > > > > > > >> > > > >> > > For (2) and (3), now I understand how metadata
> > are
> > > > > used.
> > > > > > > But
> > > > > > > >> I
> > > > > > > >> > > still
> > > > > > > >> > > > >> > don't
> > > > > > > >> > > > >> > > see why should we let the consumers to pass the
> > > topic
> > > > > > > >> > information
> > > > > > > >> > > > >> across
> > > > > > > >> > > > >> > > instead of letting coordinator give the
> > > information.
> > > > > The
> > > > > > > >> single
> > > > > > > >> > > > >> producer
> > > > > > > >> > > > >> > > use case does not solve the ownership problem
> in
> > > > > abnormal
> > > > > > > >> case
> > > > > > > >> > > > either,
> > > > > > > >> > > > >> > > which seems to be a little bit vulnerable.
> > > > > > > >> > > > >> > >
> > > > > > > >> > > > >> >
> > > > > > > >> > > > >> > One of the goals here was to generalize group
> > > > membership
> > > > > so
> > > > > > > we
> > > > > > > >> > can,
> > > > > > > >> > > > for
> > > > > > > >> > > > >> > example, use it for balancing Copycat tasks
> across
> > > > > workers.
> > > > > > > >> > There's
> > > > > > > >> > > no
> > > > > > > >> > > > >> > topic subscription info in that case. The
> metadata
> > > for
> > > > > > > copycat
> > > > > > > >> > > workers
> > > > > > > >> > > > >> > would instead need to somehow indicate the
> current
> > > set
> > > > of
> > > > > > > tasks
> > > > > > > >> > that
> > > > > > > >> > > > >> need
> > > > > > > >> > > > >> > to be assigned to workers. By making the metadata
> > > > > > completely
> > > > > > > >> > opaque
> > > > > > > >> > > to
> > > > > > > >> > > > >> the
> > > > > > > >> > > > >> > protocol, it becomes more generally useful since
> it
> > > > > focuses
> > > > > > > >> > squarely
> > > > > > > >> > > > on
> > > > > > > >> > > > >> the
> > > > > > > >> > > > >> > group membership problem, allowing for that
> > > additional
> > > > > bit
> > > > > > of
> > > > > > > >> > > metadata
> > > > > > > >> > > > >> so
> > > > > > > >> > > > >> > you don't just get a list of members, but also
> get
> > a
> > > > > little
> > > > > > > >> bit of
> > > > > > > >> > > > info
> > > > > > > >> > > > >> > about each of them.
> > > > > > > >> > > > >> >
> > > > > > > >> > > > >> > A different option that we explored is to use a
> > sort
> > > of
> > > > > > mixed
> > > > > > > >> > model
> > > > > > > >> > > --
> > > > > > > >> > > > >> > still bake all the topic subscriptions directly
> > into
> > > > the
> > > > > > > >> protocol
> > > > > > > >> > > but
> > > > > > > >> > > > >> also
> > > > > > > >> > > > >> > include metadata. That would allow us to maintain
> > the
> > > > > > > existing
> > > > > > > >> > > > >> > coordinator-driven approach to handling the
> > metadata
> > > > and
> > > > > > > change
> > > > > > > >> > > events
> > > > > > > >> > > > >> like
> > > > > > > >> > > > >> > the ones Onur pointed out. Then something like
> the
> > > > > Copycat
> > > > > > > >> workers
> > > > > > > >> > > > would
> > > > > > > >> > > > >> > just not fill in any topic subscriptions and it
> > would
> > > > be
> > > > > > > >> handled
> > > > > > > >> > as
> > > > > > > >> > > a
> > > > > > > >> > > > >> > degenerate case. Based on the way I explained
> that
> > we
> > > > can
> > > > > > > >> handle
> > > > > > > >> > > those
> > > > > > > >> > > > >> > types of events, I personally feel its cleaner
> and
> > a
> > > > > nicer
> > > > > > > >> > > > >> generalization
> > > > > > > >> > > > >> > to not include the subscriptions in the join
> group
> > > > > > protocol,
> > > > > > > >> > making
> > > > > > > >> > > it
> > > > > > > >> > > > >> part
> > > > > > > >> > > > >> > of the metadata instead.
> > > > > > > >> > > > >> >
> > > > > > > >> > > > >> > For the single producer case, are you saying it
> > > doesn't
> > > > > > solve
> > > > > > > >> > > > ownership
> > > > > > > >> > > > >> in
> > > > > > > >> > > > >> > the abnormal case because a producer that doesn't
> > > know
> > > > it
> > > > > > has
> > > > > > > >> been
> > > > > > > >> > > > >> kicked
> > > > > > > >> > > > >> > out of the group yet can still produce data even
> > > though
> > > > > it
> > > > > > > >> > shouldn't
> > > > > > > >> > > > be
> > > > > > > >> > > > >> > able to anymore? I definitely agree that that is
> a
> > > risk
> > > > > --
> > > > > > > this
> > > > > > > >> > > > >> provides a
> > > > > > > >> > > > >> > way to get closer to a true single-writer, but
> > there
> > > > are
> > > > > > > >> > definitely
> > > > > > > >> > > > >> still
> > > > > > > >> > > > >> > failure modes that this does not address.
> > > > > > > >> > > > >> >
> > > > > > > >> > > > >> > -Ewen
> > > > > > > >> > > > >> >
> > > > > > > >> > > > >> >
> > > > > > > >> > > > >> > >
> > > > > > > >> > > > >> > > Thanks,
> > > > > > > >> > > > >> > >
> > > > > > > >> > > > >> > > Jiangjie (Becket) Qin
> > > > > > > >> > > > >> > >
> > > > > > > >> > > > >> > >
> > > > > > > >> > > > >> > > On Tue, Aug 11, 2015 at 11:06 PM, Ewen
> > > > > Cheslack-Postava <
> > > > > > > >> > > > >> > ewen@confluent.io
> > > > > > > >> > > > >> > > >
> > > > > > > >> > > > >> > > wrote:
> > > > > > > >> > > > >> > >
> > > > > > > >> > > > >> > > > On Tue, Aug 11, 2015 at 10:15 PM, Jiangjie
> Qin
> > > > > > > >> > > > >> > <jqin@linkedin.com.invalid
> > > > > > > >> > > > >> > > >
> > > > > > > >> > > > >> > > > wrote:
> > > > > > > >> > > > >> > > >
> > > > > > > >> > > > >> > > > > Hi Jason,
> > > > > > > >> > > > >> > > > >
> > > > > > > >> > > > >> > > > > Thanks for writing this up. It would be
> > useful
> > > to
> > > > > > > >> generalize
> > > > > > > >> > > the
> > > > > > > >> > > > >> > group
> > > > > > > >> > > > >> > > > > concept. I have a few questions below.
> > > > > > > >> > > > >> > > > >
> > > > > > > >> > > > >> > > > > 1. In old consumer actually the partition
> > > > > assignment
> > > > > > > are
> > > > > > > >> > done
> > > > > > > >> > > by
> > > > > > > >> > > > >> > > > consumers
> > > > > > > >> > > > >> > > > > themselves. We used zookeeper to guarantee
> > > that a
> > > > > > > >> partition
> > > > > > > >> > > will
> > > > > > > >> > > > >> only
> > > > > > > >> > > > >> > > be
> > > > > > > >> > > > >> > > > > consumed by one consumer thread who
> > > successfully
> > > > > > > claimed
> > > > > > > >> its
> > > > > > > >> > > > >> > ownership.
> > > > > > > >> > > > >> > > > > Does the new protocol plan to provide the
> > same
> > > > > > > guarantee?
> > > > > > > >> > > > >> > > > >
> > > > > > > >> > > > >> > > >
> > > > > > > >> > > > >> > > > Once you have all the metadata from all the
> > > > > consumers,
> > > > > > > >> > > assignment
> > > > > > > >> > > > >> > should
> > > > > > > >> > > > >> > > > just be a simple function mapping that
> > > > > Map<ConsumerId,
> > > > > > > >> > Metadata>
> > > > > > > >> > > > to
> > > > > > > >> > > > >> > > > Map<ConsumerId, List<TopicPartition>>. If
> > > everyone
> > > > is
> > > > > > > >> > consistent
> > > > > > > >> > > > in
> > > > > > > >> > > > >> > > > computing that, you don't need ZK involved at
> > > all.
> > > > > > > >> > > > >> > > >
> > > > > > > >> > > > >> > > > In practice, this shouldn't be that hard to
> > > ensure
> > > > > for
> > > > > > > most
> > > > > > > >> > > > >> assignment
> > > > > > > >> > > > >> > > > strategies just by having decent unit testing
> > on
> > > > > them.
> > > > > > > You
> > > > > > > >> > just
> > > > > > > >> > > > >> have to
> > > > > > > >> > > > >> > > do
> > > > > > > >> > > > >> > > > things like ensure your assignment strategy
> > sorts
> > > > > lists
> > > > > > > >> into a
> > > > > > > >> > > > >> > consistent
> > > > > > > >> > > > >> > > > order.
> > > > > > > >> > > > >> > > >
> > > > > > > >> > > > >> > > > You do give up the ability to use some
> > techniques
> > > > > (e.g.
> > > > > > > any
> > > > > > > >> > > > >> randomized
> > > > > > > >> > > > >> > > > algorithm if you can't distribute the seed w/
> > the
> > > > > > > metadata)
> > > > > > > >> > and
> > > > > > > >> > > > it's
> > > > > > > >> > > > >> > true
> > > > > > > >> > > > >> > > > that nothing validates the assignment, but if
> > > that
> > > > > > > >> assignment
> > > > > > > >> > > > >> algorithm
> > > > > > > >> > > > >> > > > step is kept simple, small, and well tested,
> > the
> > > > risk
> > > > > > is
> > > > > > > >> very
> > > > > > > >> > > > >> minimal.
> > > > > > > >> > > > >> > > >
> > > > > > > >> > > > >> > > >
> > > > > > > >> > > > >> > > > >
> > > > > > > >> > > > >> > > > > 2. It looks that both JoinGroupRequest and
> > > > > > > >> JoinGroupResponse
> > > > > > > >> > > has
> > > > > > > >> > > > >> the
> > > > > > > >> > > > >> > > > >
> ProtocolMetadata.AssignmentStrategyMetadata,
> > > what
> > > > > > would
> > > > > > > >> be
> > > > > > > >> > the
> > > > > > > >> > > > >> > metadata
> > > > > > > >> > > > >> > > > be
> > > > > > > >> > > > >> > > > > sent and returned by coordinator? How will
> > the
> > > > > > > >> coordinator
> > > > > > > >> > > > handle
> > > > > > > >> > > > >> the
> > > > > > > >> > > > >> > > > > metadata?
> > > > > > > >> > > > >> > > > >
> > > > > > > >> > > > >> > > >
> > > > > > > >> > > > >> > > > The coordinator is basically just blindly
> > > > > broadcasting
> > > > > > > all
> > > > > > > >> of
> > > > > > > >> > it
> > > > > > > >> > > > to
> > > > > > > >> > > > >> > group
> > > > > > > >> > > > >> > > > members so they have a consistent view.
> > > > > > > >> > > > >> > > >
> > > > > > > >> > > > >> > > > So from the coordinators perspective, it sees
> > > > > something
> > > > > > > >> like:
> > > > > > > >> > > > >> > > >
> > > > > > > >> > > > >> > > > Consumer 1 -> JoinGroupRequest with
> > > GroupProtocols
> > > > =
> > > > > [
> > > > > > > >> > > "consumer"
> > > > > > > >> > > > >> > > > <Consumer1 opaque byte[]>]
> > > > > > > >> > > > >> > > > Consumer 2 -> JoinGroupRequest with
> > > GroupProtocols
> > > > =
> > > > > [
> > > > > > > >> > > "consumer"
> > > > > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > > > > >> > > > >> > > >
> > > > > > > >> > > > >> > > > Then, in the responses would look like:
> > > > > > > >> > > > >> > > >
> > > > > > > >> > > > >> > > > Consumer 1 <- JoinGroupResponse with
> > > GroupProtocol
> > > > =
> > > > > > > >> > "consumer"
> > > > > > > >> > > > and
> > > > > > > >> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque
> > > > > byte[]>,
> > > > > > > >> > Consumer
> > > > > > > >> > > 2
> > > > > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > > > > >> > > > >> > > > Consumer 2 <- JoinGroupResponse with
> > > GroupProtocol
> > > > =
> > > > > > > >> > "consumer"
> > > > > > > >> > > > and
> > > > > > > >> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque
> > > > > byte[]>,
> > > > > > > >> > Consumer
> > > > > > > >> > > 2
> > > > > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > > > > >> > > > >> > > >
> > > > > > > >> > > > >> > > > So all the responses include all the metadata
> > for
> > > > > every
> > > > > > > >> member
> > > > > > > >> > > in
> > > > > > > >> > > > >> the
> > > > > > > >> > > > >> > > > group, and everyone can use that to
> > consistently
> > > > > decide
> > > > > > > on
> > > > > > > >> > > > >> assignment.
> > > > > > > >> > > > >> > > The
> > > > > > > >> > > > >> > > > broker doesn't care and cannot even
> understand
> > > the
> > > > > > > metadata
> > > > > > > >> > > since
> > > > > > > >> > > > >> the
> > > > > > > >> > > > >> > > data
> > > > > > > >> > > > >> > > > format for it is dependent on the assignment
> > > > strategy
> > > > > > > being
> > > > > > > >> > > used.
> > > > > > > >> > > > >> > > >
> > > > > > > >> > > > >> > > > As another example that is *not* a consumer,
> > > let's
> > > > > say
> > > > > > > you
> > > > > > > >> > just
> > > > > > > >> > > > >> want to
> > > > > > > >> > > > >> > > > have a single writer in the group which
> > everyone
> > > > will
> > > > > > > >> forward
> > > > > > > >> > > > >> requests
> > > > > > > >> > > > >> > > to.
> > > > > > > >> > > > >> > > > To accomplish this, you could use a very dumb
> > > > > > assignment
> > > > > > > >> > > strategy:
> > > > > > > >> > > > >> > there
> > > > > > > >> > > > >> > > is
> > > > > > > >> > > > >> > > > no metadata (empty byte[]) and all we care
> > about
> > > is
> > > > > who
> > > > > > > is
> > > > > > > >> the
> > > > > > > >> > > > first
> > > > > > > >> > > > >> > > member
> > > > > > > >> > > > >> > > > in the group (e.g. when IDs are sorted
> > > > > > > lexicographically).
> > > > > > > >> > That
> > > > > > > >> > > > >> member
> > > > > > > >> > > > >> > is
> > > > > > > >> > > > >> > > > selected as the writer. In that case, we
> > actually
> > > > > just
> > > > > > > care
> > > > > > > >> > > about
> > > > > > > >> > > > >> the
> > > > > > > >> > > > >> > > > membership list, there's no additional info
> > about
> > > > > each
> > > > > > > >> member
> > > > > > > >> > > that
> > > > > > > >> > > > >> is
> > > > > > > >> > > > >> > > > required to determine who is the writer.
> > > > > > > >> > > > >> > > >
> > > > > > > >> > > > >> > > >
> > > > > > > >> > > > >> > > > > 3. Do you mean that the number of
> partitions
> > in
> > > > > > > >> > > > JoinGroupResponse
> > > > > > > >> > > > >> > will
> > > > > > > >> > > > >> > > be
> > > > > > > >> > > > >> > > > > the max partition number of a topic among
> all
> > > the
> > > > > > > >> reported
> > > > > > > >> > > > >> partition
> > > > > > > >> > > > >> > > > number
> > > > > > > >> > > > >> > > > > by consumers? Is there any reason not just
> > let
> > > > > > > >> Coordinator
> > > > > > > >> > to
> > > > > > > >> > > > >> return
> > > > > > > >> > > > >> > > the
> > > > > > > >> > > > >> > > > > number of partitions of a topic in its
> > metadata
> > > > > > cache?
> > > > > > > >> > > > >> > > > >
> > > > > > > >> > > > >> > > >
> > > > > > > >> > > > >> > > > Nothing from the embedded protocol is touched
> > by
> > > > the
> > > > > > > >> broker.
> > > > > > > >> > The
> > > > > > > >> > > > >> broker
> > > > > > > >> > > > >> > > > just collects opaque bytes of metadata, does
> > the
> > > > > > > selection
> > > > > > > >> of
> > > > > > > >> > > the
> > > > > > > >> > > > >> > > strategy
> > > > > > > >> > > > >> > > > if multiple are supported by some consumers,
> > and
> > > > then
> > > > > > > >> returns
> > > > > > > >> > > that
> > > > > > > >> > > > >> > opaque
> > > > > > > >> > > > >> > > > metadata for all the members back to every
> > > member.
> > > > In
> > > > > > > that
> > > > > > > >> way
> > > > > > > >> > > > they
> > > > > > > >> > > > >> all
> > > > > > > >> > > > >> > > > have a consistent view of the group. For
> > regular
> > > > > > > consumers,
> > > > > > > >> > that
> > > > > > > >> > > > >> view
> > > > > > > >> > > > >> > of
> > > > > > > >> > > > >> > > > the group includes information about how many
> > > > > > partitions
> > > > > > > >> each
> > > > > > > >> > > > >> consumer
> > > > > > > >> > > > >> > > > currently thinks the topics it is subscribed
> to
> > > > has.
> > > > > > > These
> > > > > > > >> > could
> > > > > > > >> > > > be
> > > > > > > >> > > > >> > > > inconsistent due to out of date metadata and
> it
> > > > would
> > > > > > be
> > > > > > > >> up to
> > > > > > > >> > > the
> > > > > > > >> > > > >> > > > assignment strategy on the *client* to
> resolve
> > > > that.
> > > > > As
> > > > > > > you
> > > > > > > >> > > point
> > > > > > > >> > > > >> out,
> > > > > > > >> > > > >> > in
> > > > > > > >> > > > >> > > > that case they could just take the max value
> > that
> > > > any
> > > > > > > >> consumer
> > > > > > > >> > > > >> reported
> > > > > > > >> > > > >> > > > seeing and use that. The consumers that
> notice
> > > that
> > > > > > their
> > > > > > > >> > > metadata
> > > > > > > >> > > > >> had
> > > > > > > >> > > > >> > a
> > > > > > > >> > > > >> > > > smaller # of partitions should also trigger a
> > > > > metadata
> > > > > > > >> update
> > > > > > > >> > > when
> > > > > > > >> > > > >> they
> > > > > > > >> > > > >> > > see
> > > > > > > >> > > > >> > > > someone else observing a larger # of
> > partitions.
> > > > > > > >> > > > >> > > >
> > > > > > > >> > > > >> > > >
> > > > > > > >> > > > >> > > > >
> > > > > > > >> > > > >> > > > > Thanks,
> > > > > > > >> > > > >> > > > >
> > > > > > > >> > > > >> > > > > Jiangjie (Becket) Qin
> > > > > > > >> > > > >> > > > >
> > > > > > > >> > > > >> > > > >
> > > > > > > >> > > > >> > > > >
> > > > > > > >> > > > >> > > > >
> > > > > > > >> > > > >> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason
> > > Gustafson
> > > > <
> > > > > > > >> > > > >> jason@confluent.io
> > > > > > > >> > > > >> > >
> > > > > > > >> > > > >> > > > > wrote:
> > > > > > > >> > > > >> > > > >
> > > > > > > >> > > > >> > > > > > Hi Kafka Devs,
> > > > > > > >> > > > >> > > > > >
> > > > > > > >> > > > >> > > > > > One of the nagging issues in the current
> > > design
> > > > > of
> > > > > > > the
> > > > > > > >> new
> > > > > > > >> > > > >> consumer
> > > > > > > >> > > > >> > > has
> > > > > > > >> > > > >> > > > > > been the need to support a variety of
> > > > assignment
> > > > > > > >> > strategies.
> > > > > > > >> > > > >> We've
> > > > > > > >> > > > >> > > > > > encountered this in particular in the
> > design
> > > of
> > > > > > > copycat
> > > > > > > >> > and
> > > > > > > >> > > > the
> > > > > > > >> > > > >> > > > > processing
> > > > > > > >> > > > >> > > > > > framework (KIP-28). From what I
> understand,
> > > > Samza
> > > > > > > also
> > > > > > > >> > has a
> > > > > > > >> > > > >> number
> > > > > > > >> > > > >> > > of
> > > > > > > >> > > > >> > > > > use
> > > > > > > >> > > > >> > > > > > cases with custom assignment needs. The
> new
> > > > > > consumer
> > > > > > > >> > > protocol
> > > > > > > >> > > > >> > > supports
> > > > > > > >> > > > >> > > > > new
> > > > > > > >> > > > >> > > > > > assignment strategies by hooking them
> into
> > > the
> > > > > > > broker.
> > > > > > > >> For
> > > > > > > >> > > > many
> > > > > > > >> > > > >> > > > > > environments, this is a major pain and in
> > > some
> > > > > > > cases, a
> > > > > > > >> > > > >> > non-starter.
> > > > > > > >> > > > >> > > It
> > > > > > > >> > > > >> > > > > > also challenges the validation that the
> > > > > coordinator
> > > > > > > can
> > > > > > > >> > > > provide.
> > > > > > > >> > > > >> > For
> > > > > > > >> > > > >> > > > > > example, some assignment strategies call
> > for
> > > > > > > >> partitions to
> > > > > > > >> > > be
> > > > > > > >> > > > >> > > assigned
> > > > > > > >> > > > >> > > > > > multiple times, which means that the
> > > > coordinator
> > > > > > can
> > > > > > > >> only
> > > > > > > >> > > > check
> > > > > > > >> > > > >> > that
> > > > > > > >> > > > >> > > > > > partitions have been assigned at least
> > once.
> > > > > > > >> > > > >> > > > > >
> > > > > > > >> > > > >> > > > > > To solve these issues, we'd like to
> propose
> > > > > moving
> > > > > > > >> > > assignment
> > > > > > > >> > > > to
> > > > > > > >> > > > >> > the
> > > > > > > >> > > > >> > > > > > client. I've written a wiki which
> outlines
> > > some
> > > > > > > >> protocol
> > > > > > > >> > > > >> changes to
> > > > > > > >> > > > >> > > > > achieve
> > > > > > > >> > > > >> > > > > > this:
> > > > > > > >> > > > >> > > > > >
> > > > > > > >> > > > >> > > > > >
> > > > > > > >> > > > >> > > > >
> > > > > > > >> > > > >> > > >
> > > > > > > >> > > > >> > >
> > > > > > > >> > > > >> >
> > > > > > > >> > > > >>
> > > > > > > >> > > >
> > > > > > > >> > >
> > > > > > > >> >
> > > > > > > >>
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> > > > > > > >> > > > >> > > > > > .
> > > > > > > >> > > > >> > > > > > To summarize briefly, instead of the
> > > > coordinator
> > > > > > > >> assigning
> > > > > > > >> > > the
> > > > > > > >> > > > >> > > > partitions
> > > > > > > >> > > > >> > > > > > itself, all subscriptions are forwarded
> to
> > > each
> > > > > > > member
> > > > > > > >> of
> > > > > > > >> > > the
> > > > > > > >> > > > >> group
> > > > > > > >> > > > >> > > > which
> > > > > > > >> > > > >> > > > > > then decides independently which
> partitions
> > > it
> > > > > > should
> > > > > > > >> > > consume.
> > > > > > > >> > > > >> The
> > > > > > > >> > > > >> > > > > protocol
> > > > > > > >> > > > >> > > > > > provides a mechanism for the coordinator
> to
> > > > > > validate
> > > > > > > >> that
> > > > > > > >> > > all
> > > > > > > >> > > > >> > > consumers
> > > > > > > >> > > > >> > > > > use
> > > > > > > >> > > > >> > > > > > the same assignment strategy, but it does
> > not
> > > > > > ensure
> > > > > > > >> that
> > > > > > > >> > > the
> > > > > > > >> > > > >> > > resulting
> > > > > > > >> > > > >> > > > > > assignment is "correct." This provides a
> > > > powerful
> > > > > > > >> > capability
> > > > > > > >> > > > for
> > > > > > > >> > > > >> > > users
> > > > > > > >> > > > >> > > > to
> > > > > > > >> > > > >> > > > > > control the full data flow on the client
> > > side.
> > > > > They
> > > > > > > >> > control
> > > > > > > >> > > > how
> > > > > > > >> > > > >> > data
> > > > > > > >> > > > >> > > is
> > > > > > > >> > > > >> > > > > > written to partitions through the
> > Partitioner
> > > > > > > interface
> > > > > > > >> > and
> > > > > > > >> > > > they
> > > > > > > >> > > > >> > > > control
> > > > > > > >> > > > >> > > > > > how data is consumed through the
> assignment
> > > > > > strategy,
> > > > > > > >> all
> > > > > > > >> > > > >> without
> > > > > > > >> > > > >> > > > > touching
> > > > > > > >> > > > >> > > > > > the server.
> > > > > > > >> > > > >> > > > > >
> > > > > > > >> > > > >> > > > > > Of course nothing comes for free. In
> > > > particular,
> > > > > > this
> > > > > > > >> > change
> > > > > > > >> > > > >> > removes
> > > > > > > >> > > > >> > > > the
> > > > > > > >> > > > >> > > > > > ability of the coordinator to validate
> that
> > > > > commits
> > > > > > > are
> > > > > > > >> > made
> > > > > > > >> > > > by
> > > > > > > >> > > > >> > > > consumers
> > > > > > > >> > > > >> > > > > > who were assigned the respective
> partition.
> > > > This
> > > > > > > might
> > > > > > > >> not
> > > > > > > >> > > be
> > > > > > > >> > > > >> too
> > > > > > > >> > > > >> > bad
> > > > > > > >> > > > >> > > > > since
> > > > > > > >> > > > >> > > > > > we retain the ability to validate the
> > > > generation
> > > > > > id,
> > > > > > > >> but
> > > > > > > >> > it
> > > > > > > >> > > > is a
> > > > > > > >> > > > >> > > > > potential
> > > > > > > >> > > > >> > > > > > concern. We have considered alternative
> > > > protocols
> > > > > > > which
> > > > > > > >> > add
> > > > > > > >> > > a
> > > > > > > >> > > > >> > second
> > > > > > > >> > > > >> > > > > > round-trip to the protocol in order to
> give
> > > the
> > > > > > > >> > coordinator
> > > > > > > >> > > > the
> > > > > > > >> > > > >> > > ability
> > > > > > > >> > > > >> > > > > to
> > > > > > > >> > > > >> > > > > > confirm the assignment. As mentioned
> above,
> > > the
> > > > > > > >> > coordinator
> > > > > > > >> > > is
> > > > > > > >> > > > >> > > somewhat
> > > > > > > >> > > > >> > > > > > limited in what it can actually validate,
> > but
> > > > > this
> > > > > > > >> would
> > > > > > > >> > > > return
> > > > > > > >> > > > >> its
> > > > > > > >> > > > >> > > > > ability
> > > > > > > >> > > > >> > > > > > to validate commits. The tradeoff is that
> > it
> > > > > > > increases
> > > > > > > >> the
> > > > > > > >> > > > >> > protocol's
> > > > > > > >> > > > >> > > > > > complexity which means more ways for the
> > > > protocol
> > > > > > to
> > > > > > > >> fail
> > > > > > > >> > > and
> > > > > > > >> > > > >> > > > > consequently
> > > > > > > >> > > > >> > > > > > more edge cases in the code.
> > > > > > > >> > > > >> > > > > >
> > > > > > > >> > > > >> > > > > > It also misses an opportunity to
> generalize
> > > the
> > > > > > group
> > > > > > > >> > > > membership
> > > > > > > >> > > > >> > > > protocol
> > > > > > > >> > > > >> > > > > > for additional use cases. In fact, after
> > > you've
> > > > > > gone
> > > > > > > to
> > > > > > > >> > the
> > > > > > > >> > > > >> trouble
> > > > > > > >> > > > >> > > of
> > > > > > > >> > > > >> > > > > > moving assignment to the client, the main
> > > thing
> > > > > > that
> > > > > > > is
> > > > > > > >> > left
> > > > > > > >> > > > in
> > > > > > > >> > > > >> > this
> > > > > > > >> > > > >> > > > > > protocol is basically a general group
> > > > management
> > > > > > > >> > capability.
> > > > > > > >> > > > >> This
> > > > > > > >> > > > >> > is
> > > > > > > >> > > > >> > > > > > exactly what is needed for a few cases
> that
> > > are
> > > > > > > >> currently
> > > > > > > >> > > > under
> > > > > > > >> > > > >> > > > > discussion
> > > > > > > >> > > > >> > > > > > (e.g. copycat or single-writer producer).
> > > We've
> > > > > > taken
> > > > > > > >> this
> > > > > > > >> > > > >> further
> > > > > > > >> > > > >> > > step
> > > > > > > >> > > > >> > > > > in
> > > > > > > >> > > > >> > > > > > the proposal and attempted to envision
> what
> > > > that
> > > > > > > >> general
> > > > > > > >> > > > >> protocol
> > > > > > > >> > > > >> > > might
> > > > > > > >> > > > >> > > > > > look like and how it could be used both
> by
> > > the
> > > > > > > consumer
> > > > > > > >> > and
> > > > > > > >> > > > for
> > > > > > > >> > > > >> > some
> > > > > > > >> > > > >> > > of
> > > > > > > >> > > > >> > > > > > these other cases.
> > > > > > > >> > > > >> > > > > >
> > > > > > > >> > > > >> > > > > > Anyway, since time is running out on the
> > new
> > > > > > > consumer,
> > > > > > > >> we
> > > > > > > >> > > have
> > > > > > > >> > > > >> > > perhaps
> > > > > > > >> > > > >> > > > > one
> > > > > > > >> > > > >> > > > > > last chance to consider a significant
> > change
> > > in
> > > > > the
> > > > > > > >> > protocol
> > > > > > > >> > > > >> like
> > > > > > > >> > > > >> > > this,
> > > > > > > >> > > > >> > > > > so
> > > > > > > >> > > > >> > > > > > have a look at the wiki and share your
> > > > thoughts.
> > > > > > I've
> > > > > > > >> no
> > > > > > > >> > > doubt
> > > > > > > >> > > > >> that
> > > > > > > >> > > > >> > > > some
> > > > > > > >> > > > >> > > > > > ideas seem clearer in my mind than they
> do
> > on
> > > > > > paper,
> > > > > > > so
> > > > > > > >> > ask
> > > > > > > >> > > > >> > questions
> > > > > > > >> > > > >> > > > if
> > > > > > > >> > > > >> > > > > > there is any confusion.
> > > > > > > >> > > > >> > > > > >
> > > > > > > >> > > > >> > > > > > Thanks!
> > > > > > > >> > > > >> > > > > > Jason
> > > > > > > >> > > > >> > > > > >
> > > > > > > >> > > > >> > > > >
> > > > > > > >> > > > >> > > >
> > > > > > > >> > > > >> > > >
> > > > > > > >> > > > >> > > >
> > > > > > > >> > > > >> > > > --
> > > > > > > >> > > > >> > > > Thanks,
> > > > > > > >> > > > >> > > > Ewen
> > > > > > > >> > > > >> > > >
> > > > > > > >> > > > >> > >
> > > > > > > >> > > > >> >
> > > > > > > >> > > > >> >
> > > > > > > >> > > > >> >
> > > > > > > >> > > > >> > --
> > > > > > > >> > > > >> > Thanks,
> > > > > > > >> > > > >> > Ewen
> > > > > > > >> > > > >> >
> > > > > > > >> > > > >>
> > > > > > > >> > > > >
> > > > > > > >> > > > >
> > > > > > > >> > > >
> > > > > > > >> > >
> > > > > > > >> >
> > > > > > > >>
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > Thanks,
> > > > > > > > Neha
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Thanks,
> > > > > > > Neha
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Thanks,
> > > > > > Ewen
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Thanks,
> > > > Ewen
> > > >
> > >
> >
>
>
>
> --
> Thanks,
> Neha
>

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Neha Narkhede <ne...@confluent.io>.
Becket,

This is a clever approach for to ensure that only one thing communicates
the metadata so even if it is stale, the entire group has the same view.
However, the big assumption this makes is that the coordinator is that one
process that has the ability to know the metadata for group members, which
does not work for any non-consumer use case.

I wonder if we may be complicating the design of 95% use cases for the
remaining 5%. For instance, how many times do people create and remove
topics or even add partitions? We operated LI clusters for a long time and
this wasn't a frequent event that would need us to optimize this design for.

Also, this is something we can easily validate by running a few tests on
the patch and I suggest we wait for that.

Thanks,
Neha

On Sat, Aug 15, 2015 at 9:14 AM, Jason Gustafson <ja...@confluent.io> wrote:

> Hey Jiangjie,
>
> I was thinking about the same problem. When metadata is changing
> frequently, the clients may not be able to ever find agreement on the
> current state. The server doesn't have this problem, as you say, because it
> can just take a snapshot and send that to the clients. Adding a dampening
> setting to the client would help if churn is sporadic, but not if it is
> steady. I think the metadata would have to be changing really frequently
> for this to be a problem practically, but this is a case where the
> server-side approach has an advantage.
>
> Including the metadata in the join group response would require making the
> subscription available to the coordinator, right? We lose a little bit of
> the generality of the protocol, but it might not be too bad since most use
> cases for reusing this protocol have a similar need for metadata (and they
> can always pass an empty subscription if they don't). We've gone back and
> forth a few times on this, and I'm generally not opposed. It might help if
> we try to quantify the impact of the metadata churn in practice. I think
> the rate of change would have to be in the low seconds for this to be a
> real problem. It does seem nice though that we have a way to manage even
> this much churn when we do this.
>
> -Jason
>
>
>
> On Fri, Aug 14, 2015 at 9:03 PM, Jiangjie Qin <jq...@linkedin.com.invalid>
> wrote:
>
> > Ewen,
> >
> > I agree that if there is a churn in metadata, the consumers need several
> > rounds of rebalances to succeed. The difference I am thinking is that
> with
> > coordinator as single source of truth, we can let the consumer finish one
> > round of rebalance, work for a while and start the next round of
> rebalance.
> > If we purely depend on the consumers to synchronize by themselves based
> on
> > different metadata sources, is it possible we have some groups spending a
> > lot of time on rebalancing but not able to make too much progress in
> > consuming?
> >
> > I'm thinking can we let consumers to fetch metadata only from their
> > coordinator? So the rebalance can be done in the following way:
> >
> > 1. Consumers refresh their metadata periodically
> > 2. If one of the consumer sees a change in metadata that triggers a
> > rebalance, it sends JoinGroupRequest to coordinator.
> > 3. Once the coordinator receives the first JoinGroupRequest of a group,
> it
> > takes a snapshot of current metadata and the group enters
> prepare-rebalance
> > state.
> > 4. The metadata snapshot will be used for this round of rebalance. i.e.
> the
> > metadata snapshot will be sent to consumers in JoinGroupResponse.
> > 4.1 If the consumers are subscribing to explicit topic lists (not regex),
> > the JoinGroupResponse needs only contain the metadata of all topics the
> > group is interested.
> > 4.2 If the consumers are subscribing using regex, all the topic metadata
> > will be returned to the consumer.
> > 5. Consumers get JoinGroupResponse, refresh metadata using the metadata
> in
> > JoinGroupResponse, run algorithm to assign partitions and start consume.
> > 6. Go back to 1.
> >
> > The benefit here is that we can let rebalance finish in one round, and
> all
> > the rest of changes will be captured in next consumer metadata refresh -
> so
> > we get group commit. One concern might be letting consumer refresh
> metadata
> > from coordinator might cause issue for big consumer groups. Maybe that is
> > OK because metadata refresh is infrequent.
> >
> > This approach actually is very similar to what is proposed now: rebalance
> > is triggered by metadata refresh, consumer provides subscription list to
> > pass around. The only difference is that we don't need metadata hash
> > anymore because the metadata is guaranteed to be the same. Replacing
> > metadata hash with actual metadata will not have too much overhead for
> > small subscription groups. There will be some overhead for regex
> > subscriptions, but this can save the potential extra round of metadata
> > fetch and will only occur when consumer see metadata change, which is
> > infrequent.
> >
> > Any thoughts?
> >
> > Thanks,
> >
> > Jiangjie (Becket) Qin
> >
> >
> > On Fri, Aug 14, 2015 at 12:57 PM, Ewen Cheslack-Postava <
> ewen@confluent.io
> > >
> > wrote:
> >
> > > On Fri, Aug 14, 2015 at 10:59 AM, Jiangjie Qin
> <jqin@linkedin.com.invalid
> > >
> > > wrote:
> > >
> > > > Neha and Ewen,
> > > >
> > > > About the metadata change frequency. I guess it really depends on how
> > > > frequent the metadata change might occur. If we run Kafka as a
> > service, I
> > > > can see that happens from time to time. As I can imagine people will
> > > create
> > > > some topic, test and maybe delete the topic in some automated test.
> If
> > > so,
> > > > the proposed protocol might be a little bit vulnerable.
> > > >
> > > > More specifically the scenario I am thinking is:
> > > > 1. Consumer 0 periodically refresh metadata and detected a metadata
> > > change.
> > > > So it sends a JoinGroupRequest with metadata_hash_0.
> > > > 2. Consumer 1 was notified by controller to start a rebalance, so it
> > > > refreshes its metadata and send a JoingGroupRequest with
> > metadata_hash_1,
> > > > which is different from metadata hash 0.
> > > > 3. Rebalance failed and both consumer refresh there metadata again
> from
> > > > different brokers.
> > > > 4. Depending on the metadata change frequency(or some admin operation
> > > like
> > > > partition reassigment), they may or may not have the same metadata
> > > > returned, so the restart from 3 again.
> > > >
> > > > I agree that step 4 might not be a big concern if consumers updates
> > > > metadata at almost the same time, but I'm a little bit worried
> whether
> > > that
> > > > assumption really stands because we do not have control over how
> > frequent
> > > > the metadata can change.
> > > >
> > > >
> > > Is this really that different from what would happen if the coordinator
> > > distributed the metadata to consumers? In that case you would trivially
> > > have everyone in a consistent state, but those metadata changes would
> > still
> > > cause churn and require JoinGroup rounds, during which processing is
> > > stalled for the nodes that are waiting on other members to re-join the
> > > group.
> > >
> > > -Ewen
> > >
> > >
> > > > Thanks,
> > > >
> > > > Jiangjie (Becket) Qin
> > > >
> > > > On Fri, Aug 14, 2015 at 2:03 AM, Ewen Cheslack-Postava <
> > > ewen@confluent.io>
> > > > wrote:
> > > >
> > > > > On Thu, Aug 13, 2015 at 11:07 PM, Neha Narkhede <neha@confluent.io
> >
> > > > wrote:
> > > > >
> > > > > > Becket,
> > > > > >
> > > > > > As you say, the metadata hash addresses the concern you
> originally
> > > > raised
> > > > > > about large topic subscriptions. Can you please list other
> problems
> > > you
> > > > > are
> > > > > > raising more clearly? It is more helpful to know problems that
> the
> > > > > proposal
> > > > > > does not address or addresses poorly.
> > > > > >
> > > > > > Regarding other things you said -
> > > > > >
> > > > > > it is required that each
> > > > > > > consumer refresh their metadata before sending a
> JoinGroupRequest
> > > > > > >
> > > > > >
> > > > > > This is required for wildcard topic subscriptions anyway. So this
> > > > > proposal
> > > > > > does not introduce a regression. We had agreed earlier that it
> does
> > > not
> > > > > > make sense for the server to deserialize regular expressions sent
> > by
> > > > the
> > > > > > consumer.
> > > > > >
> > > > >
> > > > > I don't think consumers need to do a metadata refresh before
> sending
> > a
> > > > > JoinGroupRequest. Metadata changes that affect assignment are rare
> --
> > > it
> > > > > requires changing the number of partitions in a topic. But you
> might
> > > > send a
> > > > > JoinGroupRequest simply because a new member is trying to join the
> > > group.
> > > > > That case is presumably much more common.
> > > > >
> > > > > I think it's actually a good idea to have the first JoinGroup cycle
> > > fail
> > > > in
> > > > > some cases, and has little impact. Lets say the metadata does
> change
> > > > > because partitions are added. Then we might fail in the first
> round,
> > > but
> > > > > then all members detect that issue *immediately*, refresh their
> > > metadata,
> > > > > and submit a new join group request. This second cycle does not
> > > require a
> > > > > full heartbeat cycle. It happens much more quickly because everyone
> > > > > detected the inconsistency based on the first JoinGroupResponse.
> The
> > > > > inconsistency should be resolved very quickly (barring other
> failures
> > > > like
> > > > > a member leaving mid-rebalance)
> > > >
> > > >
> > > >
> > > >
> > > > > >
> > > > > >
> > > > > > > the metadata might still be inconsistent if there is a topic or
> > > > > partition
> > > > > > > change because the
> > > > > > > UpdateMetadataRequest from controller might be handled at
> > different
> > > > > time.
> > > > > > >
> > > > > >
> > > > > > Topic metadata does not change frequently and even if it did, a
> > > couple
> > > > > > rebalance attempts will be needed whether the coordinator drives
> > the
> > > > > > assignments or the consumer. Because guess how the coordinator
> > knows
> > > > > about
> > > > > > the topic metadata changes -- indirectly through either a zk
> > callback
> > > > or
> > > > > > UpdateMetadataRequest, so it is completely possible the
> coordinator
> > > > sees
> > > > > > the topic metadata changes in batches, not all at once.
> > > > > >
> > > > >
> > > > > > On Thu, Aug 13, 2015 at 10:50 PM, Neha Narkhede <
> neha@confluent.io
> > >
> > > > > wrote:
> > > > > >
> > > > > > > Ewen/Jason,
> > > > > > >
> > > > > > > The metadata hash is a clever approach and certainly addresses
> > the
> > > > > > problem
> > > > > > > of large metadata for consumers like mirror maker. Few
> comments -
> > > > > > >
> > > > > > >
> > > > > > >    1. In the interest of simplifying the format of the
> consumer's
> > > > > > >    metadata - Why not just always include only the topic names
> in
> > > the
> > > > > > metadata
> > > > > > >    followed by the metadata hash? If the metadata hash check
> > > > succeeds,
> > > > > > each
> > > > > > >    consumer uses the # of partitions it had fetched. If it
> > fails, a
> > > > > > rebalance
> > > > > > >    happens and the metadata is not used anyway.
> > > > > >
> > > > >
> > > > > Doing this requires that every consumer always fetch the full
> > metadata.
> > > > The
> > > > > most common use case is consumers that just want to consume one or
> a
> > > > couple
> > > > > of topics, in which case grabbing all metadata for the entire
> cluster
> > > is
> > > > > wasteful. If I subscribe only to topic A, why make all consumers
> grab
> > > > > metadata for the entire topic (and need to rebalance every time it
> > > > > changes!). Including the # of partitions for each topic lets you
> > avoid
> > > > > having to grab the global set of metadata.
> > > > >
> > > > > So if you're just subscribing to one or a couple of topics, why not
> > > just
> > > > > compute the hash by filtering out everything but the topics you are
> > > > > subscribed to? The problem there is if you ever add/remove
> > > subscriptions
> > > > > and want to support rolling upgrades. If the group was subscribed
> to
> > > > topic
> > > > > A, but later changes require subscribing to A + B, then to achieve
> a
> > > > > seamless rolling upgrade would require one (old) consumer to be
> > > > subscribing
> > > > > to A and one (new) consumer to be subscribing to A+B. If we
> computed
> > > > > metadata hashes based on filtered metadata, those two would
> disagree
> > > and
> > > > we
> > > > > could not perform assignment while the upgrade was in progress.
> > > > >
> > > > > The solution is to differentiate between the cases when a very
> small
> > > > amount
> > > > > of the metadata is needed (one or a couple of topic subscriptions;
> > > > > communicate and share this via metadata in the JoinGroup protocol)
> vs
> > > > when
> > > > > *all* the metadata is needed (regex subscription; verify agreement
> > via
> > > > > hash).
> > > > >
> > > >
> > > > >
> > > > >
> > > > > > >    2. Do you need a topic list and topic regex to be separate?
> A
> > > > single
> > > > > > >    topic or list of topics can be expressed as a regex.
> > > > > >
> > > > >
> > > > > See above note about collecting all metadata when you really only
> > need
> > > it
> > > > > for 1 or 2 topics. There's probably some debate to be had about
> > whether
> > > > > this cost would be too high -- every consumer would need to request
> > the
> > > > > metadata for all topics, and they'd need to request that all every
> > time
> > > > > they might be out of date.
> > > > >
> > > > Are we going to allow consumers in the same group to subscribe to
> > > different
> > > > topic set? If we do, we need to let them refresh metadata for all the
> > > > topics a group is consuming from. If we don't then in the protocol we
> > > only
> > > > need a subscription set hash.
> > > >
> > > > >
> > > > >
> > > > > > >    3. Let's include a version explicitly at the beginning of
> the
> > > > > > >    ProtocolMetadata. The version dictates how to deserialize
> the
> > > > > > >    ProtocolMetadata blob and is consistent with the rest of
> > Kafka.
> > > > > >
> > > > >
> > > > > If I'm understanding correctly, in JoinGroupRequest I would change
> > > > >
> > > > > GroupProtocols          => [Protocol ProtocolMetadata]
> > > > >
> > > > > to
> > > > >
> > > > > GroupProtocols          => [Protocol ProtocolVersion
> > ProtocolMetadata]
> > > > >
> > > > > We had been talking about just baking the version into the Protocol
> > > > field,
> > > > > but making it separate seems perfectly reasonable to me. Jason, any
> > > issue
> > > > > with splitting the version out into a separate field like this?
> > > > >
> > > > > >
> > > > > > > That can simplify the metadata format to the following:
> > > > > > >
> > > > > > > GroupType => "consumer"
> > > > > > >>
> > > > > > >> Protocol => AssignmentStrategy
> > > > > > >>   AssignmentStrategy   => String
> > > > > > >>
> > > > > > >> ProtocolMetadata => Version Subscription
> > > AssignmentStrategyMetadata
> > > > > > >
> > > > > > >     Version                    => String
> > > > > > >
> > > > > > >   Subscription                 => TopicRegex MetadataHash
> > > > > > >>     TopicRegex                 => String
> > > > > > >>     MetadataHash               => String
> > > > > > >>   AssignmentStrategyMetadata   => bytes
> > > > > >
> > > > > >
> > > > > > >
> > > > > > > On Thu, Aug 13, 2015 at 6:28 PM, Jiangjie Qin
> > > > > <jqin@linkedin.com.invalid
> > > > > > >
> > > > > > > wrote:
> > > > > > >
> > > > > > >> Ewen and Jason,
> > > > > > >>
> > > > > > >> Thanks for the reply. Sorry I missed the metadata hash. Yes,
> > that
> > > > is a
> > > > > > >> clever approach and would solve my concern about the data
> > passing
> > > > > > around.
> > > > > > >> I
> > > > > > >> can see both pros and cons from doing this, though. The
> > advantage
> > > is
> > > > > we
> > > > > > >> don't need the topic metadata in JoinGroupResponse anymore.
> The
> > > > > downside
> > > > > > >> is
> > > > > > >> that now rebalance have extra dependency on the consensus of
> > > > metadata
> > > > > of
> > > > > > >> all consumers, which is obtained separately. So it is required
> > > that
> > > > > each
> > > > > > >> consumer refresh their metadata before sending a
> > JoinGroupRequest,
> > > > > > >> otherwise in some cases (e.g. wildcard consumers) will almost
> > > > > certainly
> > > > > > >> fail for the first rebalance attempt. Even if we do that,
> since
> > > the
> > > > > > >> consumers are getting metadata from different brokers, the
> > > metadata
> > > > > > might
> > > > > > >> still be inconsistent if there is a topic or partition change
> > > > because
> > > > > > the
> > > > > > >> UpdateMetadataRequest from controller might be handled at
> > > different
> > > > > > time.
> > > > > > >> Just want to make sure we think through the cases so the
> > protocol
> > > > does
> > > > > > not
> > > > > > >> cause us unexpected issues.
> > > > > > >>
> > > > > > >> About the number of consumers, I think with the current
> > liveliness
> > > > > > >> definition, we can tolerate churns by bumping up the session
> > > > timeout.
> > > > > > Also
> > > > > > >> I guess we will see an increasing number of consumers for new
> > > > > consumer,
> > > > > > >> because every the old consumer thread will probably become a
> > > > consumer.
> > > > > > >>
> > > > > > >> It is a valid concern for consumers that have large
> subscription
> > > > set.
> > > > > > This
> > > > > > >> might not be avoided though for client side assignment
> approach.
> > > One
> > > > > > >> solution is having topic names associate with a topic ID. And
> > only
> > > > use
> > > > > > >> topic ID in JoinGroupRequest and JoinGroupResponse, There is a
> > > > > > discussion
> > > > > > >> thread about this to solve the topic renaming case but this
> is a
> > > > > > >> completely
> > > > > > >> different discussion.
> > > > > > >>
> > > > > > >> Thanks,
> > > > > > >>
> > > > > > >> Jiangjie (Becket) Qin
> > > > > > >>
> > > > > > >>
> > > > > > >>
> > > > > > >> On Thu, Aug 13, 2015 at 2:14 PM, Jason Gustafson <
> > > > jason@confluent.io>
> > > > > > >> wrote:
> > > > > > >>
> > > > > > >> > Thanks Jiangjie, that information helps. I agree the
> protocol
> > > must
> > > > > > >> consider
> > > > > > >> > scalability. My point was that the synchronization barrier
> in
> > > the
> > > > > > >> current
> > > > > > >> > protocol already effectively limits the number of consumers
> > > since
> > > > it
> > > > > > >> > provides no way to gracefully handle churn. It wouldn't be
> > worth
> > > > > > >> worrying
> > > > > > >> > about scaling up to 100,000 members, for example, because
> > > there's
> > > > no
> > > > > > way
> > > > > > >> > the group would be stable. So we just need to set some clear
> > > > > > >> expectations
> > > > > > >> > on the size we can scale to, and that can help inform the
> > > > discussion
> > > > > > on
> > > > > > >> the
> > > > > > >> > size of messages in this protocol.
> > > > > > >> >
> > > > > > >> > Ewen and I were discussing this morning along similar lines
> to
> > > > what
> > > > > > >> you're
> > > > > > >> > suggesting. However, even if the coordinator decides on the
> > > > metadata
> > > > > > for
> > > > > > >> > the group, each member still needs to communicate its
> > > > subscriptions
> > > > > to
> > > > > > >> the
> > > > > > >> > rest of the group. This is nice for the regex case since the
> > > regex
> > > > > is
> > > > > > >> > probably small, but if the members have a large topic list,
> > then
> > > > we
> > > > > > have
> > > > > > >> > the same problem. One thing I was thinking about was whether
> > we
> > > > > really
> > > > > > >> need
> > > > > > >> > to handle different subscriptions for every member. If the
> > > > > coordinator
> > > > > > >> > could guarantee that all members had the same subscription,
> > then
> > > > > there
> > > > > > >> > would be no need for the coordinator to return the
> > subscriptions
> > > > for
> > > > > > >> each
> > > > > > >> > member. However, this would prevent graceful upgrades. We
> > might
> > > be
> > > > > > able
> > > > > > >> to
> > > > > > >> > fix that problem by allowing the consumer to provide two
> > > > > subscriptions
> > > > > > >> to
> > > > > > >> > allowing rolling updates, but that starts to sound pretty
> > nasty.
> > > > > > >> >
> > > > > > >> > -Jason
> > > > > > >> >
> > > > > > >> > On Thu, Aug 13, 2015 at 1:41 PM, Jiangjie Qin
> > > > > > <jqin@linkedin.com.invalid
> > > > > > >> >
> > > > > > >> > wrote:
> > > > > > >> >
> > > > > > >> > > Jason,
> > > > > > >> > >
> > > > > > >> > > The protocol has to consider the scalability. The protocol
> > in
> > > > the
> > > > > > wiki
> > > > > > >> > > means the JoinGroupResoponse size would be:
> > > > > > >> > > NumberOfTopics * (AvgTopicNameLength + 4) *
> > > > (NumberOfConsumers)^2
> > > > > > >> > >
> > > > > > >> > > To give some real number, we have 26-node Mirror Maker
> > > cluster,
> > > > > each
> > > > > > >> > with 4
> > > > > > >> > > consumers. That is 104 consumers using regex ".*". And
> most
> > of
> > > > our
> > > > > > >> > clusters
> > > > > > >> > > have around 3000 topics, whose topic name are typically
> > around
> > > > 20
> > > > > > >> > > characters.
> > > > > > >> > >
> > > > > > >> > > I think the key issue for client side partition assignment
> > > logic
> > > > > is
> > > > > > to
> > > > > > >> > make
> > > > > > >> > > sure 1) all the clients run the same algorithm. 2) all the
> > > > clients
> > > > > > >> make
> > > > > > >> > > decision on the same topic metadata. The second purpose
> can
> > be
> > > > > done
> > > > > > by
> > > > > > >> > > simply letting coordinator provide the topic metadata and
> > all
> > > > then
> > > > > > >> member
> > > > > > >> > > information as source of truth. Is it necessary to pass
> > topic
> > > > > > >> metadata of
> > > > > > >> > > each consumer around? Can we keep the protocol metadata
> > field
> > > > > > >> completely
> > > > > > >> > > independent of topic metadata? I think In the
> > > JoinGroupResponse,
> > > > > we
> > > > > > >> > should
> > > > > > >> > > have only one copy of topic metadata provided by
> coordinator
> > > and
> > > > > is
> > > > > > >> > outside
> > > > > > >> > > of protocol metadata. If user decides to put some metadata
> > in
> > > > the
> > > > > > >> > > JoinGroupRequest and let coordinator pass around, they are
> > > > > > responsible
> > > > > > >> > for
> > > > > > >> > > understanding the risk.
> > > > > > >> > >
> > > > > > >> > > Thanks,
> > > > > > >> > >
> > > > > > >> > > Jiangjie (Becket) Qin
> > > > > > >> > >
> > > > > > >> > >
> > > > > > >> > > On Thu, Aug 13, 2015 at 12:41 PM, Jason Gustafson <
> > > > > > jason@confluent.io
> > > > > > >> >
> > > > > > >> > > wrote:
> > > > > > >> > >
> > > > > > >> > > > Hey Onur and Jiangjie,
> > > > > > >> > > >
> > > > > > >> > > > I've updated that wiki with a proposal to add regex
> > > > > subscriptions
> > > > > > to
> > > > > > >> > the
> > > > > > >> > > > consumer metadata. Can you have a look to see if it
> > > addresses
> > > > > your
> > > > > > >> > > concern?
> > > > > > >> > > > In general, I think we should be a little careful when
> we
> > > are
> > > > > > >> talking
> > > > > > >> > > about
> > > > > > >> > > > the scalability of the protocol. Regardless of whether
> > > > > assignment
> > > > > > is
> > > > > > >> > done
> > > > > > >> > > > on the server or the client, the protocol assumes a
> > > relatively
> > > > > > >> stable
> > > > > > >> > > > configuration. When the number of consumers increases
> > > beyond a
> > > > > > >> certain
> > > > > > >> > > > limit, then membership churn becomes a major concern.
> > > > Similarly
> > > > > > >> there
> > > > > > >> > is
> > > > > > >> > > a
> > > > > > >> > > > notion of metadata churn when topics are added, deleted,
> > or
> > > > > > >> resized. If
> > > > > > >> > > > either membership or metadata changes, then the protocol
> > > > forces
> > > > > > all
> > > > > > >> > > > consumers to stop consumption and rejoin the group. If
> > this
> > > > > > happens
> > > > > > >> > often
> > > > > > >> > > > enough, then it can severely impact the ability of the
> > > > consumer
> > > > > to
> > > > > > >> make
> > > > > > >> > > > progress. The point is that the protocol may already be
> > > > unsuited
> > > > > > to
> > > > > > >> > cases
> > > > > > >> > > > where there are either a large number of consumers or
> > > topics.
> > > > I
> > > > > > >> wonder
> > > > > > >> > if
> > > > > > >> > > > you guys can share your thoughts about your scaling
> > > > > expectations?
> > > > > > >> > > >
> > > > > > >> > > > -Jason
> > > > > > >> > > >
> > > > > > >> > > >
> > > > > > >> > > >
> > > > > > >> > > >
> > > > > > >> > > > On Wed, Aug 12, 2015 at 12:28 PM, Jason Gustafson <
> > > > > > >> jason@confluent.io>
> > > > > > >> > > > wrote:
> > > > > > >> > > >
> > > > > > >> > > > > Hey Jiangjie,
> > > > > > >> > > > >
> > > > > > >> > > > > That's a great point. In the worst case (the mirror
> > maker
> > > > > case I
> > > > > > >> > > guess),
> > > > > > >> > > > > the join group response can be massive. This would be
> > > > > especially
> > > > > > >> > deadly
> > > > > > >> > > > > when there is a lot of churn in the group (e.g. in a
> > > rolling
> > > > > > >> > upgrade).
> > > > > > >> > > > The
> > > > > > >> > > > > current protocol is not great for this case either,
> but
> > > it's
> > > > > > >> > > > significantly
> > > > > > >> > > > > better. Here are a couple ways to deal with the size:
> > > > > > >> > > > >
> > > > > > >> > > > > 1. First, we could have the coordinator compress the
> > > > > responses.
> > > > > > >> This
> > > > > > >> > > > would
> > > > > > >> > > > > probably be pretty effective if applied across the
> > > metadata
> > > > > from
> > > > > > >> all
> > > > > > >> > > > > members.
> > > > > > >> > > > >
> > > > > > >> > > > > 2. I think the regex case is the main problem. Is that
> > > > right?
> > > > > We
> > > > > > >> > could
> > > > > > >> > > > > extend the metadata to allow the consumer to embed its
> > > regex
> > > > > > >> > > subscription
> > > > > > >> > > > > in the metadata directly (note this might be a good
> idea
> > > > > > >> regardless
> > > > > > >> > of
> > > > > > >> > > > the
> > > > > > >> > > > > rest of this proposal). To support regex on the
> > consumer,
> > > we
> > > > > > must
> > > > > > >> > fetch
> > > > > > >> > > > > metadata for all topics. Rather than having all regex
> > > > > > subscribers
> > > > > > >> > embed
> > > > > > >> > > > all
> > > > > > >> > > > > of this metadata in their join group requests, they
> > could
> > > > > > instead
> > > > > > >> > > embed a
> > > > > > >> > > > > hash of it. Then after the join group responses are
> > > > received,
> > > > > > they
> > > > > > >> > just
> > > > > > >> > > > > need to check that the hashes are the same. If there
> is
> > a
> > > > > > mismatch
> > > > > > >> > > (which
> > > > > > >> > > > > should only occur when topics are created, deleted, or
> > > > > resized),
> > > > > > >> then
> > > > > > >> > > the
> > > > > > >> > > > > group members must refetch the metadata and rejoin the
> > > > group.
> > > > > > >> This is
> > > > > > >> > > > also
> > > > > > >> > > > > how the current protocol behaves when there is a
> change
> > in
> > > > the
> > > > > > >> topic
> > > > > > >> > > > > metadata affecting the group--someone (either the
> > > > coordinator
> > > > > or
> > > > > > >> the
> > > > > > >> > > > > consumer) detects the change and forces the group to
> > > > > rebalance.
> > > > > > >> > > > >
> > > > > > >> > > > > What do you think?
> > > > > > >> > > > >
> > > > > > >> > > > > (Also I think adding groupId/generationId to fetch and
> > > > produce
> > > > > > >> > requests
> > > > > > >> > > > > seems like an interesting line of thought.)
> > > > > > >> > > > >
> > > > > > >> > > > > -Jason
> > > > > > >> > > > >
> > > > > > >> > > > >
> > > > > > >> > > > >
> > > > > > >> > > > > On Wed, Aug 12, 2015 at 10:57 AM, Jiangjie Qin
> > > > > > >> > > <jqin@linkedin.com.invalid
> > > > > > >> > > > >
> > > > > > >> > > > > wrote:
> > > > > > >> > > > >
> > > > > > >> > > > >> Hey Ewen,
> > > > > > >> > > > >>
> > > > > > >> > > > >> Onur and I discussed this a little bit more. And we
> are
> > > > still
> > > > > > >> > worrying
> > > > > > >> > > > >> about passing all the metadata of all consumers
> around.
> > > > > > >> > > > >>
> > > > > > >> > > > >> Let's say I have a cluster has 10,000 topics, the
> > average
> > > > > topic
> > > > > > >> name
> > > > > > >> > > > >> length
> > > > > > >> > > > >> is 10 bytes. In this case, the opaque metadata will
> > have
> > > > 10 *
> > > > > > >> > 10,000 =
> > > > > > >> > > > >> 100KB for topic name, for each topic, there is a
> 4-byte
> > > > > integer
> > > > > > >> of
> > > > > > >> > > > number
> > > > > > >> > > > >> of partitions, that's another 40KB. So one global
> topic
> > > > > > metadata
> > > > > > >> > will
> > > > > > >> > > > have
> > > > > > >> > > > >> 140KB data. If I have 100 consumers who are using
> > > wildcard
> > > > to
> > > > > > >> > consume
> > > > > > >> > > > from
> > > > > > >> > > > >> all the topics. That means the protocol metadata end
> up
> > > in
> > > > > the
> > > > > > >> > > > >> JoinGroupResponse will be 140KB * 100 = 14MB. And the
> > > > > > >> > > JoinGroupResponse
> > > > > > >> > > > >> will need to be sent to 100 different consumers, that
> > > means
> > > > > > 14MB
> > > > > > >> *
> > > > > > >> > > 100 =
> > > > > > >> > > > >> 1.4GB need to be sent by the consumer coordinator for
> > one
> > > > > > >> rebalance.
> > > > > > >> > > How
> > > > > > >> > > > >> would that work?
> > > > > > >> > > > >>
> > > > > > >> > > > >> Also, having two consumers (old owner and new owner)
> > > > > consuming
> > > > > > >> from
> > > > > > >> > > the
> > > > > > >> > > > >> same partition might also be a problem. e.g. people
> are
> > > > > > updating
> > > > > > >> > > > database.
> > > > > > >> > > > >> One thing might worth doing is to add GroupId and
> > > > Generation
> > > > > ID
> > > > > > >> to
> > > > > > >> > > > >> ProducerRequest and FetchRequest as well. This will
> > also
> > > > help
> > > > > > >> with
> > > > > > >> > the
> > > > > > >> > > > >> single producer use case. However, this is probably
> > > > > orthogonal
> > > > > > to
> > > > > > >> > this
> > > > > > >> > > > >> thread given the current new consumer also has this
> > > problem
> > > > > > and I
> > > > > > >> > > > believe
> > > > > > >> > > > >> we need to fix it.
> > > > > > >> > > > >>
> > > > > > >> > > > >> Thanks,
> > > > > > >> > > > >>
> > > > > > >> > > > >> Jiangjie (Becket) Qin
> > > > > > >> > > > >>
> > > > > > >> > > > >> On Tue, Aug 11, 2015 at 11:43 PM, Ewen
> > Cheslack-Postava <
> > > > > > >> > > > >> ewen@confluent.io>
> > > > > > >> > > > >> wrote:
> > > > > > >> > > > >>
> > > > > > >> > > > >> > On Tue, Aug 11, 2015 at 11:29 PM, Jiangjie Qin
> > > > > > >> > > > >> <jq...@linkedin.com.invalid>
> > > > > > >> > > > >> > wrote:
> > > > > > >> > > > >> >
> > > > > > >> > > > >> > > Ewen,
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> > > Thanks for the explanation.
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> > > For (1), I am more concerned about the failure
> case
> > > > > instead
> > > > > > >> of
> > > > > > >> > > > normal
> > > > > > >> > > > >> > case.
> > > > > > >> > > > >> > > What if a consumer somehow was kick out of a
> group
> > > but
> > > > is
> > > > > > >> still
> > > > > > >> > > > >> consuming
> > > > > > >> > > > >> > > and committing offsets? Does that mean the new
> > owner
> > > > and
> > > > > > old
> > > > > > >> > owner
> > > > > > >> > > > >> might
> > > > > > >> > > > >> > > potentially consuming from and committing offsets
> > for
> > > > the
> > > > > > >> same
> > > > > > >> > > > >> partition?
> > > > > > >> > > > >> > > In the old consumer, this won't happen because
> the
> > > new
> > > > > > >> consumer
> > > > > > >> > > will
> > > > > > >> > > > >> not
> > > > > > >> > > > >> > be
> > > > > > >> > > > >> > > able to start consumption unless the previous
> owner
> > > has
> > > > > > >> released
> > > > > > >> > > its
> > > > > > >> > > > >> > > ownership. Basically, without the ownership
> > > guarantee,
> > > > I
> > > > > > >> don't
> > > > > > >> > see
> > > > > > >> > > > how
> > > > > > >> > > > >> > the
> > > > > > >> > > > >> > > communication among consumers themselves alone
> can
> > > > solve
> > > > > > the
> > > > > > >> > > problem
> > > > > > >> > > > >> > here.
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> >
> > > > > > >> > > > >> > The generation ID check still applies to offset
> > > commits.
> > > > If
> > > > > > >> one of
> > > > > > >> > > the
> > > > > > >> > > > >> > consumers is kicked out and misbehaving, it can
> > > obviously
> > > > > > still
> > > > > > >> > > fetch
> > > > > > >> > > > >> and
> > > > > > >> > > > >> > process messages, but offset commits will not work
> > > since
> > > > it
> > > > > > >> will
> > > > > > >> > not
> > > > > > >> > > > >> have
> > > > > > >> > > > >> > the current generation ID.
> > > > > > >> > > > >> >
> > > > > > >> > > > >> >
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> > > For (2) and (3), now I understand how metadata
> are
> > > > used.
> > > > > > But
> > > > > > >> I
> > > > > > >> > > still
> > > > > > >> > > > >> > don't
> > > > > > >> > > > >> > > see why should we let the consumers to pass the
> > topic
> > > > > > >> > information
> > > > > > >> > > > >> across
> > > > > > >> > > > >> > > instead of letting coordinator give the
> > information.
> > > > The
> > > > > > >> single
> > > > > > >> > > > >> producer
> > > > > > >> > > > >> > > use case does not solve the ownership problem in
> > > > abnormal
> > > > > > >> case
> > > > > > >> > > > either,
> > > > > > >> > > > >> > > which seems to be a little bit vulnerable.
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> >
> > > > > > >> > > > >> > One of the goals here was to generalize group
> > > membership
> > > > so
> > > > > > we
> > > > > > >> > can,
> > > > > > >> > > > for
> > > > > > >> > > > >> > example, use it for balancing Copycat tasks across
> > > > workers.
> > > > > > >> > There's
> > > > > > >> > > no
> > > > > > >> > > > >> > topic subscription info in that case. The metadata
> > for
> > > > > > copycat
> > > > > > >> > > workers
> > > > > > >> > > > >> > would instead need to somehow indicate the current
> > set
> > > of
> > > > > > tasks
> > > > > > >> > that
> > > > > > >> > > > >> need
> > > > > > >> > > > >> > to be assigned to workers. By making the metadata
> > > > > completely
> > > > > > >> > opaque
> > > > > > >> > > to
> > > > > > >> > > > >> the
> > > > > > >> > > > >> > protocol, it becomes more generally useful since it
> > > > focuses
> > > > > > >> > squarely
> > > > > > >> > > > on
> > > > > > >> > > > >> the
> > > > > > >> > > > >> > group membership problem, allowing for that
> > additional
> > > > bit
> > > > > of
> > > > > > >> > > metadata
> > > > > > >> > > > >> so
> > > > > > >> > > > >> > you don't just get a list of members, but also get
> a
> > > > little
> > > > > > >> bit of
> > > > > > >> > > > info
> > > > > > >> > > > >> > about each of them.
> > > > > > >> > > > >> >
> > > > > > >> > > > >> > A different option that we explored is to use a
> sort
> > of
> > > > > mixed
> > > > > > >> > model
> > > > > > >> > > --
> > > > > > >> > > > >> > still bake all the topic subscriptions directly
> into
> > > the
> > > > > > >> protocol
> > > > > > >> > > but
> > > > > > >> > > > >> also
> > > > > > >> > > > >> > include metadata. That would allow us to maintain
> the
> > > > > > existing
> > > > > > >> > > > >> > coordinator-driven approach to handling the
> metadata
> > > and
> > > > > > change
> > > > > > >> > > events
> > > > > > >> > > > >> like
> > > > > > >> > > > >> > the ones Onur pointed out. Then something like the
> > > > Copycat
> > > > > > >> workers
> > > > > > >> > > > would
> > > > > > >> > > > >> > just not fill in any topic subscriptions and it
> would
> > > be
> > > > > > >> handled
> > > > > > >> > as
> > > > > > >> > > a
> > > > > > >> > > > >> > degenerate case. Based on the way I explained that
> we
> > > can
> > > > > > >> handle
> > > > > > >> > > those
> > > > > > >> > > > >> > types of events, I personally feel its cleaner and
> a
> > > > nicer
> > > > > > >> > > > >> generalization
> > > > > > >> > > > >> > to not include the subscriptions in the join group
> > > > > protocol,
> > > > > > >> > making
> > > > > > >> > > it
> > > > > > >> > > > >> part
> > > > > > >> > > > >> > of the metadata instead.
> > > > > > >> > > > >> >
> > > > > > >> > > > >> > For the single producer case, are you saying it
> > doesn't
> > > > > solve
> > > > > > >> > > > ownership
> > > > > > >> > > > >> in
> > > > > > >> > > > >> > the abnormal case because a producer that doesn't
> > know
> > > it
> > > > > has
> > > > > > >> been
> > > > > > >> > > > >> kicked
> > > > > > >> > > > >> > out of the group yet can still produce data even
> > though
> > > > it
> > > > > > >> > shouldn't
> > > > > > >> > > > be
> > > > > > >> > > > >> > able to anymore? I definitely agree that that is a
> > risk
> > > > --
> > > > > > this
> > > > > > >> > > > >> provides a
> > > > > > >> > > > >> > way to get closer to a true single-writer, but
> there
> > > are
> > > > > > >> > definitely
> > > > > > >> > > > >> still
> > > > > > >> > > > >> > failure modes that this does not address.
> > > > > > >> > > > >> >
> > > > > > >> > > > >> > -Ewen
> > > > > > >> > > > >> >
> > > > > > >> > > > >> >
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> > > Thanks,
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> > > Jiangjie (Becket) Qin
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> > > On Tue, Aug 11, 2015 at 11:06 PM, Ewen
> > > > Cheslack-Postava <
> > > > > > >> > > > >> > ewen@confluent.io
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > wrote:
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> > > > On Tue, Aug 11, 2015 at 10:15 PM, Jiangjie Qin
> > > > > > >> > > > >> > <jqin@linkedin.com.invalid
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > wrote:
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > > Hi Jason,
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > > > Thanks for writing this up. It would be
> useful
> > to
> > > > > > >> generalize
> > > > > > >> > > the
> > > > > > >> > > > >> > group
> > > > > > >> > > > >> > > > > concept. I have a few questions below.
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > > > 1. In old consumer actually the partition
> > > > assignment
> > > > > > are
> > > > > > >> > done
> > > > > > >> > > by
> > > > > > >> > > > >> > > > consumers
> > > > > > >> > > > >> > > > > themselves. We used zookeeper to guarantee
> > that a
> > > > > > >> partition
> > > > > > >> > > will
> > > > > > >> > > > >> only
> > > > > > >> > > > >> > > be
> > > > > > >> > > > >> > > > > consumed by one consumer thread who
> > successfully
> > > > > > claimed
> > > > > > >> its
> > > > > > >> > > > >> > ownership.
> > > > > > >> > > > >> > > > > Does the new protocol plan to provide the
> same
> > > > > > guarantee?
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > Once you have all the metadata from all the
> > > > consumers,
> > > > > > >> > > assignment
> > > > > > >> > > > >> > should
> > > > > > >> > > > >> > > > just be a simple function mapping that
> > > > Map<ConsumerId,
> > > > > > >> > Metadata>
> > > > > > >> > > > to
> > > > > > >> > > > >> > > > Map<ConsumerId, List<TopicPartition>>. If
> > everyone
> > > is
> > > > > > >> > consistent
> > > > > > >> > > > in
> > > > > > >> > > > >> > > > computing that, you don't need ZK involved at
> > all.
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > In practice, this shouldn't be that hard to
> > ensure
> > > > for
> > > > > > most
> > > > > > >> > > > >> assignment
> > > > > > >> > > > >> > > > strategies just by having decent unit testing
> on
> > > > them.
> > > > > > You
> > > > > > >> > just
> > > > > > >> > > > >> have to
> > > > > > >> > > > >> > > do
> > > > > > >> > > > >> > > > things like ensure your assignment strategy
> sorts
> > > > lists
> > > > > > >> into a
> > > > > > >> > > > >> > consistent
> > > > > > >> > > > >> > > > order.
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > You do give up the ability to use some
> techniques
> > > > (e.g.
> > > > > > any
> > > > > > >> > > > >> randomized
> > > > > > >> > > > >> > > > algorithm if you can't distribute the seed w/
> the
> > > > > > metadata)
> > > > > > >> > and
> > > > > > >> > > > it's
> > > > > > >> > > > >> > true
> > > > > > >> > > > >> > > > that nothing validates the assignment, but if
> > that
> > > > > > >> assignment
> > > > > > >> > > > >> algorithm
> > > > > > >> > > > >> > > > step is kept simple, small, and well tested,
> the
> > > risk
> > > > > is
> > > > > > >> very
> > > > > > >> > > > >> minimal.
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > > > 2. It looks that both JoinGroupRequest and
> > > > > > >> JoinGroupResponse
> > > > > > >> > > has
> > > > > > >> > > > >> the
> > > > > > >> > > > >> > > > > ProtocolMetadata.AssignmentStrategyMetadata,
> > what
> > > > > would
> > > > > > >> be
> > > > > > >> > the
> > > > > > >> > > > >> > metadata
> > > > > > >> > > > >> > > > be
> > > > > > >> > > > >> > > > > sent and returned by coordinator? How will
> the
> > > > > > >> coordinator
> > > > > > >> > > > handle
> > > > > > >> > > > >> the
> > > > > > >> > > > >> > > > > metadata?
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > The coordinator is basically just blindly
> > > > broadcasting
> > > > > > all
> > > > > > >> of
> > > > > > >> > it
> > > > > > >> > > > to
> > > > > > >> > > > >> > group
> > > > > > >> > > > >> > > > members so they have a consistent view.
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > So from the coordinators perspective, it sees
> > > > something
> > > > > > >> like:
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > Consumer 1 -> JoinGroupRequest with
> > GroupProtocols
> > > =
> > > > [
> > > > > > >> > > "consumer"
> > > > > > >> > > > >> > > > <Consumer1 opaque byte[]>]
> > > > > > >> > > > >> > > > Consumer 2 -> JoinGroupRequest with
> > GroupProtocols
> > > =
> > > > [
> > > > > > >> > > "consumer"
> > > > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > Then, in the responses would look like:
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > Consumer 1 <- JoinGroupResponse with
> > GroupProtocol
> > > =
> > > > > > >> > "consumer"
> > > > > > >> > > > and
> > > > > > >> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque
> > > > byte[]>,
> > > > > > >> > Consumer
> > > > > > >> > > 2
> > > > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > > > >> > > > >> > > > Consumer 2 <- JoinGroupResponse with
> > GroupProtocol
> > > =
> > > > > > >> > "consumer"
> > > > > > >> > > > and
> > > > > > >> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque
> > > > byte[]>,
> > > > > > >> > Consumer
> > > > > > >> > > 2
> > > > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > So all the responses include all the metadata
> for
> > > > every
> > > > > > >> member
> > > > > > >> > > in
> > > > > > >> > > > >> the
> > > > > > >> > > > >> > > > group, and everyone can use that to
> consistently
> > > > decide
> > > > > > on
> > > > > > >> > > > >> assignment.
> > > > > > >> > > > >> > > The
> > > > > > >> > > > >> > > > broker doesn't care and cannot even understand
> > the
> > > > > > metadata
> > > > > > >> > > since
> > > > > > >> > > > >> the
> > > > > > >> > > > >> > > data
> > > > > > >> > > > >> > > > format for it is dependent on the assignment
> > > strategy
> > > > > > being
> > > > > > >> > > used.
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > As another example that is *not* a consumer,
> > let's
> > > > say
> > > > > > you
> > > > > > >> > just
> > > > > > >> > > > >> want to
> > > > > > >> > > > >> > > > have a single writer in the group which
> everyone
> > > will
> > > > > > >> forward
> > > > > > >> > > > >> requests
> > > > > > >> > > > >> > > to.
> > > > > > >> > > > >> > > > To accomplish this, you could use a very dumb
> > > > > assignment
> > > > > > >> > > strategy:
> > > > > > >> > > > >> > there
> > > > > > >> > > > >> > > is
> > > > > > >> > > > >> > > > no metadata (empty byte[]) and all we care
> about
> > is
> > > > who
> > > > > > is
> > > > > > >> the
> > > > > > >> > > > first
> > > > > > >> > > > >> > > member
> > > > > > >> > > > >> > > > in the group (e.g. when IDs are sorted
> > > > > > lexicographically).
> > > > > > >> > That
> > > > > > >> > > > >> member
> > > > > > >> > > > >> > is
> > > > > > >> > > > >> > > > selected as the writer. In that case, we
> actually
> > > > just
> > > > > > care
> > > > > > >> > > about
> > > > > > >> > > > >> the
> > > > > > >> > > > >> > > > membership list, there's no additional info
> about
> > > > each
> > > > > > >> member
> > > > > > >> > > that
> > > > > > >> > > > >> is
> > > > > > >> > > > >> > > > required to determine who is the writer.
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > > 3. Do you mean that the number of partitions
> in
> > > > > > >> > > > JoinGroupResponse
> > > > > > >> > > > >> > will
> > > > > > >> > > > >> > > be
> > > > > > >> > > > >> > > > > the max partition number of a topic among all
> > the
> > > > > > >> reported
> > > > > > >> > > > >> partition
> > > > > > >> > > > >> > > > number
> > > > > > >> > > > >> > > > > by consumers? Is there any reason not just
> let
> > > > > > >> Coordinator
> > > > > > >> > to
> > > > > > >> > > > >> return
> > > > > > >> > > > >> > > the
> > > > > > >> > > > >> > > > > number of partitions of a topic in its
> metadata
> > > > > cache?
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > Nothing from the embedded protocol is touched
> by
> > > the
> > > > > > >> broker.
> > > > > > >> > The
> > > > > > >> > > > >> broker
> > > > > > >> > > > >> > > > just collects opaque bytes of metadata, does
> the
> > > > > > selection
> > > > > > >> of
> > > > > > >> > > the
> > > > > > >> > > > >> > > strategy
> > > > > > >> > > > >> > > > if multiple are supported by some consumers,
> and
> > > then
> > > > > > >> returns
> > > > > > >> > > that
> > > > > > >> > > > >> > opaque
> > > > > > >> > > > >> > > > metadata for all the members back to every
> > member.
> > > In
> > > > > > that
> > > > > > >> way
> > > > > > >> > > > they
> > > > > > >> > > > >> all
> > > > > > >> > > > >> > > > have a consistent view of the group. For
> regular
> > > > > > consumers,
> > > > > > >> > that
> > > > > > >> > > > >> view
> > > > > > >> > > > >> > of
> > > > > > >> > > > >> > > > the group includes information about how many
> > > > > partitions
> > > > > > >> each
> > > > > > >> > > > >> consumer
> > > > > > >> > > > >> > > > currently thinks the topics it is subscribed to
> > > has.
> > > > > > These
> > > > > > >> > could
> > > > > > >> > > > be
> > > > > > >> > > > >> > > > inconsistent due to out of date metadata and it
> > > would
> > > > > be
> > > > > > >> up to
> > > > > > >> > > the
> > > > > > >> > > > >> > > > assignment strategy on the *client* to resolve
> > > that.
> > > > As
> > > > > > you
> > > > > > >> > > point
> > > > > > >> > > > >> out,
> > > > > > >> > > > >> > in
> > > > > > >> > > > >> > > > that case they could just take the max value
> that
> > > any
> > > > > > >> consumer
> > > > > > >> > > > >> reported
> > > > > > >> > > > >> > > > seeing and use that. The consumers that notice
> > that
> > > > > their
> > > > > > >> > > metadata
> > > > > > >> > > > >> had
> > > > > > >> > > > >> > a
> > > > > > >> > > > >> > > > smaller # of partitions should also trigger a
> > > > metadata
> > > > > > >> update
> > > > > > >> > > when
> > > > > > >> > > > >> they
> > > > > > >> > > > >> > > see
> > > > > > >> > > > >> > > > someone else observing a larger # of
> partitions.
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > > > Thanks,
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > > > Jiangjie (Becket) Qin
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason
> > Gustafson
> > > <
> > > > > > >> > > > >> jason@confluent.io
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> > > > > wrote:
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > > > > Hi Kafka Devs,
> > > > > > >> > > > >> > > > > >
> > > > > > >> > > > >> > > > > > One of the nagging issues in the current
> > design
> > > > of
> > > > > > the
> > > > > > >> new
> > > > > > >> > > > >> consumer
> > > > > > >> > > > >> > > has
> > > > > > >> > > > >> > > > > > been the need to support a variety of
> > > assignment
> > > > > > >> > strategies.
> > > > > > >> > > > >> We've
> > > > > > >> > > > >> > > > > > encountered this in particular in the
> design
> > of
> > > > > > copycat
> > > > > > >> > and
> > > > > > >> > > > the
> > > > > > >> > > > >> > > > > processing
> > > > > > >> > > > >> > > > > > framework (KIP-28). From what I understand,
> > > Samza
> > > > > > also
> > > > > > >> > has a
> > > > > > >> > > > >> number
> > > > > > >> > > > >> > > of
> > > > > > >> > > > >> > > > > use
> > > > > > >> > > > >> > > > > > cases with custom assignment needs. The new
> > > > > consumer
> > > > > > >> > > protocol
> > > > > > >> > > > >> > > supports
> > > > > > >> > > > >> > > > > new
> > > > > > >> > > > >> > > > > > assignment strategies by hooking them into
> > the
> > > > > > broker.
> > > > > > >> For
> > > > > > >> > > > many
> > > > > > >> > > > >> > > > > > environments, this is a major pain and in
> > some
> > > > > > cases, a
> > > > > > >> > > > >> > non-starter.
> > > > > > >> > > > >> > > It
> > > > > > >> > > > >> > > > > > also challenges the validation that the
> > > > coordinator
> > > > > > can
> > > > > > >> > > > provide.
> > > > > > >> > > > >> > For
> > > > > > >> > > > >> > > > > > example, some assignment strategies call
> for
> > > > > > >> partitions to
> > > > > > >> > > be
> > > > > > >> > > > >> > > assigned
> > > > > > >> > > > >> > > > > > multiple times, which means that the
> > > coordinator
> > > > > can
> > > > > > >> only
> > > > > > >> > > > check
> > > > > > >> > > > >> > that
> > > > > > >> > > > >> > > > > > partitions have been assigned at least
> once.
> > > > > > >> > > > >> > > > > >
> > > > > > >> > > > >> > > > > > To solve these issues, we'd like to propose
> > > > moving
> > > > > > >> > > assignment
> > > > > > >> > > > to
> > > > > > >> > > > >> > the
> > > > > > >> > > > >> > > > > > client. I've written a wiki which outlines
> > some
> > > > > > >> protocol
> > > > > > >> > > > >> changes to
> > > > > > >> > > > >> > > > > achieve
> > > > > > >> > > > >> > > > > > this:
> > > > > > >> > > > >> > > > > >
> > > > > > >> > > > >> > > > > >
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> >
> > > > > > >> > > > >>
> > > > > > >> > > >
> > > > > > >> > >
> > > > > > >> >
> > > > > > >>
> > > > > >
> > > > >
> > > >
> > >
> >
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> > > > > > >> > > > >> > > > > > .
> > > > > > >> > > > >> > > > > > To summarize briefly, instead of the
> > > coordinator
> > > > > > >> assigning
> > > > > > >> > > the
> > > > > > >> > > > >> > > > partitions
> > > > > > >> > > > >> > > > > > itself, all subscriptions are forwarded to
> > each
> > > > > > member
> > > > > > >> of
> > > > > > >> > > the
> > > > > > >> > > > >> group
> > > > > > >> > > > >> > > > which
> > > > > > >> > > > >> > > > > > then decides independently which partitions
> > it
> > > > > should
> > > > > > >> > > consume.
> > > > > > >> > > > >> The
> > > > > > >> > > > >> > > > > protocol
> > > > > > >> > > > >> > > > > > provides a mechanism for the coordinator to
> > > > > validate
> > > > > > >> that
> > > > > > >> > > all
> > > > > > >> > > > >> > > consumers
> > > > > > >> > > > >> > > > > use
> > > > > > >> > > > >> > > > > > the same assignment strategy, but it does
> not
> > > > > ensure
> > > > > > >> that
> > > > > > >> > > the
> > > > > > >> > > > >> > > resulting
> > > > > > >> > > > >> > > > > > assignment is "correct." This provides a
> > > powerful
> > > > > > >> > capability
> > > > > > >> > > > for
> > > > > > >> > > > >> > > users
> > > > > > >> > > > >> > > > to
> > > > > > >> > > > >> > > > > > control the full data flow on the client
> > side.
> > > > They
> > > > > > >> > control
> > > > > > >> > > > how
> > > > > > >> > > > >> > data
> > > > > > >> > > > >> > > is
> > > > > > >> > > > >> > > > > > written to partitions through the
> Partitioner
> > > > > > interface
> > > > > > >> > and
> > > > > > >> > > > they
> > > > > > >> > > > >> > > > control
> > > > > > >> > > > >> > > > > > how data is consumed through the assignment
> > > > > strategy,
> > > > > > >> all
> > > > > > >> > > > >> without
> > > > > > >> > > > >> > > > > touching
> > > > > > >> > > > >> > > > > > the server.
> > > > > > >> > > > >> > > > > >
> > > > > > >> > > > >> > > > > > Of course nothing comes for free. In
> > > particular,
> > > > > this
> > > > > > >> > change
> > > > > > >> > > > >> > removes
> > > > > > >> > > > >> > > > the
> > > > > > >> > > > >> > > > > > ability of the coordinator to validate that
> > > > commits
> > > > > > are
> > > > > > >> > made
> > > > > > >> > > > by
> > > > > > >> > > > >> > > > consumers
> > > > > > >> > > > >> > > > > > who were assigned the respective partition.
> > > This
> > > > > > might
> > > > > > >> not
> > > > > > >> > > be
> > > > > > >> > > > >> too
> > > > > > >> > > > >> > bad
> > > > > > >> > > > >> > > > > since
> > > > > > >> > > > >> > > > > > we retain the ability to validate the
> > > generation
> > > > > id,
> > > > > > >> but
> > > > > > >> > it
> > > > > > >> > > > is a
> > > > > > >> > > > >> > > > > potential
> > > > > > >> > > > >> > > > > > concern. We have considered alternative
> > > protocols
> > > > > > which
> > > > > > >> > add
> > > > > > >> > > a
> > > > > > >> > > > >> > second
> > > > > > >> > > > >> > > > > > round-trip to the protocol in order to give
> > the
> > > > > > >> > coordinator
> > > > > > >> > > > the
> > > > > > >> > > > >> > > ability
> > > > > > >> > > > >> > > > > to
> > > > > > >> > > > >> > > > > > confirm the assignment. As mentioned above,
> > the
> > > > > > >> > coordinator
> > > > > > >> > > is
> > > > > > >> > > > >> > > somewhat
> > > > > > >> > > > >> > > > > > limited in what it can actually validate,
> but
> > > > this
> > > > > > >> would
> > > > > > >> > > > return
> > > > > > >> > > > >> its
> > > > > > >> > > > >> > > > > ability
> > > > > > >> > > > >> > > > > > to validate commits. The tradeoff is that
> it
> > > > > > increases
> > > > > > >> the
> > > > > > >> > > > >> > protocol's
> > > > > > >> > > > >> > > > > > complexity which means more ways for the
> > > protocol
> > > > > to
> > > > > > >> fail
> > > > > > >> > > and
> > > > > > >> > > > >> > > > > consequently
> > > > > > >> > > > >> > > > > > more edge cases in the code.
> > > > > > >> > > > >> > > > > >
> > > > > > >> > > > >> > > > > > It also misses an opportunity to generalize
> > the
> > > > > group
> > > > > > >> > > > membership
> > > > > > >> > > > >> > > > protocol
> > > > > > >> > > > >> > > > > > for additional use cases. In fact, after
> > you've
> > > > > gone
> > > > > > to
> > > > > > >> > the
> > > > > > >> > > > >> trouble
> > > > > > >> > > > >> > > of
> > > > > > >> > > > >> > > > > > moving assignment to the client, the main
> > thing
> > > > > that
> > > > > > is
> > > > > > >> > left
> > > > > > >> > > > in
> > > > > > >> > > > >> > this
> > > > > > >> > > > >> > > > > > protocol is basically a general group
> > > management
> > > > > > >> > capability.
> > > > > > >> > > > >> This
> > > > > > >> > > > >> > is
> > > > > > >> > > > >> > > > > > exactly what is needed for a few cases that
> > are
> > > > > > >> currently
> > > > > > >> > > > under
> > > > > > >> > > > >> > > > > discussion
> > > > > > >> > > > >> > > > > > (e.g. copycat or single-writer producer).
> > We've
> > > > > taken
> > > > > > >> this
> > > > > > >> > > > >> further
> > > > > > >> > > > >> > > step
> > > > > > >> > > > >> > > > > in
> > > > > > >> > > > >> > > > > > the proposal and attempted to envision what
> > > that
> > > > > > >> general
> > > > > > >> > > > >> protocol
> > > > > > >> > > > >> > > might
> > > > > > >> > > > >> > > > > > look like and how it could be used both by
> > the
> > > > > > consumer
> > > > > > >> > and
> > > > > > >> > > > for
> > > > > > >> > > > >> > some
> > > > > > >> > > > >> > > of
> > > > > > >> > > > >> > > > > > these other cases.
> > > > > > >> > > > >> > > > > >
> > > > > > >> > > > >> > > > > > Anyway, since time is running out on the
> new
> > > > > > consumer,
> > > > > > >> we
> > > > > > >> > > have
> > > > > > >> > > > >> > > perhaps
> > > > > > >> > > > >> > > > > one
> > > > > > >> > > > >> > > > > > last chance to consider a significant
> change
> > in
> > > > the
> > > > > > >> > protocol
> > > > > > >> > > > >> like
> > > > > > >> > > > >> > > this,
> > > > > > >> > > > >> > > > > so
> > > > > > >> > > > >> > > > > > have a look at the wiki and share your
> > > thoughts.
> > > > > I've
> > > > > > >> no
> > > > > > >> > > doubt
> > > > > > >> > > > >> that
> > > > > > >> > > > >> > > > some
> > > > > > >> > > > >> > > > > > ideas seem clearer in my mind than they do
> on
> > > > > paper,
> > > > > > so
> > > > > > >> > ask
> > > > > > >> > > > >> > questions
> > > > > > >> > > > >> > > > if
> > > > > > >> > > > >> > > > > > there is any confusion.
> > > > > > >> > > > >> > > > > >
> > > > > > >> > > > >> > > > > > Thanks!
> > > > > > >> > > > >> > > > > > Jason
> > > > > > >> > > > >> > > > > >
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > --
> > > > > > >> > > > >> > > > Thanks,
> > > > > > >> > > > >> > > > Ewen
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> >
> > > > > > >> > > > >> >
> > > > > > >> > > > >> >
> > > > > > >> > > > >> > --
> > > > > > >> > > > >> > Thanks,
> > > > > > >> > > > >> > Ewen
> > > > > > >> > > > >> >
> > > > > > >> > > > >>
> > > > > > >> > > > >
> > > > > > >> > > > >
> > > > > > >> > > >
> > > > > > >> > >
> > > > > > >> >
> > > > > > >>
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Thanks,
> > > > > > > Neha
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Thanks,
> > > > > > Neha
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Thanks,
> > > > > Ewen
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Thanks,
> > > Ewen
> > >
> >
>



-- 
Thanks,
Neha

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Jason Gustafson <ja...@confluent.io>.
Hey Jiangjie,

I was thinking about the same problem. When metadata is changing
frequently, the clients may not be able to ever find agreement on the
current state. The server doesn't have this problem, as you say, because it
can just take a snapshot and send that to the clients. Adding a dampening
setting to the client would help if churn is sporadic, but not if it is
steady. I think the metadata would have to be changing really frequently
for this to be a problem practically, but this is a case where the
server-side approach has an advantage.

Including the metadata in the join group response would require making the
subscription available to the coordinator, right? We lose a little bit of
the generality of the protocol, but it might not be too bad since most use
cases for reusing this protocol have a similar need for metadata (and they
can always pass an empty subscription if they don't). We've gone back and
forth a few times on this, and I'm generally not opposed. It might help if
we try to quantify the impact of the metadata churn in practice. I think
the rate of change would have to be in the low seconds for this to be a
real problem. It does seem nice though that we have a way to manage even
this much churn when we do this.

-Jason



On Fri, Aug 14, 2015 at 9:03 PM, Jiangjie Qin <jq...@linkedin.com.invalid>
wrote:

> Ewen,
>
> I agree that if there is a churn in metadata, the consumers need several
> rounds of rebalances to succeed. The difference I am thinking is that with
> coordinator as single source of truth, we can let the consumer finish one
> round of rebalance, work for a while and start the next round of rebalance.
> If we purely depend on the consumers to synchronize by themselves based on
> different metadata sources, is it possible we have some groups spending a
> lot of time on rebalancing but not able to make too much progress in
> consuming?
>
> I'm thinking can we let consumers to fetch metadata only from their
> coordinator? So the rebalance can be done in the following way:
>
> 1. Consumers refresh their metadata periodically
> 2. If one of the consumer sees a change in metadata that triggers a
> rebalance, it sends JoinGroupRequest to coordinator.
> 3. Once the coordinator receives the first JoinGroupRequest of a group, it
> takes a snapshot of current metadata and the group enters prepare-rebalance
> state.
> 4. The metadata snapshot will be used for this round of rebalance. i.e. the
> metadata snapshot will be sent to consumers in JoinGroupResponse.
> 4.1 If the consumers are subscribing to explicit topic lists (not regex),
> the JoinGroupResponse needs only contain the metadata of all topics the
> group is interested.
> 4.2 If the consumers are subscribing using regex, all the topic metadata
> will be returned to the consumer.
> 5. Consumers get JoinGroupResponse, refresh metadata using the metadata in
> JoinGroupResponse, run algorithm to assign partitions and start consume.
> 6. Go back to 1.
>
> The benefit here is that we can let rebalance finish in one round, and all
> the rest of changes will be captured in next consumer metadata refresh - so
> we get group commit. One concern might be letting consumer refresh metadata
> from coordinator might cause issue for big consumer groups. Maybe that is
> OK because metadata refresh is infrequent.
>
> This approach actually is very similar to what is proposed now: rebalance
> is triggered by metadata refresh, consumer provides subscription list to
> pass around. The only difference is that we don't need metadata hash
> anymore because the metadata is guaranteed to be the same. Replacing
> metadata hash with actual metadata will not have too much overhead for
> small subscription groups. There will be some overhead for regex
> subscriptions, but this can save the potential extra round of metadata
> fetch and will only occur when consumer see metadata change, which is
> infrequent.
>
> Any thoughts?
>
> Thanks,
>
> Jiangjie (Becket) Qin
>
>
> On Fri, Aug 14, 2015 at 12:57 PM, Ewen Cheslack-Postava <ewen@confluent.io
> >
> wrote:
>
> > On Fri, Aug 14, 2015 at 10:59 AM, Jiangjie Qin <jqin@linkedin.com.invalid
> >
> > wrote:
> >
> > > Neha and Ewen,
> > >
> > > About the metadata change frequency. I guess it really depends on how
> > > frequent the metadata change might occur. If we run Kafka as a
> service, I
> > > can see that happens from time to time. As I can imagine people will
> > create
> > > some topic, test and maybe delete the topic in some automated test. If
> > so,
> > > the proposed protocol might be a little bit vulnerable.
> > >
> > > More specifically the scenario I am thinking is:
> > > 1. Consumer 0 periodically refresh metadata and detected a metadata
> > change.
> > > So it sends a JoinGroupRequest with metadata_hash_0.
> > > 2. Consumer 1 was notified by controller to start a rebalance, so it
> > > refreshes its metadata and send a JoingGroupRequest with
> metadata_hash_1,
> > > which is different from metadata hash 0.
> > > 3. Rebalance failed and both consumer refresh there metadata again from
> > > different brokers.
> > > 4. Depending on the metadata change frequency(or some admin operation
> > like
> > > partition reassigment), they may or may not have the same metadata
> > > returned, so the restart from 3 again.
> > >
> > > I agree that step 4 might not be a big concern if consumers updates
> > > metadata at almost the same time, but I'm a little bit worried whether
> > that
> > > assumption really stands because we do not have control over how
> frequent
> > > the metadata can change.
> > >
> > >
> > Is this really that different from what would happen if the coordinator
> > distributed the metadata to consumers? In that case you would trivially
> > have everyone in a consistent state, but those metadata changes would
> still
> > cause churn and require JoinGroup rounds, during which processing is
> > stalled for the nodes that are waiting on other members to re-join the
> > group.
> >
> > -Ewen
> >
> >
> > > Thanks,
> > >
> > > Jiangjie (Becket) Qin
> > >
> > > On Fri, Aug 14, 2015 at 2:03 AM, Ewen Cheslack-Postava <
> > ewen@confluent.io>
> > > wrote:
> > >
> > > > On Thu, Aug 13, 2015 at 11:07 PM, Neha Narkhede <ne...@confluent.io>
> > > wrote:
> > > >
> > > > > Becket,
> > > > >
> > > > > As you say, the metadata hash addresses the concern you originally
> > > raised
> > > > > about large topic subscriptions. Can you please list other problems
> > you
> > > > are
> > > > > raising more clearly? It is more helpful to know problems that the
> > > > proposal
> > > > > does not address or addresses poorly.
> > > > >
> > > > > Regarding other things you said -
> > > > >
> > > > > it is required that each
> > > > > > consumer refresh their metadata before sending a JoinGroupRequest
> > > > > >
> > > > >
> > > > > This is required for wildcard topic subscriptions anyway. So this
> > > > proposal
> > > > > does not introduce a regression. We had agreed earlier that it does
> > not
> > > > > make sense for the server to deserialize regular expressions sent
> by
> > > the
> > > > > consumer.
> > > > >
> > > >
> > > > I don't think consumers need to do a metadata refresh before sending
> a
> > > > JoinGroupRequest. Metadata changes that affect assignment are rare --
> > it
> > > > requires changing the number of partitions in a topic. But you might
> > > send a
> > > > JoinGroupRequest simply because a new member is trying to join the
> > group.
> > > > That case is presumably much more common.
> > > >
> > > > I think it's actually a good idea to have the first JoinGroup cycle
> > fail
> > > in
> > > > some cases, and has little impact. Lets say the metadata does change
> > > > because partitions are added. Then we might fail in the first round,
> > but
> > > > then all members detect that issue *immediately*, refresh their
> > metadata,
> > > > and submit a new join group request. This second cycle does not
> > require a
> > > > full heartbeat cycle. It happens much more quickly because everyone
> > > > detected the inconsistency based on the first JoinGroupResponse. The
> > > > inconsistency should be resolved very quickly (barring other failures
> > > like
> > > > a member leaving mid-rebalance)
> > >
> > >
> > >
> > >
> > > > >
> > > > >
> > > > > > the metadata might still be inconsistent if there is a topic or
> > > > partition
> > > > > > change because the
> > > > > > UpdateMetadataRequest from controller might be handled at
> different
> > > > time.
> > > > > >
> > > > >
> > > > > Topic metadata does not change frequently and even if it did, a
> > couple
> > > > > rebalance attempts will be needed whether the coordinator drives
> the
> > > > > assignments or the consumer. Because guess how the coordinator
> knows
> > > > about
> > > > > the topic metadata changes -- indirectly through either a zk
> callback
> > > or
> > > > > UpdateMetadataRequest, so it is completely possible the coordinator
> > > sees
> > > > > the topic metadata changes in batches, not all at once.
> > > > >
> > > >
> > > > > On Thu, Aug 13, 2015 at 10:50 PM, Neha Narkhede <neha@confluent.io
> >
> > > > wrote:
> > > > >
> > > > > > Ewen/Jason,
> > > > > >
> > > > > > The metadata hash is a clever approach and certainly addresses
> the
> > > > > problem
> > > > > > of large metadata for consumers like mirror maker. Few comments -
> > > > > >
> > > > > >
> > > > > >    1. In the interest of simplifying the format of the consumer's
> > > > > >    metadata - Why not just always include only the topic names in
> > the
> > > > > metadata
> > > > > >    followed by the metadata hash? If the metadata hash check
> > > succeeds,
> > > > > each
> > > > > >    consumer uses the # of partitions it had fetched. If it
> fails, a
> > > > > rebalance
> > > > > >    happens and the metadata is not used anyway.
> > > > >
> > > >
> > > > Doing this requires that every consumer always fetch the full
> metadata.
> > > The
> > > > most common use case is consumers that just want to consume one or a
> > > couple
> > > > of topics, in which case grabbing all metadata for the entire cluster
> > is
> > > > wasteful. If I subscribe only to topic A, why make all consumers grab
> > > > metadata for the entire topic (and need to rebalance every time it
> > > > changes!). Including the # of partitions for each topic lets you
> avoid
> > > > having to grab the global set of metadata.
> > > >
> > > > So if you're just subscribing to one or a couple of topics, why not
> > just
> > > > compute the hash by filtering out everything but the topics you are
> > > > subscribed to? The problem there is if you ever add/remove
> > subscriptions
> > > > and want to support rolling upgrades. If the group was subscribed to
> > > topic
> > > > A, but later changes require subscribing to A + B, then to achieve a
> > > > seamless rolling upgrade would require one (old) consumer to be
> > > subscribing
> > > > to A and one (new) consumer to be subscribing to A+B. If we computed
> > > > metadata hashes based on filtered metadata, those two would disagree
> > and
> > > we
> > > > could not perform assignment while the upgrade was in progress.
> > > >
> > > > The solution is to differentiate between the cases when a very small
> > > amount
> > > > of the metadata is needed (one or a couple of topic subscriptions;
> > > > communicate and share this via metadata in the JoinGroup protocol) vs
> > > when
> > > > *all* the metadata is needed (regex subscription; verify agreement
> via
> > > > hash).
> > > >
> > >
> > > >
> > > >
> > > > > >    2. Do you need a topic list and topic regex to be separate? A
> > > single
> > > > > >    topic or list of topics can be expressed as a regex.
> > > > >
> > > >
> > > > See above note about collecting all metadata when you really only
> need
> > it
> > > > for 1 or 2 topics. There's probably some debate to be had about
> whether
> > > > this cost would be too high -- every consumer would need to request
> the
> > > > metadata for all topics, and they'd need to request that all every
> time
> > > > they might be out of date.
> > > >
> > > Are we going to allow consumers in the same group to subscribe to
> > different
> > > topic set? If we do, we need to let them refresh metadata for all the
> > > topics a group is consuming from. If we don't then in the protocol we
> > only
> > > need a subscription set hash.
> > >
> > > >
> > > >
> > > > > >    3. Let's include a version explicitly at the beginning of the
> > > > > >    ProtocolMetadata. The version dictates how to deserialize the
> > > > > >    ProtocolMetadata blob and is consistent with the rest of
> Kafka.
> > > > >
> > > >
> > > > If I'm understanding correctly, in JoinGroupRequest I would change
> > > >
> > > > GroupProtocols          => [Protocol ProtocolMetadata]
> > > >
> > > > to
> > > >
> > > > GroupProtocols          => [Protocol ProtocolVersion
> ProtocolMetadata]
> > > >
> > > > We had been talking about just baking the version into the Protocol
> > > field,
> > > > but making it separate seems perfectly reasonable to me. Jason, any
> > issue
> > > > with splitting the version out into a separate field like this?
> > > >
> > > > >
> > > > > > That can simplify the metadata format to the following:
> > > > > >
> > > > > > GroupType => "consumer"
> > > > > >>
> > > > > >> Protocol => AssignmentStrategy
> > > > > >>   AssignmentStrategy   => String
> > > > > >>
> > > > > >> ProtocolMetadata => Version Subscription
> > AssignmentStrategyMetadata
> > > > > >
> > > > > >     Version                    => String
> > > > > >
> > > > > >   Subscription                 => TopicRegex MetadataHash
> > > > > >>     TopicRegex                 => String
> > > > > >>     MetadataHash               => String
> > > > > >>   AssignmentStrategyMetadata   => bytes
> > > > >
> > > > >
> > > > > >
> > > > > > On Thu, Aug 13, 2015 at 6:28 PM, Jiangjie Qin
> > > > <jqin@linkedin.com.invalid
> > > > > >
> > > > > > wrote:
> > > > > >
> > > > > >> Ewen and Jason,
> > > > > >>
> > > > > >> Thanks for the reply. Sorry I missed the metadata hash. Yes,
> that
> > > is a
> > > > > >> clever approach and would solve my concern about the data
> passing
> > > > > around.
> > > > > >> I
> > > > > >> can see both pros and cons from doing this, though. The
> advantage
> > is
> > > > we
> > > > > >> don't need the topic metadata in JoinGroupResponse anymore. The
> > > > downside
> > > > > >> is
> > > > > >> that now rebalance have extra dependency on the consensus of
> > > metadata
> > > > of
> > > > > >> all consumers, which is obtained separately. So it is required
> > that
> > > > each
> > > > > >> consumer refresh their metadata before sending a
> JoinGroupRequest,
> > > > > >> otherwise in some cases (e.g. wildcard consumers) will almost
> > > > certainly
> > > > > >> fail for the first rebalance attempt. Even if we do that, since
> > the
> > > > > >> consumers are getting metadata from different brokers, the
> > metadata
> > > > > might
> > > > > >> still be inconsistent if there is a topic or partition change
> > > because
> > > > > the
> > > > > >> UpdateMetadataRequest from controller might be handled at
> > different
> > > > > time.
> > > > > >> Just want to make sure we think through the cases so the
> protocol
> > > does
> > > > > not
> > > > > >> cause us unexpected issues.
> > > > > >>
> > > > > >> About the number of consumers, I think with the current
> liveliness
> > > > > >> definition, we can tolerate churns by bumping up the session
> > > timeout.
> > > > > Also
> > > > > >> I guess we will see an increasing number of consumers for new
> > > > consumer,
> > > > > >> because every the old consumer thread will probably become a
> > > consumer.
> > > > > >>
> > > > > >> It is a valid concern for consumers that have large subscription
> > > set.
> > > > > This
> > > > > >> might not be avoided though for client side assignment approach.
> > One
> > > > > >> solution is having topic names associate with a topic ID. And
> only
> > > use
> > > > > >> topic ID in JoinGroupRequest and JoinGroupResponse, There is a
> > > > > discussion
> > > > > >> thread about this to solve the topic renaming case but this is a
> > > > > >> completely
> > > > > >> different discussion.
> > > > > >>
> > > > > >> Thanks,
> > > > > >>
> > > > > >> Jiangjie (Becket) Qin
> > > > > >>
> > > > > >>
> > > > > >>
> > > > > >> On Thu, Aug 13, 2015 at 2:14 PM, Jason Gustafson <
> > > jason@confluent.io>
> > > > > >> wrote:
> > > > > >>
> > > > > >> > Thanks Jiangjie, that information helps. I agree the protocol
> > must
> > > > > >> consider
> > > > > >> > scalability. My point was that the synchronization barrier in
> > the
> > > > > >> current
> > > > > >> > protocol already effectively limits the number of consumers
> > since
> > > it
> > > > > >> > provides no way to gracefully handle churn. It wouldn't be
> worth
> > > > > >> worrying
> > > > > >> > about scaling up to 100,000 members, for example, because
> > there's
> > > no
> > > > > way
> > > > > >> > the group would be stable. So we just need to set some clear
> > > > > >> expectations
> > > > > >> > on the size we can scale to, and that can help inform the
> > > discussion
> > > > > on
> > > > > >> the
> > > > > >> > size of messages in this protocol.
> > > > > >> >
> > > > > >> > Ewen and I were discussing this morning along similar lines to
> > > what
> > > > > >> you're
> > > > > >> > suggesting. However, even if the coordinator decides on the
> > > metadata
> > > > > for
> > > > > >> > the group, each member still needs to communicate its
> > > subscriptions
> > > > to
> > > > > >> the
> > > > > >> > rest of the group. This is nice for the regex case since the
> > regex
> > > > is
> > > > > >> > probably small, but if the members have a large topic list,
> then
> > > we
> > > > > have
> > > > > >> > the same problem. One thing I was thinking about was whether
> we
> > > > really
> > > > > >> need
> > > > > >> > to handle different subscriptions for every member. If the
> > > > coordinator
> > > > > >> > could guarantee that all members had the same subscription,
> then
> > > > there
> > > > > >> > would be no need for the coordinator to return the
> subscriptions
> > > for
> > > > > >> each
> > > > > >> > member. However, this would prevent graceful upgrades. We
> might
> > be
> > > > > able
> > > > > >> to
> > > > > >> > fix that problem by allowing the consumer to provide two
> > > > subscriptions
> > > > > >> to
> > > > > >> > allowing rolling updates, but that starts to sound pretty
> nasty.
> > > > > >> >
> > > > > >> > -Jason
> > > > > >> >
> > > > > >> > On Thu, Aug 13, 2015 at 1:41 PM, Jiangjie Qin
> > > > > <jqin@linkedin.com.invalid
> > > > > >> >
> > > > > >> > wrote:
> > > > > >> >
> > > > > >> > > Jason,
> > > > > >> > >
> > > > > >> > > The protocol has to consider the scalability. The protocol
> in
> > > the
> > > > > wiki
> > > > > >> > > means the JoinGroupResoponse size would be:
> > > > > >> > > NumberOfTopics * (AvgTopicNameLength + 4) *
> > > (NumberOfConsumers)^2
> > > > > >> > >
> > > > > >> > > To give some real number, we have 26-node Mirror Maker
> > cluster,
> > > > each
> > > > > >> > with 4
> > > > > >> > > consumers. That is 104 consumers using regex ".*". And most
> of
> > > our
> > > > > >> > clusters
> > > > > >> > > have around 3000 topics, whose topic name are typically
> around
> > > 20
> > > > > >> > > characters.
> > > > > >> > >
> > > > > >> > > I think the key issue for client side partition assignment
> > logic
> > > > is
> > > > > to
> > > > > >> > make
> > > > > >> > > sure 1) all the clients run the same algorithm. 2) all the
> > > clients
> > > > > >> make
> > > > > >> > > decision on the same topic metadata. The second purpose can
> be
> > > > done
> > > > > by
> > > > > >> > > simply letting coordinator provide the topic metadata and
> all
> > > then
> > > > > >> member
> > > > > >> > > information as source of truth. Is it necessary to pass
> topic
> > > > > >> metadata of
> > > > > >> > > each consumer around? Can we keep the protocol metadata
> field
> > > > > >> completely
> > > > > >> > > independent of topic metadata? I think In the
> > JoinGroupResponse,
> > > > we
> > > > > >> > should
> > > > > >> > > have only one copy of topic metadata provided by coordinator
> > and
> > > > is
> > > > > >> > outside
> > > > > >> > > of protocol metadata. If user decides to put some metadata
> in
> > > the
> > > > > >> > > JoinGroupRequest and let coordinator pass around, they are
> > > > > responsible
> > > > > >> > for
> > > > > >> > > understanding the risk.
> > > > > >> > >
> > > > > >> > > Thanks,
> > > > > >> > >
> > > > > >> > > Jiangjie (Becket) Qin
> > > > > >> > >
> > > > > >> > >
> > > > > >> > > On Thu, Aug 13, 2015 at 12:41 PM, Jason Gustafson <
> > > > > jason@confluent.io
> > > > > >> >
> > > > > >> > > wrote:
> > > > > >> > >
> > > > > >> > > > Hey Onur and Jiangjie,
> > > > > >> > > >
> > > > > >> > > > I've updated that wiki with a proposal to add regex
> > > > subscriptions
> > > > > to
> > > > > >> > the
> > > > > >> > > > consumer metadata. Can you have a look to see if it
> > addresses
> > > > your
> > > > > >> > > concern?
> > > > > >> > > > In general, I think we should be a little careful when we
> > are
> > > > > >> talking
> > > > > >> > > about
> > > > > >> > > > the scalability of the protocol. Regardless of whether
> > > > assignment
> > > > > is
> > > > > >> > done
> > > > > >> > > > on the server or the client, the protocol assumes a
> > relatively
> > > > > >> stable
> > > > > >> > > > configuration. When the number of consumers increases
> > beyond a
> > > > > >> certain
> > > > > >> > > > limit, then membership churn becomes a major concern.
> > > Similarly
> > > > > >> there
> > > > > >> > is
> > > > > >> > > a
> > > > > >> > > > notion of metadata churn when topics are added, deleted,
> or
> > > > > >> resized. If
> > > > > >> > > > either membership or metadata changes, then the protocol
> > > forces
> > > > > all
> > > > > >> > > > consumers to stop consumption and rejoin the group. If
> this
> > > > > happens
> > > > > >> > often
> > > > > >> > > > enough, then it can severely impact the ability of the
> > > consumer
> > > > to
> > > > > >> make
> > > > > >> > > > progress. The point is that the protocol may already be
> > > unsuited
> > > > > to
> > > > > >> > cases
> > > > > >> > > > where there are either a large number of consumers or
> > topics.
> > > I
> > > > > >> wonder
> > > > > >> > if
> > > > > >> > > > you guys can share your thoughts about your scaling
> > > > expectations?
> > > > > >> > > >
> > > > > >> > > > -Jason
> > > > > >> > > >
> > > > > >> > > >
> > > > > >> > > >
> > > > > >> > > >
> > > > > >> > > > On Wed, Aug 12, 2015 at 12:28 PM, Jason Gustafson <
> > > > > >> jason@confluent.io>
> > > > > >> > > > wrote:
> > > > > >> > > >
> > > > > >> > > > > Hey Jiangjie,
> > > > > >> > > > >
> > > > > >> > > > > That's a great point. In the worst case (the mirror
> maker
> > > > case I
> > > > > >> > > guess),
> > > > > >> > > > > the join group response can be massive. This would be
> > > > especially
> > > > > >> > deadly
> > > > > >> > > > > when there is a lot of churn in the group (e.g. in a
> > rolling
> > > > > >> > upgrade).
> > > > > >> > > > The
> > > > > >> > > > > current protocol is not great for this case either, but
> > it's
> > > > > >> > > > significantly
> > > > > >> > > > > better. Here are a couple ways to deal with the size:
> > > > > >> > > > >
> > > > > >> > > > > 1. First, we could have the coordinator compress the
> > > > responses.
> > > > > >> This
> > > > > >> > > > would
> > > > > >> > > > > probably be pretty effective if applied across the
> > metadata
> > > > from
> > > > > >> all
> > > > > >> > > > > members.
> > > > > >> > > > >
> > > > > >> > > > > 2. I think the regex case is the main problem. Is that
> > > right?
> > > > We
> > > > > >> > could
> > > > > >> > > > > extend the metadata to allow the consumer to embed its
> > regex
> > > > > >> > > subscription
> > > > > >> > > > > in the metadata directly (note this might be a good idea
> > > > > >> regardless
> > > > > >> > of
> > > > > >> > > > the
> > > > > >> > > > > rest of this proposal). To support regex on the
> consumer,
> > we
> > > > > must
> > > > > >> > fetch
> > > > > >> > > > > metadata for all topics. Rather than having all regex
> > > > > subscribers
> > > > > >> > embed
> > > > > >> > > > all
> > > > > >> > > > > of this metadata in their join group requests, they
> could
> > > > > instead
> > > > > >> > > embed a
> > > > > >> > > > > hash of it. Then after the join group responses are
> > > received,
> > > > > they
> > > > > >> > just
> > > > > >> > > > > need to check that the hashes are the same. If there is
> a
> > > > > mismatch
> > > > > >> > > (which
> > > > > >> > > > > should only occur when topics are created, deleted, or
> > > > resized),
> > > > > >> then
> > > > > >> > > the
> > > > > >> > > > > group members must refetch the metadata and rejoin the
> > > group.
> > > > > >> This is
> > > > > >> > > > also
> > > > > >> > > > > how the current protocol behaves when there is a change
> in
> > > the
> > > > > >> topic
> > > > > >> > > > > metadata affecting the group--someone (either the
> > > coordinator
> > > > or
> > > > > >> the
> > > > > >> > > > > consumer) detects the change and forces the group to
> > > > rebalance.
> > > > > >> > > > >
> > > > > >> > > > > What do you think?
> > > > > >> > > > >
> > > > > >> > > > > (Also I think adding groupId/generationId to fetch and
> > > produce
> > > > > >> > requests
> > > > > >> > > > > seems like an interesting line of thought.)
> > > > > >> > > > >
> > > > > >> > > > > -Jason
> > > > > >> > > > >
> > > > > >> > > > >
> > > > > >> > > > >
> > > > > >> > > > > On Wed, Aug 12, 2015 at 10:57 AM, Jiangjie Qin
> > > > > >> > > <jqin@linkedin.com.invalid
> > > > > >> > > > >
> > > > > >> > > > > wrote:
> > > > > >> > > > >
> > > > > >> > > > >> Hey Ewen,
> > > > > >> > > > >>
> > > > > >> > > > >> Onur and I discussed this a little bit more. And we are
> > > still
> > > > > >> > worrying
> > > > > >> > > > >> about passing all the metadata of all consumers around.
> > > > > >> > > > >>
> > > > > >> > > > >> Let's say I have a cluster has 10,000 topics, the
> average
> > > > topic
> > > > > >> name
> > > > > >> > > > >> length
> > > > > >> > > > >> is 10 bytes. In this case, the opaque metadata will
> have
> > > 10 *
> > > > > >> > 10,000 =
> > > > > >> > > > >> 100KB for topic name, for each topic, there is a 4-byte
> > > > integer
> > > > > >> of
> > > > > >> > > > number
> > > > > >> > > > >> of partitions, that's another 40KB. So one global topic
> > > > > metadata
> > > > > >> > will
> > > > > >> > > > have
> > > > > >> > > > >> 140KB data. If I have 100 consumers who are using
> > wildcard
> > > to
> > > > > >> > consume
> > > > > >> > > > from
> > > > > >> > > > >> all the topics. That means the protocol metadata end up
> > in
> > > > the
> > > > > >> > > > >> JoinGroupResponse will be 140KB * 100 = 14MB. And the
> > > > > >> > > JoinGroupResponse
> > > > > >> > > > >> will need to be sent to 100 different consumers, that
> > means
> > > > > 14MB
> > > > > >> *
> > > > > >> > > 100 =
> > > > > >> > > > >> 1.4GB need to be sent by the consumer coordinator for
> one
> > > > > >> rebalance.
> > > > > >> > > How
> > > > > >> > > > >> would that work?
> > > > > >> > > > >>
> > > > > >> > > > >> Also, having two consumers (old owner and new owner)
> > > > consuming
> > > > > >> from
> > > > > >> > > the
> > > > > >> > > > >> same partition might also be a problem. e.g. people are
> > > > > updating
> > > > > >> > > > database.
> > > > > >> > > > >> One thing might worth doing is to add GroupId and
> > > Generation
> > > > ID
> > > > > >> to
> > > > > >> > > > >> ProducerRequest and FetchRequest as well. This will
> also
> > > help
> > > > > >> with
> > > > > >> > the
> > > > > >> > > > >> single producer use case. However, this is probably
> > > > orthogonal
> > > > > to
> > > > > >> > this
> > > > > >> > > > >> thread given the current new consumer also has this
> > problem
> > > > > and I
> > > > > >> > > > believe
> > > > > >> > > > >> we need to fix it.
> > > > > >> > > > >>
> > > > > >> > > > >> Thanks,
> > > > > >> > > > >>
> > > > > >> > > > >> Jiangjie (Becket) Qin
> > > > > >> > > > >>
> > > > > >> > > > >> On Tue, Aug 11, 2015 at 11:43 PM, Ewen
> Cheslack-Postava <
> > > > > >> > > > >> ewen@confluent.io>
> > > > > >> > > > >> wrote:
> > > > > >> > > > >>
> > > > > >> > > > >> > On Tue, Aug 11, 2015 at 11:29 PM, Jiangjie Qin
> > > > > >> > > > >> <jq...@linkedin.com.invalid>
> > > > > >> > > > >> > wrote:
> > > > > >> > > > >> >
> > > > > >> > > > >> > > Ewen,
> > > > > >> > > > >> > >
> > > > > >> > > > >> > > Thanks for the explanation.
> > > > > >> > > > >> > >
> > > > > >> > > > >> > > For (1), I am more concerned about the failure case
> > > > instead
> > > > > >> of
> > > > > >> > > > normal
> > > > > >> > > > >> > case.
> > > > > >> > > > >> > > What if a consumer somehow was kick out of a group
> > but
> > > is
> > > > > >> still
> > > > > >> > > > >> consuming
> > > > > >> > > > >> > > and committing offsets? Does that mean the new
> owner
> > > and
> > > > > old
> > > > > >> > owner
> > > > > >> > > > >> might
> > > > > >> > > > >> > > potentially consuming from and committing offsets
> for
> > > the
> > > > > >> same
> > > > > >> > > > >> partition?
> > > > > >> > > > >> > > In the old consumer, this won't happen because the
> > new
> > > > > >> consumer
> > > > > >> > > will
> > > > > >> > > > >> not
> > > > > >> > > > >> > be
> > > > > >> > > > >> > > able to start consumption unless the previous owner
> > has
> > > > > >> released
> > > > > >> > > its
> > > > > >> > > > >> > > ownership. Basically, without the ownership
> > guarantee,
> > > I
> > > > > >> don't
> > > > > >> > see
> > > > > >> > > > how
> > > > > >> > > > >> > the
> > > > > >> > > > >> > > communication among consumers themselves alone can
> > > solve
> > > > > the
> > > > > >> > > problem
> > > > > >> > > > >> > here.
> > > > > >> > > > >> > >
> > > > > >> > > > >> >
> > > > > >> > > > >> > The generation ID check still applies to offset
> > commits.
> > > If
> > > > > >> one of
> > > > > >> > > the
> > > > > >> > > > >> > consumers is kicked out and misbehaving, it can
> > obviously
> > > > > still
> > > > > >> > > fetch
> > > > > >> > > > >> and
> > > > > >> > > > >> > process messages, but offset commits will not work
> > since
> > > it
> > > > > >> will
> > > > > >> > not
> > > > > >> > > > >> have
> > > > > >> > > > >> > the current generation ID.
> > > > > >> > > > >> >
> > > > > >> > > > >> >
> > > > > >> > > > >> > >
> > > > > >> > > > >> > > For (2) and (3), now I understand how metadata are
> > > used.
> > > > > But
> > > > > >> I
> > > > > >> > > still
> > > > > >> > > > >> > don't
> > > > > >> > > > >> > > see why should we let the consumers to pass the
> topic
> > > > > >> > information
> > > > > >> > > > >> across
> > > > > >> > > > >> > > instead of letting coordinator give the
> information.
> > > The
> > > > > >> single
> > > > > >> > > > >> producer
> > > > > >> > > > >> > > use case does not solve the ownership problem in
> > > abnormal
> > > > > >> case
> > > > > >> > > > either,
> > > > > >> > > > >> > > which seems to be a little bit vulnerable.
> > > > > >> > > > >> > >
> > > > > >> > > > >> >
> > > > > >> > > > >> > One of the goals here was to generalize group
> > membership
> > > so
> > > > > we
> > > > > >> > can,
> > > > > >> > > > for
> > > > > >> > > > >> > example, use it for balancing Copycat tasks across
> > > workers.
> > > > > >> > There's
> > > > > >> > > no
> > > > > >> > > > >> > topic subscription info in that case. The metadata
> for
> > > > > copycat
> > > > > >> > > workers
> > > > > >> > > > >> > would instead need to somehow indicate the current
> set
> > of
> > > > > tasks
> > > > > >> > that
> > > > > >> > > > >> need
> > > > > >> > > > >> > to be assigned to workers. By making the metadata
> > > > completely
> > > > > >> > opaque
> > > > > >> > > to
> > > > > >> > > > >> the
> > > > > >> > > > >> > protocol, it becomes more generally useful since it
> > > focuses
> > > > > >> > squarely
> > > > > >> > > > on
> > > > > >> > > > >> the
> > > > > >> > > > >> > group membership problem, allowing for that
> additional
> > > bit
> > > > of
> > > > > >> > > metadata
> > > > > >> > > > >> so
> > > > > >> > > > >> > you don't just get a list of members, but also get a
> > > little
> > > > > >> bit of
> > > > > >> > > > info
> > > > > >> > > > >> > about each of them.
> > > > > >> > > > >> >
> > > > > >> > > > >> > A different option that we explored is to use a sort
> of
> > > > mixed
> > > > > >> > model
> > > > > >> > > --
> > > > > >> > > > >> > still bake all the topic subscriptions directly into
> > the
> > > > > >> protocol
> > > > > >> > > but
> > > > > >> > > > >> also
> > > > > >> > > > >> > include metadata. That would allow us to maintain the
> > > > > existing
> > > > > >> > > > >> > coordinator-driven approach to handling the metadata
> > and
> > > > > change
> > > > > >> > > events
> > > > > >> > > > >> like
> > > > > >> > > > >> > the ones Onur pointed out. Then something like the
> > > Copycat
> > > > > >> workers
> > > > > >> > > > would
> > > > > >> > > > >> > just not fill in any topic subscriptions and it would
> > be
> > > > > >> handled
> > > > > >> > as
> > > > > >> > > a
> > > > > >> > > > >> > degenerate case. Based on the way I explained that we
> > can
> > > > > >> handle
> > > > > >> > > those
> > > > > >> > > > >> > types of events, I personally feel its cleaner and a
> > > nicer
> > > > > >> > > > >> generalization
> > > > > >> > > > >> > to not include the subscriptions in the join group
> > > > protocol,
> > > > > >> > making
> > > > > >> > > it
> > > > > >> > > > >> part
> > > > > >> > > > >> > of the metadata instead.
> > > > > >> > > > >> >
> > > > > >> > > > >> > For the single producer case, are you saying it
> doesn't
> > > > solve
> > > > > >> > > > ownership
> > > > > >> > > > >> in
> > > > > >> > > > >> > the abnormal case because a producer that doesn't
> know
> > it
> > > > has
> > > > > >> been
> > > > > >> > > > >> kicked
> > > > > >> > > > >> > out of the group yet can still produce data even
> though
> > > it
> > > > > >> > shouldn't
> > > > > >> > > > be
> > > > > >> > > > >> > able to anymore? I definitely agree that that is a
> risk
> > > --
> > > > > this
> > > > > >> > > > >> provides a
> > > > > >> > > > >> > way to get closer to a true single-writer, but there
> > are
> > > > > >> > definitely
> > > > > >> > > > >> still
> > > > > >> > > > >> > failure modes that this does not address.
> > > > > >> > > > >> >
> > > > > >> > > > >> > -Ewen
> > > > > >> > > > >> >
> > > > > >> > > > >> >
> > > > > >> > > > >> > >
> > > > > >> > > > >> > > Thanks,
> > > > > >> > > > >> > >
> > > > > >> > > > >> > > Jiangjie (Becket) Qin
> > > > > >> > > > >> > >
> > > > > >> > > > >> > >
> > > > > >> > > > >> > > On Tue, Aug 11, 2015 at 11:06 PM, Ewen
> > > Cheslack-Postava <
> > > > > >> > > > >> > ewen@confluent.io
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > wrote:
> > > > > >> > > > >> > >
> > > > > >> > > > >> > > > On Tue, Aug 11, 2015 at 10:15 PM, Jiangjie Qin
> > > > > >> > > > >> > <jqin@linkedin.com.invalid
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > wrote:
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > > Hi Jason,
> > > > > >> > > > >> > > > >
> > > > > >> > > > >> > > > > Thanks for writing this up. It would be useful
> to
> > > > > >> generalize
> > > > > >> > > the
> > > > > >> > > > >> > group
> > > > > >> > > > >> > > > > concept. I have a few questions below.
> > > > > >> > > > >> > > > >
> > > > > >> > > > >> > > > > 1. In old consumer actually the partition
> > > assignment
> > > > > are
> > > > > >> > done
> > > > > >> > > by
> > > > > >> > > > >> > > > consumers
> > > > > >> > > > >> > > > > themselves. We used zookeeper to guarantee
> that a
> > > > > >> partition
> > > > > >> > > will
> > > > > >> > > > >> only
> > > > > >> > > > >> > > be
> > > > > >> > > > >> > > > > consumed by one consumer thread who
> successfully
> > > > > claimed
> > > > > >> its
> > > > > >> > > > >> > ownership.
> > > > > >> > > > >> > > > > Does the new protocol plan to provide the same
> > > > > guarantee?
> > > > > >> > > > >> > > > >
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > Once you have all the metadata from all the
> > > consumers,
> > > > > >> > > assignment
> > > > > >> > > > >> > should
> > > > > >> > > > >> > > > just be a simple function mapping that
> > > Map<ConsumerId,
> > > > > >> > Metadata>
> > > > > >> > > > to
> > > > > >> > > > >> > > > Map<ConsumerId, List<TopicPartition>>. If
> everyone
> > is
> > > > > >> > consistent
> > > > > >> > > > in
> > > > > >> > > > >> > > > computing that, you don't need ZK involved at
> all.
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > In practice, this shouldn't be that hard to
> ensure
> > > for
> > > > > most
> > > > > >> > > > >> assignment
> > > > > >> > > > >> > > > strategies just by having decent unit testing on
> > > them.
> > > > > You
> > > > > >> > just
> > > > > >> > > > >> have to
> > > > > >> > > > >> > > do
> > > > > >> > > > >> > > > things like ensure your assignment strategy sorts
> > > lists
> > > > > >> into a
> > > > > >> > > > >> > consistent
> > > > > >> > > > >> > > > order.
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > You do give up the ability to use some techniques
> > > (e.g.
> > > > > any
> > > > > >> > > > >> randomized
> > > > > >> > > > >> > > > algorithm if you can't distribute the seed w/ the
> > > > > metadata)
> > > > > >> > and
> > > > > >> > > > it's
> > > > > >> > > > >> > true
> > > > > >> > > > >> > > > that nothing validates the assignment, but if
> that
> > > > > >> assignment
> > > > > >> > > > >> algorithm
> > > > > >> > > > >> > > > step is kept simple, small, and well tested, the
> > risk
> > > > is
> > > > > >> very
> > > > > >> > > > >> minimal.
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > >
> > > > > >> > > > >> > > > > 2. It looks that both JoinGroupRequest and
> > > > > >> JoinGroupResponse
> > > > > >> > > has
> > > > > >> > > > >> the
> > > > > >> > > > >> > > > > ProtocolMetadata.AssignmentStrategyMetadata,
> what
> > > > would
> > > > > >> be
> > > > > >> > the
> > > > > >> > > > >> > metadata
> > > > > >> > > > >> > > > be
> > > > > >> > > > >> > > > > sent and returned by coordinator? How will the
> > > > > >> coordinator
> > > > > >> > > > handle
> > > > > >> > > > >> the
> > > > > >> > > > >> > > > > metadata?
> > > > > >> > > > >> > > > >
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > The coordinator is basically just blindly
> > > broadcasting
> > > > > all
> > > > > >> of
> > > > > >> > it
> > > > > >> > > > to
> > > > > >> > > > >> > group
> > > > > >> > > > >> > > > members so they have a consistent view.
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > So from the coordinators perspective, it sees
> > > something
> > > > > >> like:
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > Consumer 1 -> JoinGroupRequest with
> GroupProtocols
> > =
> > > [
> > > > > >> > > "consumer"
> > > > > >> > > > >> > > > <Consumer1 opaque byte[]>]
> > > > > >> > > > >> > > > Consumer 2 -> JoinGroupRequest with
> GroupProtocols
> > =
> > > [
> > > > > >> > > "consumer"
> > > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > Then, in the responses would look like:
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > Consumer 1 <- JoinGroupResponse with
> GroupProtocol
> > =
> > > > > >> > "consumer"
> > > > > >> > > > and
> > > > > >> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque
> > > byte[]>,
> > > > > >> > Consumer
> > > > > >> > > 2
> > > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > > >> > > > >> > > > Consumer 2 <- JoinGroupResponse with
> GroupProtocol
> > =
> > > > > >> > "consumer"
> > > > > >> > > > and
> > > > > >> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque
> > > byte[]>,
> > > > > >> > Consumer
> > > > > >> > > 2
> > > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > So all the responses include all the metadata for
> > > every
> > > > > >> member
> > > > > >> > > in
> > > > > >> > > > >> the
> > > > > >> > > > >> > > > group, and everyone can use that to consistently
> > > decide
> > > > > on
> > > > > >> > > > >> assignment.
> > > > > >> > > > >> > > The
> > > > > >> > > > >> > > > broker doesn't care and cannot even understand
> the
> > > > > metadata
> > > > > >> > > since
> > > > > >> > > > >> the
> > > > > >> > > > >> > > data
> > > > > >> > > > >> > > > format for it is dependent on the assignment
> > strategy
> > > > > being
> > > > > >> > > used.
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > As another example that is *not* a consumer,
> let's
> > > say
> > > > > you
> > > > > >> > just
> > > > > >> > > > >> want to
> > > > > >> > > > >> > > > have a single writer in the group which everyone
> > will
> > > > > >> forward
> > > > > >> > > > >> requests
> > > > > >> > > > >> > > to.
> > > > > >> > > > >> > > > To accomplish this, you could use a very dumb
> > > > assignment
> > > > > >> > > strategy:
> > > > > >> > > > >> > there
> > > > > >> > > > >> > > is
> > > > > >> > > > >> > > > no metadata (empty byte[]) and all we care about
> is
> > > who
> > > > > is
> > > > > >> the
> > > > > >> > > > first
> > > > > >> > > > >> > > member
> > > > > >> > > > >> > > > in the group (e.g. when IDs are sorted
> > > > > lexicographically).
> > > > > >> > That
> > > > > >> > > > >> member
> > > > > >> > > > >> > is
> > > > > >> > > > >> > > > selected as the writer. In that case, we actually
> > > just
> > > > > care
> > > > > >> > > about
> > > > > >> > > > >> the
> > > > > >> > > > >> > > > membership list, there's no additional info about
> > > each
> > > > > >> member
> > > > > >> > > that
> > > > > >> > > > >> is
> > > > > >> > > > >> > > > required to determine who is the writer.
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > > 3. Do you mean that the number of partitions in
> > > > > >> > > > JoinGroupResponse
> > > > > >> > > > >> > will
> > > > > >> > > > >> > > be
> > > > > >> > > > >> > > > > the max partition number of a topic among all
> the
> > > > > >> reported
> > > > > >> > > > >> partition
> > > > > >> > > > >> > > > number
> > > > > >> > > > >> > > > > by consumers? Is there any reason not just let
> > > > > >> Coordinator
> > > > > >> > to
> > > > > >> > > > >> return
> > > > > >> > > > >> > > the
> > > > > >> > > > >> > > > > number of partitions of a topic in its metadata
> > > > cache?
> > > > > >> > > > >> > > > >
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > Nothing from the embedded protocol is touched by
> > the
> > > > > >> broker.
> > > > > >> > The
> > > > > >> > > > >> broker
> > > > > >> > > > >> > > > just collects opaque bytes of metadata, does the
> > > > > selection
> > > > > >> of
> > > > > >> > > the
> > > > > >> > > > >> > > strategy
> > > > > >> > > > >> > > > if multiple are supported by some consumers, and
> > then
> > > > > >> returns
> > > > > >> > > that
> > > > > >> > > > >> > opaque
> > > > > >> > > > >> > > > metadata for all the members back to every
> member.
> > In
> > > > > that
> > > > > >> way
> > > > > >> > > > they
> > > > > >> > > > >> all
> > > > > >> > > > >> > > > have a consistent view of the group. For regular
> > > > > consumers,
> > > > > >> > that
> > > > > >> > > > >> view
> > > > > >> > > > >> > of
> > > > > >> > > > >> > > > the group includes information about how many
> > > > partitions
> > > > > >> each
> > > > > >> > > > >> consumer
> > > > > >> > > > >> > > > currently thinks the topics it is subscribed to
> > has.
> > > > > These
> > > > > >> > could
> > > > > >> > > > be
> > > > > >> > > > >> > > > inconsistent due to out of date metadata and it
> > would
> > > > be
> > > > > >> up to
> > > > > >> > > the
> > > > > >> > > > >> > > > assignment strategy on the *client* to resolve
> > that.
> > > As
> > > > > you
> > > > > >> > > point
> > > > > >> > > > >> out,
> > > > > >> > > > >> > in
> > > > > >> > > > >> > > > that case they could just take the max value that
> > any
> > > > > >> consumer
> > > > > >> > > > >> reported
> > > > > >> > > > >> > > > seeing and use that. The consumers that notice
> that
> > > > their
> > > > > >> > > metadata
> > > > > >> > > > >> had
> > > > > >> > > > >> > a
> > > > > >> > > > >> > > > smaller # of partitions should also trigger a
> > > metadata
> > > > > >> update
> > > > > >> > > when
> > > > > >> > > > >> they
> > > > > >> > > > >> > > see
> > > > > >> > > > >> > > > someone else observing a larger # of partitions.
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > >
> > > > > >> > > > >> > > > > Thanks,
> > > > > >> > > > >> > > > >
> > > > > >> > > > >> > > > > Jiangjie (Becket) Qin
> > > > > >> > > > >> > > > >
> > > > > >> > > > >> > > > >
> > > > > >> > > > >> > > > >
> > > > > >> > > > >> > > > >
> > > > > >> > > > >> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason
> Gustafson
> > <
> > > > > >> > > > >> jason@confluent.io
> > > > > >> > > > >> > >
> > > > > >> > > > >> > > > > wrote:
> > > > > >> > > > >> > > > >
> > > > > >> > > > >> > > > > > Hi Kafka Devs,
> > > > > >> > > > >> > > > > >
> > > > > >> > > > >> > > > > > One of the nagging issues in the current
> design
> > > of
> > > > > the
> > > > > >> new
> > > > > >> > > > >> consumer
> > > > > >> > > > >> > > has
> > > > > >> > > > >> > > > > > been the need to support a variety of
> > assignment
> > > > > >> > strategies.
> > > > > >> > > > >> We've
> > > > > >> > > > >> > > > > > encountered this in particular in the design
> of
> > > > > copycat
> > > > > >> > and
> > > > > >> > > > the
> > > > > >> > > > >> > > > > processing
> > > > > >> > > > >> > > > > > framework (KIP-28). From what I understand,
> > Samza
> > > > > also
> > > > > >> > has a
> > > > > >> > > > >> number
> > > > > >> > > > >> > > of
> > > > > >> > > > >> > > > > use
> > > > > >> > > > >> > > > > > cases with custom assignment needs. The new
> > > > consumer
> > > > > >> > > protocol
> > > > > >> > > > >> > > supports
> > > > > >> > > > >> > > > > new
> > > > > >> > > > >> > > > > > assignment strategies by hooking them into
> the
> > > > > broker.
> > > > > >> For
> > > > > >> > > > many
> > > > > >> > > > >> > > > > > environments, this is a major pain and in
> some
> > > > > cases, a
> > > > > >> > > > >> > non-starter.
> > > > > >> > > > >> > > It
> > > > > >> > > > >> > > > > > also challenges the validation that the
> > > coordinator
> > > > > can
> > > > > >> > > > provide.
> > > > > >> > > > >> > For
> > > > > >> > > > >> > > > > > example, some assignment strategies call for
> > > > > >> partitions to
> > > > > >> > > be
> > > > > >> > > > >> > > assigned
> > > > > >> > > > >> > > > > > multiple times, which means that the
> > coordinator
> > > > can
> > > > > >> only
> > > > > >> > > > check
> > > > > >> > > > >> > that
> > > > > >> > > > >> > > > > > partitions have been assigned at least once.
> > > > > >> > > > >> > > > > >
> > > > > >> > > > >> > > > > > To solve these issues, we'd like to propose
> > > moving
> > > > > >> > > assignment
> > > > > >> > > > to
> > > > > >> > > > >> > the
> > > > > >> > > > >> > > > > > client. I've written a wiki which outlines
> some
> > > > > >> protocol
> > > > > >> > > > >> changes to
> > > > > >> > > > >> > > > > achieve
> > > > > >> > > > >> > > > > > this:
> > > > > >> > > > >> > > > > >
> > > > > >> > > > >> > > > > >
> > > > > >> > > > >> > > > >
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > >
> > > > > >> > > > >> >
> > > > > >> > > > >>
> > > > > >> > > >
> > > > > >> > >
> > > > > >> >
> > > > > >>
> > > > >
> > > >
> > >
> >
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> > > > > >> > > > >> > > > > > .
> > > > > >> > > > >> > > > > > To summarize briefly, instead of the
> > coordinator
> > > > > >> assigning
> > > > > >> > > the
> > > > > >> > > > >> > > > partitions
> > > > > >> > > > >> > > > > > itself, all subscriptions are forwarded to
> each
> > > > > member
> > > > > >> of
> > > > > >> > > the
> > > > > >> > > > >> group
> > > > > >> > > > >> > > > which
> > > > > >> > > > >> > > > > > then decides independently which partitions
> it
> > > > should
> > > > > >> > > consume.
> > > > > >> > > > >> The
> > > > > >> > > > >> > > > > protocol
> > > > > >> > > > >> > > > > > provides a mechanism for the coordinator to
> > > > validate
> > > > > >> that
> > > > > >> > > all
> > > > > >> > > > >> > > consumers
> > > > > >> > > > >> > > > > use
> > > > > >> > > > >> > > > > > the same assignment strategy, but it does not
> > > > ensure
> > > > > >> that
> > > > > >> > > the
> > > > > >> > > > >> > > resulting
> > > > > >> > > > >> > > > > > assignment is "correct." This provides a
> > powerful
> > > > > >> > capability
> > > > > >> > > > for
> > > > > >> > > > >> > > users
> > > > > >> > > > >> > > > to
> > > > > >> > > > >> > > > > > control the full data flow on the client
> side.
> > > They
> > > > > >> > control
> > > > > >> > > > how
> > > > > >> > > > >> > data
> > > > > >> > > > >> > > is
> > > > > >> > > > >> > > > > > written to partitions through the Partitioner
> > > > > interface
> > > > > >> > and
> > > > > >> > > > they
> > > > > >> > > > >> > > > control
> > > > > >> > > > >> > > > > > how data is consumed through the assignment
> > > > strategy,
> > > > > >> all
> > > > > >> > > > >> without
> > > > > >> > > > >> > > > > touching
> > > > > >> > > > >> > > > > > the server.
> > > > > >> > > > >> > > > > >
> > > > > >> > > > >> > > > > > Of course nothing comes for free. In
> > particular,
> > > > this
> > > > > >> > change
> > > > > >> > > > >> > removes
> > > > > >> > > > >> > > > the
> > > > > >> > > > >> > > > > > ability of the coordinator to validate that
> > > commits
> > > > > are
> > > > > >> > made
> > > > > >> > > > by
> > > > > >> > > > >> > > > consumers
> > > > > >> > > > >> > > > > > who were assigned the respective partition.
> > This
> > > > > might
> > > > > >> not
> > > > > >> > > be
> > > > > >> > > > >> too
> > > > > >> > > > >> > bad
> > > > > >> > > > >> > > > > since
> > > > > >> > > > >> > > > > > we retain the ability to validate the
> > generation
> > > > id,
> > > > > >> but
> > > > > >> > it
> > > > > >> > > > is a
> > > > > >> > > > >> > > > > potential
> > > > > >> > > > >> > > > > > concern. We have considered alternative
> > protocols
> > > > > which
> > > > > >> > add
> > > > > >> > > a
> > > > > >> > > > >> > second
> > > > > >> > > > >> > > > > > round-trip to the protocol in order to give
> the
> > > > > >> > coordinator
> > > > > >> > > > the
> > > > > >> > > > >> > > ability
> > > > > >> > > > >> > > > > to
> > > > > >> > > > >> > > > > > confirm the assignment. As mentioned above,
> the
> > > > > >> > coordinator
> > > > > >> > > is
> > > > > >> > > > >> > > somewhat
> > > > > >> > > > >> > > > > > limited in what it can actually validate, but
> > > this
> > > > > >> would
> > > > > >> > > > return
> > > > > >> > > > >> its
> > > > > >> > > > >> > > > > ability
> > > > > >> > > > >> > > > > > to validate commits. The tradeoff is that it
> > > > > increases
> > > > > >> the
> > > > > >> > > > >> > protocol's
> > > > > >> > > > >> > > > > > complexity which means more ways for the
> > protocol
> > > > to
> > > > > >> fail
> > > > > >> > > and
> > > > > >> > > > >> > > > > consequently
> > > > > >> > > > >> > > > > > more edge cases in the code.
> > > > > >> > > > >> > > > > >
> > > > > >> > > > >> > > > > > It also misses an opportunity to generalize
> the
> > > > group
> > > > > >> > > > membership
> > > > > >> > > > >> > > > protocol
> > > > > >> > > > >> > > > > > for additional use cases. In fact, after
> you've
> > > > gone
> > > > > to
> > > > > >> > the
> > > > > >> > > > >> trouble
> > > > > >> > > > >> > > of
> > > > > >> > > > >> > > > > > moving assignment to the client, the main
> thing
> > > > that
> > > > > is
> > > > > >> > left
> > > > > >> > > > in
> > > > > >> > > > >> > this
> > > > > >> > > > >> > > > > > protocol is basically a general group
> > management
> > > > > >> > capability.
> > > > > >> > > > >> This
> > > > > >> > > > >> > is
> > > > > >> > > > >> > > > > > exactly what is needed for a few cases that
> are
> > > > > >> currently
> > > > > >> > > > under
> > > > > >> > > > >> > > > > discussion
> > > > > >> > > > >> > > > > > (e.g. copycat or single-writer producer).
> We've
> > > > taken
> > > > > >> this
> > > > > >> > > > >> further
> > > > > >> > > > >> > > step
> > > > > >> > > > >> > > > > in
> > > > > >> > > > >> > > > > > the proposal and attempted to envision what
> > that
> > > > > >> general
> > > > > >> > > > >> protocol
> > > > > >> > > > >> > > might
> > > > > >> > > > >> > > > > > look like and how it could be used both by
> the
> > > > > consumer
> > > > > >> > and
> > > > > >> > > > for
> > > > > >> > > > >> > some
> > > > > >> > > > >> > > of
> > > > > >> > > > >> > > > > > these other cases.
> > > > > >> > > > >> > > > > >
> > > > > >> > > > >> > > > > > Anyway, since time is running out on the new
> > > > > consumer,
> > > > > >> we
> > > > > >> > > have
> > > > > >> > > > >> > > perhaps
> > > > > >> > > > >> > > > > one
> > > > > >> > > > >> > > > > > last chance to consider a significant change
> in
> > > the
> > > > > >> > protocol
> > > > > >> > > > >> like
> > > > > >> > > > >> > > this,
> > > > > >> > > > >> > > > > so
> > > > > >> > > > >> > > > > > have a look at the wiki and share your
> > thoughts.
> > > > I've
> > > > > >> no
> > > > > >> > > doubt
> > > > > >> > > > >> that
> > > > > >> > > > >> > > > some
> > > > > >> > > > >> > > > > > ideas seem clearer in my mind than they do on
> > > > paper,
> > > > > so
> > > > > >> > ask
> > > > > >> > > > >> > questions
> > > > > >> > > > >> > > > if
> > > > > >> > > > >> > > > > > there is any confusion.
> > > > > >> > > > >> > > > > >
> > > > > >> > > > >> > > > > > Thanks!
> > > > > >> > > > >> > > > > > Jason
> > > > > >> > > > >> > > > > >
> > > > > >> > > > >> > > > >
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > --
> > > > > >> > > > >> > > > Thanks,
> > > > > >> > > > >> > > > Ewen
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > >
> > > > > >> > > > >> >
> > > > > >> > > > >> >
> > > > > >> > > > >> >
> > > > > >> > > > >> > --
> > > > > >> > > > >> > Thanks,
> > > > > >> > > > >> > Ewen
> > > > > >> > > > >> >
> > > > > >> > > > >>
> > > > > >> > > > >
> > > > > >> > > > >
> > > > > >> > > >
> > > > > >> > >
> > > > > >> >
> > > > > >>
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Thanks,
> > > > > > Neha
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Thanks,
> > > > > Neha
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Thanks,
> > > > Ewen
> > > >
> > >
> >
> >
> >
> > --
> > Thanks,
> > Ewen
> >
>

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Jiangjie Qin <jq...@linkedin.com.INVALID>.
Ewen,

I agree that if there is a churn in metadata, the consumers need several
rounds of rebalances to succeed. The difference I am thinking is that with
coordinator as single source of truth, we can let the consumer finish one
round of rebalance, work for a while and start the next round of rebalance.
If we purely depend on the consumers to synchronize by themselves based on
different metadata sources, is it possible we have some groups spending a
lot of time on rebalancing but not able to make too much progress in
consuming?

I'm thinking can we let consumers to fetch metadata only from their
coordinator? So the rebalance can be done in the following way:

1. Consumers refresh their metadata periodically
2. If one of the consumer sees a change in metadata that triggers a
rebalance, it sends JoinGroupRequest to coordinator.
3. Once the coordinator receives the first JoinGroupRequest of a group, it
takes a snapshot of current metadata and the group enters prepare-rebalance
state.
4. The metadata snapshot will be used for this round of rebalance. i.e. the
metadata snapshot will be sent to consumers in JoinGroupResponse.
4.1 If the consumers are subscribing to explicit topic lists (not regex),
the JoinGroupResponse needs only contain the metadata of all topics the
group is interested.
4.2 If the consumers are subscribing using regex, all the topic metadata
will be returned to the consumer.
5. Consumers get JoinGroupResponse, refresh metadata using the metadata in
JoinGroupResponse, run algorithm to assign partitions and start consume.
6. Go back to 1.

The benefit here is that we can let rebalance finish in one round, and all
the rest of changes will be captured in next consumer metadata refresh - so
we get group commit. One concern might be letting consumer refresh metadata
from coordinator might cause issue for big consumer groups. Maybe that is
OK because metadata refresh is infrequent.

This approach actually is very similar to what is proposed now: rebalance
is triggered by metadata refresh, consumer provides subscription list to
pass around. The only difference is that we don't need metadata hash
anymore because the metadata is guaranteed to be the same. Replacing
metadata hash with actual metadata will not have too much overhead for
small subscription groups. There will be some overhead for regex
subscriptions, but this can save the potential extra round of metadata
fetch and will only occur when consumer see metadata change, which is
infrequent.

Any thoughts?

Thanks,

Jiangjie (Becket) Qin


On Fri, Aug 14, 2015 at 12:57 PM, Ewen Cheslack-Postava <ew...@confluent.io>
wrote:

> On Fri, Aug 14, 2015 at 10:59 AM, Jiangjie Qin <jq...@linkedin.com.invalid>
> wrote:
>
> > Neha and Ewen,
> >
> > About the metadata change frequency. I guess it really depends on how
> > frequent the metadata change might occur. If we run Kafka as a service, I
> > can see that happens from time to time. As I can imagine people will
> create
> > some topic, test and maybe delete the topic in some automated test. If
> so,
> > the proposed protocol might be a little bit vulnerable.
> >
> > More specifically the scenario I am thinking is:
> > 1. Consumer 0 periodically refresh metadata and detected a metadata
> change.
> > So it sends a JoinGroupRequest with metadata_hash_0.
> > 2. Consumer 1 was notified by controller to start a rebalance, so it
> > refreshes its metadata and send a JoingGroupRequest with metadata_hash_1,
> > which is different from metadata hash 0.
> > 3. Rebalance failed and both consumer refresh there metadata again from
> > different brokers.
> > 4. Depending on the metadata change frequency(or some admin operation
> like
> > partition reassigment), they may or may not have the same metadata
> > returned, so the restart from 3 again.
> >
> > I agree that step 4 might not be a big concern if consumers updates
> > metadata at almost the same time, but I'm a little bit worried whether
> that
> > assumption really stands because we do not have control over how frequent
> > the metadata can change.
> >
> >
> Is this really that different from what would happen if the coordinator
> distributed the metadata to consumers? In that case you would trivially
> have everyone in a consistent state, but those metadata changes would still
> cause churn and require JoinGroup rounds, during which processing is
> stalled for the nodes that are waiting on other members to re-join the
> group.
>
> -Ewen
>
>
> > Thanks,
> >
> > Jiangjie (Becket) Qin
> >
> > On Fri, Aug 14, 2015 at 2:03 AM, Ewen Cheslack-Postava <
> ewen@confluent.io>
> > wrote:
> >
> > > On Thu, Aug 13, 2015 at 11:07 PM, Neha Narkhede <ne...@confluent.io>
> > wrote:
> > >
> > > > Becket,
> > > >
> > > > As you say, the metadata hash addresses the concern you originally
> > raised
> > > > about large topic subscriptions. Can you please list other problems
> you
> > > are
> > > > raising more clearly? It is more helpful to know problems that the
> > > proposal
> > > > does not address or addresses poorly.
> > > >
> > > > Regarding other things you said -
> > > >
> > > > it is required that each
> > > > > consumer refresh their metadata before sending a JoinGroupRequest
> > > > >
> > > >
> > > > This is required for wildcard topic subscriptions anyway. So this
> > > proposal
> > > > does not introduce a regression. We had agreed earlier that it does
> not
> > > > make sense for the server to deserialize regular expressions sent by
> > the
> > > > consumer.
> > > >
> > >
> > > I don't think consumers need to do a metadata refresh before sending a
> > > JoinGroupRequest. Metadata changes that affect assignment are rare --
> it
> > > requires changing the number of partitions in a topic. But you might
> > send a
> > > JoinGroupRequest simply because a new member is trying to join the
> group.
> > > That case is presumably much more common.
> > >
> > > I think it's actually a good idea to have the first JoinGroup cycle
> fail
> > in
> > > some cases, and has little impact. Lets say the metadata does change
> > > because partitions are added. Then we might fail in the first round,
> but
> > > then all members detect that issue *immediately*, refresh their
> metadata,
> > > and submit a new join group request. This second cycle does not
> require a
> > > full heartbeat cycle. It happens much more quickly because everyone
> > > detected the inconsistency based on the first JoinGroupResponse. The
> > > inconsistency should be resolved very quickly (barring other failures
> > like
> > > a member leaving mid-rebalance)
> >
> >
> >
> >
> > > >
> > > >
> > > > > the metadata might still be inconsistent if there is a topic or
> > > partition
> > > > > change because the
> > > > > UpdateMetadataRequest from controller might be handled at different
> > > time.
> > > > >
> > > >
> > > > Topic metadata does not change frequently and even if it did, a
> couple
> > > > rebalance attempts will be needed whether the coordinator drives the
> > > > assignments or the consumer. Because guess how the coordinator knows
> > > about
> > > > the topic metadata changes -- indirectly through either a zk callback
> > or
> > > > UpdateMetadataRequest, so it is completely possible the coordinator
> > sees
> > > > the topic metadata changes in batches, not all at once.
> > > >
> > >
> > > > On Thu, Aug 13, 2015 at 10:50 PM, Neha Narkhede <ne...@confluent.io>
> > > wrote:
> > > >
> > > > > Ewen/Jason,
> > > > >
> > > > > The metadata hash is a clever approach and certainly addresses the
> > > > problem
> > > > > of large metadata for consumers like mirror maker. Few comments -
> > > > >
> > > > >
> > > > >    1. In the interest of simplifying the format of the consumer's
> > > > >    metadata - Why not just always include only the topic names in
> the
> > > > metadata
> > > > >    followed by the metadata hash? If the metadata hash check
> > succeeds,
> > > > each
> > > > >    consumer uses the # of partitions it had fetched. If it fails, a
> > > > rebalance
> > > > >    happens and the metadata is not used anyway.
> > > >
> > >
> > > Doing this requires that every consumer always fetch the full metadata.
> > The
> > > most common use case is consumers that just want to consume one or a
> > couple
> > > of topics, in which case grabbing all metadata for the entire cluster
> is
> > > wasteful. If I subscribe only to topic A, why make all consumers grab
> > > metadata for the entire topic (and need to rebalance every time it
> > > changes!). Including the # of partitions for each topic lets you avoid
> > > having to grab the global set of metadata.
> > >
> > > So if you're just subscribing to one or a couple of topics, why not
> just
> > > compute the hash by filtering out everything but the topics you are
> > > subscribed to? The problem there is if you ever add/remove
> subscriptions
> > > and want to support rolling upgrades. If the group was subscribed to
> > topic
> > > A, but later changes require subscribing to A + B, then to achieve a
> > > seamless rolling upgrade would require one (old) consumer to be
> > subscribing
> > > to A and one (new) consumer to be subscribing to A+B. If we computed
> > > metadata hashes based on filtered metadata, those two would disagree
> and
> > we
> > > could not perform assignment while the upgrade was in progress.
> > >
> > > The solution is to differentiate between the cases when a very small
> > amount
> > > of the metadata is needed (one or a couple of topic subscriptions;
> > > communicate and share this via metadata in the JoinGroup protocol) vs
> > when
> > > *all* the metadata is needed (regex subscription; verify agreement via
> > > hash).
> > >
> >
> > >
> > >
> > > > >    2. Do you need a topic list and topic regex to be separate? A
> > single
> > > > >    topic or list of topics can be expressed as a regex.
> > > >
> > >
> > > See above note about collecting all metadata when you really only need
> it
> > > for 1 or 2 topics. There's probably some debate to be had about whether
> > > this cost would be too high -- every consumer would need to request the
> > > metadata for all topics, and they'd need to request that all every time
> > > they might be out of date.
> > >
> > Are we going to allow consumers in the same group to subscribe to
> different
> > topic set? If we do, we need to let them refresh metadata for all the
> > topics a group is consuming from. If we don't then in the protocol we
> only
> > need a subscription set hash.
> >
> > >
> > >
> > > > >    3. Let's include a version explicitly at the beginning of the
> > > > >    ProtocolMetadata. The version dictates how to deserialize the
> > > > >    ProtocolMetadata blob and is consistent with the rest of Kafka.
> > > >
> > >
> > > If I'm understanding correctly, in JoinGroupRequest I would change
> > >
> > > GroupProtocols          => [Protocol ProtocolMetadata]
> > >
> > > to
> > >
> > > GroupProtocols          => [Protocol ProtocolVersion ProtocolMetadata]
> > >
> > > We had been talking about just baking the version into the Protocol
> > field,
> > > but making it separate seems perfectly reasonable to me. Jason, any
> issue
> > > with splitting the version out into a separate field like this?
> > >
> > > >
> > > > > That can simplify the metadata format to the following:
> > > > >
> > > > > GroupType => "consumer"
> > > > >>
> > > > >> Protocol => AssignmentStrategy
> > > > >>   AssignmentStrategy   => String
> > > > >>
> > > > >> ProtocolMetadata => Version Subscription
> AssignmentStrategyMetadata
> > > > >
> > > > >     Version                    => String
> > > > >
> > > > >   Subscription                 => TopicRegex MetadataHash
> > > > >>     TopicRegex                 => String
> > > > >>     MetadataHash               => String
> > > > >>   AssignmentStrategyMetadata   => bytes
> > > >
> > > >
> > > > >
> > > > > On Thu, Aug 13, 2015 at 6:28 PM, Jiangjie Qin
> > > <jqin@linkedin.com.invalid
> > > > >
> > > > > wrote:
> > > > >
> > > > >> Ewen and Jason,
> > > > >>
> > > > >> Thanks for the reply. Sorry I missed the metadata hash. Yes, that
> > is a
> > > > >> clever approach and would solve my concern about the data passing
> > > > around.
> > > > >> I
> > > > >> can see both pros and cons from doing this, though. The advantage
> is
> > > we
> > > > >> don't need the topic metadata in JoinGroupResponse anymore. The
> > > downside
> > > > >> is
> > > > >> that now rebalance have extra dependency on the consensus of
> > metadata
> > > of
> > > > >> all consumers, which is obtained separately. So it is required
> that
> > > each
> > > > >> consumer refresh their metadata before sending a JoinGroupRequest,
> > > > >> otherwise in some cases (e.g. wildcard consumers) will almost
> > > certainly
> > > > >> fail for the first rebalance attempt. Even if we do that, since
> the
> > > > >> consumers are getting metadata from different brokers, the
> metadata
> > > > might
> > > > >> still be inconsistent if there is a topic or partition change
> > because
> > > > the
> > > > >> UpdateMetadataRequest from controller might be handled at
> different
> > > > time.
> > > > >> Just want to make sure we think through the cases so the protocol
> > does
> > > > not
> > > > >> cause us unexpected issues.
> > > > >>
> > > > >> About the number of consumers, I think with the current liveliness
> > > > >> definition, we can tolerate churns by bumping up the session
> > timeout.
> > > > Also
> > > > >> I guess we will see an increasing number of consumers for new
> > > consumer,
> > > > >> because every the old consumer thread will probably become a
> > consumer.
> > > > >>
> > > > >> It is a valid concern for consumers that have large subscription
> > set.
> > > > This
> > > > >> might not be avoided though for client side assignment approach.
> One
> > > > >> solution is having topic names associate with a topic ID. And only
> > use
> > > > >> topic ID in JoinGroupRequest and JoinGroupResponse, There is a
> > > > discussion
> > > > >> thread about this to solve the topic renaming case but this is a
> > > > >> completely
> > > > >> different discussion.
> > > > >>
> > > > >> Thanks,
> > > > >>
> > > > >> Jiangjie (Becket) Qin
> > > > >>
> > > > >>
> > > > >>
> > > > >> On Thu, Aug 13, 2015 at 2:14 PM, Jason Gustafson <
> > jason@confluent.io>
> > > > >> wrote:
> > > > >>
> > > > >> > Thanks Jiangjie, that information helps. I agree the protocol
> must
> > > > >> consider
> > > > >> > scalability. My point was that the synchronization barrier in
> the
> > > > >> current
> > > > >> > protocol already effectively limits the number of consumers
> since
> > it
> > > > >> > provides no way to gracefully handle churn. It wouldn't be worth
> > > > >> worrying
> > > > >> > about scaling up to 100,000 members, for example, because
> there's
> > no
> > > > way
> > > > >> > the group would be stable. So we just need to set some clear
> > > > >> expectations
> > > > >> > on the size we can scale to, and that can help inform the
> > discussion
> > > > on
> > > > >> the
> > > > >> > size of messages in this protocol.
> > > > >> >
> > > > >> > Ewen and I were discussing this morning along similar lines to
> > what
> > > > >> you're
> > > > >> > suggesting. However, even if the coordinator decides on the
> > metadata
> > > > for
> > > > >> > the group, each member still needs to communicate its
> > subscriptions
> > > to
> > > > >> the
> > > > >> > rest of the group. This is nice for the regex case since the
> regex
> > > is
> > > > >> > probably small, but if the members have a large topic list, then
> > we
> > > > have
> > > > >> > the same problem. One thing I was thinking about was whether we
> > > really
> > > > >> need
> > > > >> > to handle different subscriptions for every member. If the
> > > coordinator
> > > > >> > could guarantee that all members had the same subscription, then
> > > there
> > > > >> > would be no need for the coordinator to return the subscriptions
> > for
> > > > >> each
> > > > >> > member. However, this would prevent graceful upgrades. We might
> be
> > > > able
> > > > >> to
> > > > >> > fix that problem by allowing the consumer to provide two
> > > subscriptions
> > > > >> to
> > > > >> > allowing rolling updates, but that starts to sound pretty nasty.
> > > > >> >
> > > > >> > -Jason
> > > > >> >
> > > > >> > On Thu, Aug 13, 2015 at 1:41 PM, Jiangjie Qin
> > > > <jqin@linkedin.com.invalid
> > > > >> >
> > > > >> > wrote:
> > > > >> >
> > > > >> > > Jason,
> > > > >> > >
> > > > >> > > The protocol has to consider the scalability. The protocol in
> > the
> > > > wiki
> > > > >> > > means the JoinGroupResoponse size would be:
> > > > >> > > NumberOfTopics * (AvgTopicNameLength + 4) *
> > (NumberOfConsumers)^2
> > > > >> > >
> > > > >> > > To give some real number, we have 26-node Mirror Maker
> cluster,
> > > each
> > > > >> > with 4
> > > > >> > > consumers. That is 104 consumers using regex ".*". And most of
> > our
> > > > >> > clusters
> > > > >> > > have around 3000 topics, whose topic name are typically around
> > 20
> > > > >> > > characters.
> > > > >> > >
> > > > >> > > I think the key issue for client side partition assignment
> logic
> > > is
> > > > to
> > > > >> > make
> > > > >> > > sure 1) all the clients run the same algorithm. 2) all the
> > clients
> > > > >> make
> > > > >> > > decision on the same topic metadata. The second purpose can be
> > > done
> > > > by
> > > > >> > > simply letting coordinator provide the topic metadata and all
> > then
> > > > >> member
> > > > >> > > information as source of truth. Is it necessary to pass topic
> > > > >> metadata of
> > > > >> > > each consumer around? Can we keep the protocol metadata field
> > > > >> completely
> > > > >> > > independent of topic metadata? I think In the
> JoinGroupResponse,
> > > we
> > > > >> > should
> > > > >> > > have only one copy of topic metadata provided by coordinator
> and
> > > is
> > > > >> > outside
> > > > >> > > of protocol metadata. If user decides to put some metadata in
> > the
> > > > >> > > JoinGroupRequest and let coordinator pass around, they are
> > > > responsible
> > > > >> > for
> > > > >> > > understanding the risk.
> > > > >> > >
> > > > >> > > Thanks,
> > > > >> > >
> > > > >> > > Jiangjie (Becket) Qin
> > > > >> > >
> > > > >> > >
> > > > >> > > On Thu, Aug 13, 2015 at 12:41 PM, Jason Gustafson <
> > > > jason@confluent.io
> > > > >> >
> > > > >> > > wrote:
> > > > >> > >
> > > > >> > > > Hey Onur and Jiangjie,
> > > > >> > > >
> > > > >> > > > I've updated that wiki with a proposal to add regex
> > > subscriptions
> > > > to
> > > > >> > the
> > > > >> > > > consumer metadata. Can you have a look to see if it
> addresses
> > > your
> > > > >> > > concern?
> > > > >> > > > In general, I think we should be a little careful when we
> are
> > > > >> talking
> > > > >> > > about
> > > > >> > > > the scalability of the protocol. Regardless of whether
> > > assignment
> > > > is
> > > > >> > done
> > > > >> > > > on the server or the client, the protocol assumes a
> relatively
> > > > >> stable
> > > > >> > > > configuration. When the number of consumers increases
> beyond a
> > > > >> certain
> > > > >> > > > limit, then membership churn becomes a major concern.
> > Similarly
> > > > >> there
> > > > >> > is
> > > > >> > > a
> > > > >> > > > notion of metadata churn when topics are added, deleted, or
> > > > >> resized. If
> > > > >> > > > either membership or metadata changes, then the protocol
> > forces
> > > > all
> > > > >> > > > consumers to stop consumption and rejoin the group. If this
> > > > happens
> > > > >> > often
> > > > >> > > > enough, then it can severely impact the ability of the
> > consumer
> > > to
> > > > >> make
> > > > >> > > > progress. The point is that the protocol may already be
> > unsuited
> > > > to
> > > > >> > cases
> > > > >> > > > where there are either a large number of consumers or
> topics.
> > I
> > > > >> wonder
> > > > >> > if
> > > > >> > > > you guys can share your thoughts about your scaling
> > > expectations?
> > > > >> > > >
> > > > >> > > > -Jason
> > > > >> > > >
> > > > >> > > >
> > > > >> > > >
> > > > >> > > >
> > > > >> > > > On Wed, Aug 12, 2015 at 12:28 PM, Jason Gustafson <
> > > > >> jason@confluent.io>
> > > > >> > > > wrote:
> > > > >> > > >
> > > > >> > > > > Hey Jiangjie,
> > > > >> > > > >
> > > > >> > > > > That's a great point. In the worst case (the mirror maker
> > > case I
> > > > >> > > guess),
> > > > >> > > > > the join group response can be massive. This would be
> > > especially
> > > > >> > deadly
> > > > >> > > > > when there is a lot of churn in the group (e.g. in a
> rolling
> > > > >> > upgrade).
> > > > >> > > > The
> > > > >> > > > > current protocol is not great for this case either, but
> it's
> > > > >> > > > significantly
> > > > >> > > > > better. Here are a couple ways to deal with the size:
> > > > >> > > > >
> > > > >> > > > > 1. First, we could have the coordinator compress the
> > > responses.
> > > > >> This
> > > > >> > > > would
> > > > >> > > > > probably be pretty effective if applied across the
> metadata
> > > from
> > > > >> all
> > > > >> > > > > members.
> > > > >> > > > >
> > > > >> > > > > 2. I think the regex case is the main problem. Is that
> > right?
> > > We
> > > > >> > could
> > > > >> > > > > extend the metadata to allow the consumer to embed its
> regex
> > > > >> > > subscription
> > > > >> > > > > in the metadata directly (note this might be a good idea
> > > > >> regardless
> > > > >> > of
> > > > >> > > > the
> > > > >> > > > > rest of this proposal). To support regex on the consumer,
> we
> > > > must
> > > > >> > fetch
> > > > >> > > > > metadata for all topics. Rather than having all regex
> > > > subscribers
> > > > >> > embed
> > > > >> > > > all
> > > > >> > > > > of this metadata in their join group requests, they could
> > > > instead
> > > > >> > > embed a
> > > > >> > > > > hash of it. Then after the join group responses are
> > received,
> > > > they
> > > > >> > just
> > > > >> > > > > need to check that the hashes are the same. If there is a
> > > > mismatch
> > > > >> > > (which
> > > > >> > > > > should only occur when topics are created, deleted, or
> > > resized),
> > > > >> then
> > > > >> > > the
> > > > >> > > > > group members must refetch the metadata and rejoin the
> > group.
> > > > >> This is
> > > > >> > > > also
> > > > >> > > > > how the current protocol behaves when there is a change in
> > the
> > > > >> topic
> > > > >> > > > > metadata affecting the group--someone (either the
> > coordinator
> > > or
> > > > >> the
> > > > >> > > > > consumer) detects the change and forces the group to
> > > rebalance.
> > > > >> > > > >
> > > > >> > > > > What do you think?
> > > > >> > > > >
> > > > >> > > > > (Also I think adding groupId/generationId to fetch and
> > produce
> > > > >> > requests
> > > > >> > > > > seems like an interesting line of thought.)
> > > > >> > > > >
> > > > >> > > > > -Jason
> > > > >> > > > >
> > > > >> > > > >
> > > > >> > > > >
> > > > >> > > > > On Wed, Aug 12, 2015 at 10:57 AM, Jiangjie Qin
> > > > >> > > <jqin@linkedin.com.invalid
> > > > >> > > > >
> > > > >> > > > > wrote:
> > > > >> > > > >
> > > > >> > > > >> Hey Ewen,
> > > > >> > > > >>
> > > > >> > > > >> Onur and I discussed this a little bit more. And we are
> > still
> > > > >> > worrying
> > > > >> > > > >> about passing all the metadata of all consumers around.
> > > > >> > > > >>
> > > > >> > > > >> Let's say I have a cluster has 10,000 topics, the average
> > > topic
> > > > >> name
> > > > >> > > > >> length
> > > > >> > > > >> is 10 bytes. In this case, the opaque metadata will have
> > 10 *
> > > > >> > 10,000 =
> > > > >> > > > >> 100KB for topic name, for each topic, there is a 4-byte
> > > integer
> > > > >> of
> > > > >> > > > number
> > > > >> > > > >> of partitions, that's another 40KB. So one global topic
> > > > metadata
> > > > >> > will
> > > > >> > > > have
> > > > >> > > > >> 140KB data. If I have 100 consumers who are using
> wildcard
> > to
> > > > >> > consume
> > > > >> > > > from
> > > > >> > > > >> all the topics. That means the protocol metadata end up
> in
> > > the
> > > > >> > > > >> JoinGroupResponse will be 140KB * 100 = 14MB. And the
> > > > >> > > JoinGroupResponse
> > > > >> > > > >> will need to be sent to 100 different consumers, that
> means
> > > > 14MB
> > > > >> *
> > > > >> > > 100 =
> > > > >> > > > >> 1.4GB need to be sent by the consumer coordinator for one
> > > > >> rebalance.
> > > > >> > > How
> > > > >> > > > >> would that work?
> > > > >> > > > >>
> > > > >> > > > >> Also, having two consumers (old owner and new owner)
> > > consuming
> > > > >> from
> > > > >> > > the
> > > > >> > > > >> same partition might also be a problem. e.g. people are
> > > > updating
> > > > >> > > > database.
> > > > >> > > > >> One thing might worth doing is to add GroupId and
> > Generation
> > > ID
> > > > >> to
> > > > >> > > > >> ProducerRequest and FetchRequest as well. This will also
> > help
> > > > >> with
> > > > >> > the
> > > > >> > > > >> single producer use case. However, this is probably
> > > orthogonal
> > > > to
> > > > >> > this
> > > > >> > > > >> thread given the current new consumer also has this
> problem
> > > > and I
> > > > >> > > > believe
> > > > >> > > > >> we need to fix it.
> > > > >> > > > >>
> > > > >> > > > >> Thanks,
> > > > >> > > > >>
> > > > >> > > > >> Jiangjie (Becket) Qin
> > > > >> > > > >>
> > > > >> > > > >> On Tue, Aug 11, 2015 at 11:43 PM, Ewen Cheslack-Postava <
> > > > >> > > > >> ewen@confluent.io>
> > > > >> > > > >> wrote:
> > > > >> > > > >>
> > > > >> > > > >> > On Tue, Aug 11, 2015 at 11:29 PM, Jiangjie Qin
> > > > >> > > > >> <jq...@linkedin.com.invalid>
> > > > >> > > > >> > wrote:
> > > > >> > > > >> >
> > > > >> > > > >> > > Ewen,
> > > > >> > > > >> > >
> > > > >> > > > >> > > Thanks for the explanation.
> > > > >> > > > >> > >
> > > > >> > > > >> > > For (1), I am more concerned about the failure case
> > > instead
> > > > >> of
> > > > >> > > > normal
> > > > >> > > > >> > case.
> > > > >> > > > >> > > What if a consumer somehow was kick out of a group
> but
> > is
> > > > >> still
> > > > >> > > > >> consuming
> > > > >> > > > >> > > and committing offsets? Does that mean the new owner
> > and
> > > > old
> > > > >> > owner
> > > > >> > > > >> might
> > > > >> > > > >> > > potentially consuming from and committing offsets for
> > the
> > > > >> same
> > > > >> > > > >> partition?
> > > > >> > > > >> > > In the old consumer, this won't happen because the
> new
> > > > >> consumer
> > > > >> > > will
> > > > >> > > > >> not
> > > > >> > > > >> > be
> > > > >> > > > >> > > able to start consumption unless the previous owner
> has
> > > > >> released
> > > > >> > > its
> > > > >> > > > >> > > ownership. Basically, without the ownership
> guarantee,
> > I
> > > > >> don't
> > > > >> > see
> > > > >> > > > how
> > > > >> > > > >> > the
> > > > >> > > > >> > > communication among consumers themselves alone can
> > solve
> > > > the
> > > > >> > > problem
> > > > >> > > > >> > here.
> > > > >> > > > >> > >
> > > > >> > > > >> >
> > > > >> > > > >> > The generation ID check still applies to offset
> commits.
> > If
> > > > >> one of
> > > > >> > > the
> > > > >> > > > >> > consumers is kicked out and misbehaving, it can
> obviously
> > > > still
> > > > >> > > fetch
> > > > >> > > > >> and
> > > > >> > > > >> > process messages, but offset commits will not work
> since
> > it
> > > > >> will
> > > > >> > not
> > > > >> > > > >> have
> > > > >> > > > >> > the current generation ID.
> > > > >> > > > >> >
> > > > >> > > > >> >
> > > > >> > > > >> > >
> > > > >> > > > >> > > For (2) and (3), now I understand how metadata are
> > used.
> > > > But
> > > > >> I
> > > > >> > > still
> > > > >> > > > >> > don't
> > > > >> > > > >> > > see why should we let the consumers to pass the topic
> > > > >> > information
> > > > >> > > > >> across
> > > > >> > > > >> > > instead of letting coordinator give the information.
> > The
> > > > >> single
> > > > >> > > > >> producer
> > > > >> > > > >> > > use case does not solve the ownership problem in
> > abnormal
> > > > >> case
> > > > >> > > > either,
> > > > >> > > > >> > > which seems to be a little bit vulnerable.
> > > > >> > > > >> > >
> > > > >> > > > >> >
> > > > >> > > > >> > One of the goals here was to generalize group
> membership
> > so
> > > > we
> > > > >> > can,
> > > > >> > > > for
> > > > >> > > > >> > example, use it for balancing Copycat tasks across
> > workers.
> > > > >> > There's
> > > > >> > > no
> > > > >> > > > >> > topic subscription info in that case. The metadata for
> > > > copycat
> > > > >> > > workers
> > > > >> > > > >> > would instead need to somehow indicate the current set
> of
> > > > tasks
> > > > >> > that
> > > > >> > > > >> need
> > > > >> > > > >> > to be assigned to workers. By making the metadata
> > > completely
> > > > >> > opaque
> > > > >> > > to
> > > > >> > > > >> the
> > > > >> > > > >> > protocol, it becomes more generally useful since it
> > focuses
> > > > >> > squarely
> > > > >> > > > on
> > > > >> > > > >> the
> > > > >> > > > >> > group membership problem, allowing for that additional
> > bit
> > > of
> > > > >> > > metadata
> > > > >> > > > >> so
> > > > >> > > > >> > you don't just get a list of members, but also get a
> > little
> > > > >> bit of
> > > > >> > > > info
> > > > >> > > > >> > about each of them.
> > > > >> > > > >> >
> > > > >> > > > >> > A different option that we explored is to use a sort of
> > > mixed
> > > > >> > model
> > > > >> > > --
> > > > >> > > > >> > still bake all the topic subscriptions directly into
> the
> > > > >> protocol
> > > > >> > > but
> > > > >> > > > >> also
> > > > >> > > > >> > include metadata. That would allow us to maintain the
> > > > existing
> > > > >> > > > >> > coordinator-driven approach to handling the metadata
> and
> > > > change
> > > > >> > > events
> > > > >> > > > >> like
> > > > >> > > > >> > the ones Onur pointed out. Then something like the
> > Copycat
> > > > >> workers
> > > > >> > > > would
> > > > >> > > > >> > just not fill in any topic subscriptions and it would
> be
> > > > >> handled
> > > > >> > as
> > > > >> > > a
> > > > >> > > > >> > degenerate case. Based on the way I explained that we
> can
> > > > >> handle
> > > > >> > > those
> > > > >> > > > >> > types of events, I personally feel its cleaner and a
> > nicer
> > > > >> > > > >> generalization
> > > > >> > > > >> > to not include the subscriptions in the join group
> > > protocol,
> > > > >> > making
> > > > >> > > it
> > > > >> > > > >> part
> > > > >> > > > >> > of the metadata instead.
> > > > >> > > > >> >
> > > > >> > > > >> > For the single producer case, are you saying it doesn't
> > > solve
> > > > >> > > > ownership
> > > > >> > > > >> in
> > > > >> > > > >> > the abnormal case because a producer that doesn't know
> it
> > > has
> > > > >> been
> > > > >> > > > >> kicked
> > > > >> > > > >> > out of the group yet can still produce data even though
> > it
> > > > >> > shouldn't
> > > > >> > > > be
> > > > >> > > > >> > able to anymore? I definitely agree that that is a risk
> > --
> > > > this
> > > > >> > > > >> provides a
> > > > >> > > > >> > way to get closer to a true single-writer, but there
> are
> > > > >> > definitely
> > > > >> > > > >> still
> > > > >> > > > >> > failure modes that this does not address.
> > > > >> > > > >> >
> > > > >> > > > >> > -Ewen
> > > > >> > > > >> >
> > > > >> > > > >> >
> > > > >> > > > >> > >
> > > > >> > > > >> > > Thanks,
> > > > >> > > > >> > >
> > > > >> > > > >> > > Jiangjie (Becket) Qin
> > > > >> > > > >> > >
> > > > >> > > > >> > >
> > > > >> > > > >> > > On Tue, Aug 11, 2015 at 11:06 PM, Ewen
> > Cheslack-Postava <
> > > > >> > > > >> > ewen@confluent.io
> > > > >> > > > >> > > >
> > > > >> > > > >> > > wrote:
> > > > >> > > > >> > >
> > > > >> > > > >> > > > On Tue, Aug 11, 2015 at 10:15 PM, Jiangjie Qin
> > > > >> > > > >> > <jqin@linkedin.com.invalid
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > wrote:
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > > Hi Jason,
> > > > >> > > > >> > > > >
> > > > >> > > > >> > > > > Thanks for writing this up. It would be useful to
> > > > >> generalize
> > > > >> > > the
> > > > >> > > > >> > group
> > > > >> > > > >> > > > > concept. I have a few questions below.
> > > > >> > > > >> > > > >
> > > > >> > > > >> > > > > 1. In old consumer actually the partition
> > assignment
> > > > are
> > > > >> > done
> > > > >> > > by
> > > > >> > > > >> > > > consumers
> > > > >> > > > >> > > > > themselves. We used zookeeper to guarantee that a
> > > > >> partition
> > > > >> > > will
> > > > >> > > > >> only
> > > > >> > > > >> > > be
> > > > >> > > > >> > > > > consumed by one consumer thread who successfully
> > > > claimed
> > > > >> its
> > > > >> > > > >> > ownership.
> > > > >> > > > >> > > > > Does the new protocol plan to provide the same
> > > > guarantee?
> > > > >> > > > >> > > > >
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > Once you have all the metadata from all the
> > consumers,
> > > > >> > > assignment
> > > > >> > > > >> > should
> > > > >> > > > >> > > > just be a simple function mapping that
> > Map<ConsumerId,
> > > > >> > Metadata>
> > > > >> > > > to
> > > > >> > > > >> > > > Map<ConsumerId, List<TopicPartition>>. If everyone
> is
> > > > >> > consistent
> > > > >> > > > in
> > > > >> > > > >> > > > computing that, you don't need ZK involved at all.
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > In practice, this shouldn't be that hard to ensure
> > for
> > > > most
> > > > >> > > > >> assignment
> > > > >> > > > >> > > > strategies just by having decent unit testing on
> > them.
> > > > You
> > > > >> > just
> > > > >> > > > >> have to
> > > > >> > > > >> > > do
> > > > >> > > > >> > > > things like ensure your assignment strategy sorts
> > lists
> > > > >> into a
> > > > >> > > > >> > consistent
> > > > >> > > > >> > > > order.
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > You do give up the ability to use some techniques
> > (e.g.
> > > > any
> > > > >> > > > >> randomized
> > > > >> > > > >> > > > algorithm if you can't distribute the seed w/ the
> > > > metadata)
> > > > >> > and
> > > > >> > > > it's
> > > > >> > > > >> > true
> > > > >> > > > >> > > > that nothing validates the assignment, but if that
> > > > >> assignment
> > > > >> > > > >> algorithm
> > > > >> > > > >> > > > step is kept simple, small, and well tested, the
> risk
> > > is
> > > > >> very
> > > > >> > > > >> minimal.
> > > > >> > > > >> > > >
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > >
> > > > >> > > > >> > > > > 2. It looks that both JoinGroupRequest and
> > > > >> JoinGroupResponse
> > > > >> > > has
> > > > >> > > > >> the
> > > > >> > > > >> > > > > ProtocolMetadata.AssignmentStrategyMetadata, what
> > > would
> > > > >> be
> > > > >> > the
> > > > >> > > > >> > metadata
> > > > >> > > > >> > > > be
> > > > >> > > > >> > > > > sent and returned by coordinator? How will the
> > > > >> coordinator
> > > > >> > > > handle
> > > > >> > > > >> the
> > > > >> > > > >> > > > > metadata?
> > > > >> > > > >> > > > >
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > The coordinator is basically just blindly
> > broadcasting
> > > > all
> > > > >> of
> > > > >> > it
> > > > >> > > > to
> > > > >> > > > >> > group
> > > > >> > > > >> > > > members so they have a consistent view.
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > So from the coordinators perspective, it sees
> > something
> > > > >> like:
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > Consumer 1 -> JoinGroupRequest with GroupProtocols
> =
> > [
> > > > >> > > "consumer"
> > > > >> > > > >> > > > <Consumer1 opaque byte[]>]
> > > > >> > > > >> > > > Consumer 2 -> JoinGroupRequest with GroupProtocols
> =
> > [
> > > > >> > > "consumer"
> > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > Then, in the responses would look like:
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > Consumer 1 <- JoinGroupResponse with GroupProtocol
> =
> > > > >> > "consumer"
> > > > >> > > > and
> > > > >> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque
> > byte[]>,
> > > > >> > Consumer
> > > > >> > > 2
> > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > >> > > > >> > > > Consumer 2 <- JoinGroupResponse with GroupProtocol
> =
> > > > >> > "consumer"
> > > > >> > > > and
> > > > >> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque
> > byte[]>,
> > > > >> > Consumer
> > > > >> > > 2
> > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > So all the responses include all the metadata for
> > every
> > > > >> member
> > > > >> > > in
> > > > >> > > > >> the
> > > > >> > > > >> > > > group, and everyone can use that to consistently
> > decide
> > > > on
> > > > >> > > > >> assignment.
> > > > >> > > > >> > > The
> > > > >> > > > >> > > > broker doesn't care and cannot even understand the
> > > > metadata
> > > > >> > > since
> > > > >> > > > >> the
> > > > >> > > > >> > > data
> > > > >> > > > >> > > > format for it is dependent on the assignment
> strategy
> > > > being
> > > > >> > > used.
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > As another example that is *not* a consumer, let's
> > say
> > > > you
> > > > >> > just
> > > > >> > > > >> want to
> > > > >> > > > >> > > > have a single writer in the group which everyone
> will
> > > > >> forward
> > > > >> > > > >> requests
> > > > >> > > > >> > > to.
> > > > >> > > > >> > > > To accomplish this, you could use a very dumb
> > > assignment
> > > > >> > > strategy:
> > > > >> > > > >> > there
> > > > >> > > > >> > > is
> > > > >> > > > >> > > > no metadata (empty byte[]) and all we care about is
> > who
> > > > is
> > > > >> the
> > > > >> > > > first
> > > > >> > > > >> > > member
> > > > >> > > > >> > > > in the group (e.g. when IDs are sorted
> > > > lexicographically).
> > > > >> > That
> > > > >> > > > >> member
> > > > >> > > > >> > is
> > > > >> > > > >> > > > selected as the writer. In that case, we actually
> > just
> > > > care
> > > > >> > > about
> > > > >> > > > >> the
> > > > >> > > > >> > > > membership list, there's no additional info about
> > each
> > > > >> member
> > > > >> > > that
> > > > >> > > > >> is
> > > > >> > > > >> > > > required to determine who is the writer.
> > > > >> > > > >> > > >
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > > 3. Do you mean that the number of partitions in
> > > > >> > > > JoinGroupResponse
> > > > >> > > > >> > will
> > > > >> > > > >> > > be
> > > > >> > > > >> > > > > the max partition number of a topic among all the
> > > > >> reported
> > > > >> > > > >> partition
> > > > >> > > > >> > > > number
> > > > >> > > > >> > > > > by consumers? Is there any reason not just let
> > > > >> Coordinator
> > > > >> > to
> > > > >> > > > >> return
> > > > >> > > > >> > > the
> > > > >> > > > >> > > > > number of partitions of a topic in its metadata
> > > cache?
> > > > >> > > > >> > > > >
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > Nothing from the embedded protocol is touched by
> the
> > > > >> broker.
> > > > >> > The
> > > > >> > > > >> broker
> > > > >> > > > >> > > > just collects opaque bytes of metadata, does the
> > > > selection
> > > > >> of
> > > > >> > > the
> > > > >> > > > >> > > strategy
> > > > >> > > > >> > > > if multiple are supported by some consumers, and
> then
> > > > >> returns
> > > > >> > > that
> > > > >> > > > >> > opaque
> > > > >> > > > >> > > > metadata for all the members back to every member.
> In
> > > > that
> > > > >> way
> > > > >> > > > they
> > > > >> > > > >> all
> > > > >> > > > >> > > > have a consistent view of the group. For regular
> > > > consumers,
> > > > >> > that
> > > > >> > > > >> view
> > > > >> > > > >> > of
> > > > >> > > > >> > > > the group includes information about how many
> > > partitions
> > > > >> each
> > > > >> > > > >> consumer
> > > > >> > > > >> > > > currently thinks the topics it is subscribed to
> has.
> > > > These
> > > > >> > could
> > > > >> > > > be
> > > > >> > > > >> > > > inconsistent due to out of date metadata and it
> would
> > > be
> > > > >> up to
> > > > >> > > the
> > > > >> > > > >> > > > assignment strategy on the *client* to resolve
> that.
> > As
> > > > you
> > > > >> > > point
> > > > >> > > > >> out,
> > > > >> > > > >> > in
> > > > >> > > > >> > > > that case they could just take the max value that
> any
> > > > >> consumer
> > > > >> > > > >> reported
> > > > >> > > > >> > > > seeing and use that. The consumers that notice that
> > > their
> > > > >> > > metadata
> > > > >> > > > >> had
> > > > >> > > > >> > a
> > > > >> > > > >> > > > smaller # of partitions should also trigger a
> > metadata
> > > > >> update
> > > > >> > > when
> > > > >> > > > >> they
> > > > >> > > > >> > > see
> > > > >> > > > >> > > > someone else observing a larger # of partitions.
> > > > >> > > > >> > > >
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > >
> > > > >> > > > >> > > > > Thanks,
> > > > >> > > > >> > > > >
> > > > >> > > > >> > > > > Jiangjie (Becket) Qin
> > > > >> > > > >> > > > >
> > > > >> > > > >> > > > >
> > > > >> > > > >> > > > >
> > > > >> > > > >> > > > >
> > > > >> > > > >> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson
> <
> > > > >> > > > >> jason@confluent.io
> > > > >> > > > >> > >
> > > > >> > > > >> > > > > wrote:
> > > > >> > > > >> > > > >
> > > > >> > > > >> > > > > > Hi Kafka Devs,
> > > > >> > > > >> > > > > >
> > > > >> > > > >> > > > > > One of the nagging issues in the current design
> > of
> > > > the
> > > > >> new
> > > > >> > > > >> consumer
> > > > >> > > > >> > > has
> > > > >> > > > >> > > > > > been the need to support a variety of
> assignment
> > > > >> > strategies.
> > > > >> > > > >> We've
> > > > >> > > > >> > > > > > encountered this in particular in the design of
> > > > copycat
> > > > >> > and
> > > > >> > > > the
> > > > >> > > > >> > > > > processing
> > > > >> > > > >> > > > > > framework (KIP-28). From what I understand,
> Samza
> > > > also
> > > > >> > has a
> > > > >> > > > >> number
> > > > >> > > > >> > > of
> > > > >> > > > >> > > > > use
> > > > >> > > > >> > > > > > cases with custom assignment needs. The new
> > > consumer
> > > > >> > > protocol
> > > > >> > > > >> > > supports
> > > > >> > > > >> > > > > new
> > > > >> > > > >> > > > > > assignment strategies by hooking them into the
> > > > broker.
> > > > >> For
> > > > >> > > > many
> > > > >> > > > >> > > > > > environments, this is a major pain and in some
> > > > cases, a
> > > > >> > > > >> > non-starter.
> > > > >> > > > >> > > It
> > > > >> > > > >> > > > > > also challenges the validation that the
> > coordinator
> > > > can
> > > > >> > > > provide.
> > > > >> > > > >> > For
> > > > >> > > > >> > > > > > example, some assignment strategies call for
> > > > >> partitions to
> > > > >> > > be
> > > > >> > > > >> > > assigned
> > > > >> > > > >> > > > > > multiple times, which means that the
> coordinator
> > > can
> > > > >> only
> > > > >> > > > check
> > > > >> > > > >> > that
> > > > >> > > > >> > > > > > partitions have been assigned at least once.
> > > > >> > > > >> > > > > >
> > > > >> > > > >> > > > > > To solve these issues, we'd like to propose
> > moving
> > > > >> > > assignment
> > > > >> > > > to
> > > > >> > > > >> > the
> > > > >> > > > >> > > > > > client. I've written a wiki which outlines some
> > > > >> protocol
> > > > >> > > > >> changes to
> > > > >> > > > >> > > > > achieve
> > > > >> > > > >> > > > > > this:
> > > > >> > > > >> > > > > >
> > > > >> > > > >> > > > > >
> > > > >> > > > >> > > > >
> > > > >> > > > >> > > >
> > > > >> > > > >> > >
> > > > >> > > > >> >
> > > > >> > > > >>
> > > > >> > > >
> > > > >> > >
> > > > >> >
> > > > >>
> > > >
> > >
> >
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> > > > >> > > > >> > > > > > .
> > > > >> > > > >> > > > > > To summarize briefly, instead of the
> coordinator
> > > > >> assigning
> > > > >> > > the
> > > > >> > > > >> > > > partitions
> > > > >> > > > >> > > > > > itself, all subscriptions are forwarded to each
> > > > member
> > > > >> of
> > > > >> > > the
> > > > >> > > > >> group
> > > > >> > > > >> > > > which
> > > > >> > > > >> > > > > > then decides independently which partitions it
> > > should
> > > > >> > > consume.
> > > > >> > > > >> The
> > > > >> > > > >> > > > > protocol
> > > > >> > > > >> > > > > > provides a mechanism for the coordinator to
> > > validate
> > > > >> that
> > > > >> > > all
> > > > >> > > > >> > > consumers
> > > > >> > > > >> > > > > use
> > > > >> > > > >> > > > > > the same assignment strategy, but it does not
> > > ensure
> > > > >> that
> > > > >> > > the
> > > > >> > > > >> > > resulting
> > > > >> > > > >> > > > > > assignment is "correct." This provides a
> powerful
> > > > >> > capability
> > > > >> > > > for
> > > > >> > > > >> > > users
> > > > >> > > > >> > > > to
> > > > >> > > > >> > > > > > control the full data flow on the client side.
> > They
> > > > >> > control
> > > > >> > > > how
> > > > >> > > > >> > data
> > > > >> > > > >> > > is
> > > > >> > > > >> > > > > > written to partitions through the Partitioner
> > > > interface
> > > > >> > and
> > > > >> > > > they
> > > > >> > > > >> > > > control
> > > > >> > > > >> > > > > > how data is consumed through the assignment
> > > strategy,
> > > > >> all
> > > > >> > > > >> without
> > > > >> > > > >> > > > > touching
> > > > >> > > > >> > > > > > the server.
> > > > >> > > > >> > > > > >
> > > > >> > > > >> > > > > > Of course nothing comes for free. In
> particular,
> > > this
> > > > >> > change
> > > > >> > > > >> > removes
> > > > >> > > > >> > > > the
> > > > >> > > > >> > > > > > ability of the coordinator to validate that
> > commits
> > > > are
> > > > >> > made
> > > > >> > > > by
> > > > >> > > > >> > > > consumers
> > > > >> > > > >> > > > > > who were assigned the respective partition.
> This
> > > > might
> > > > >> not
> > > > >> > > be
> > > > >> > > > >> too
> > > > >> > > > >> > bad
> > > > >> > > > >> > > > > since
> > > > >> > > > >> > > > > > we retain the ability to validate the
> generation
> > > id,
> > > > >> but
> > > > >> > it
> > > > >> > > > is a
> > > > >> > > > >> > > > > potential
> > > > >> > > > >> > > > > > concern. We have considered alternative
> protocols
> > > > which
> > > > >> > add
> > > > >> > > a
> > > > >> > > > >> > second
> > > > >> > > > >> > > > > > round-trip to the protocol in order to give the
> > > > >> > coordinator
> > > > >> > > > the
> > > > >> > > > >> > > ability
> > > > >> > > > >> > > > > to
> > > > >> > > > >> > > > > > confirm the assignment. As mentioned above, the
> > > > >> > coordinator
> > > > >> > > is
> > > > >> > > > >> > > somewhat
> > > > >> > > > >> > > > > > limited in what it can actually validate, but
> > this
> > > > >> would
> > > > >> > > > return
> > > > >> > > > >> its
> > > > >> > > > >> > > > > ability
> > > > >> > > > >> > > > > > to validate commits. The tradeoff is that it
> > > > increases
> > > > >> the
> > > > >> > > > >> > protocol's
> > > > >> > > > >> > > > > > complexity which means more ways for the
> protocol
> > > to
> > > > >> fail
> > > > >> > > and
> > > > >> > > > >> > > > > consequently
> > > > >> > > > >> > > > > > more edge cases in the code.
> > > > >> > > > >> > > > > >
> > > > >> > > > >> > > > > > It also misses an opportunity to generalize the
> > > group
> > > > >> > > > membership
> > > > >> > > > >> > > > protocol
> > > > >> > > > >> > > > > > for additional use cases. In fact, after you've
> > > gone
> > > > to
> > > > >> > the
> > > > >> > > > >> trouble
> > > > >> > > > >> > > of
> > > > >> > > > >> > > > > > moving assignment to the client, the main thing
> > > that
> > > > is
> > > > >> > left
> > > > >> > > > in
> > > > >> > > > >> > this
> > > > >> > > > >> > > > > > protocol is basically a general group
> management
> > > > >> > capability.
> > > > >> > > > >> This
> > > > >> > > > >> > is
> > > > >> > > > >> > > > > > exactly what is needed for a few cases that are
> > > > >> currently
> > > > >> > > > under
> > > > >> > > > >> > > > > discussion
> > > > >> > > > >> > > > > > (e.g. copycat or single-writer producer). We've
> > > taken
> > > > >> this
> > > > >> > > > >> further
> > > > >> > > > >> > > step
> > > > >> > > > >> > > > > in
> > > > >> > > > >> > > > > > the proposal and attempted to envision what
> that
> > > > >> general
> > > > >> > > > >> protocol
> > > > >> > > > >> > > might
> > > > >> > > > >> > > > > > look like and how it could be used both by the
> > > > consumer
> > > > >> > and
> > > > >> > > > for
> > > > >> > > > >> > some
> > > > >> > > > >> > > of
> > > > >> > > > >> > > > > > these other cases.
> > > > >> > > > >> > > > > >
> > > > >> > > > >> > > > > > Anyway, since time is running out on the new
> > > > consumer,
> > > > >> we
> > > > >> > > have
> > > > >> > > > >> > > perhaps
> > > > >> > > > >> > > > > one
> > > > >> > > > >> > > > > > last chance to consider a significant change in
> > the
> > > > >> > protocol
> > > > >> > > > >> like
> > > > >> > > > >> > > this,
> > > > >> > > > >> > > > > so
> > > > >> > > > >> > > > > > have a look at the wiki and share your
> thoughts.
> > > I've
> > > > >> no
> > > > >> > > doubt
> > > > >> > > > >> that
> > > > >> > > > >> > > > some
> > > > >> > > > >> > > > > > ideas seem clearer in my mind than they do on
> > > paper,
> > > > so
> > > > >> > ask
> > > > >> > > > >> > questions
> > > > >> > > > >> > > > if
> > > > >> > > > >> > > > > > there is any confusion.
> > > > >> > > > >> > > > > >
> > > > >> > > > >> > > > > > Thanks!
> > > > >> > > > >> > > > > > Jason
> > > > >> > > > >> > > > > >
> > > > >> > > > >> > > > >
> > > > >> > > > >> > > >
> > > > >> > > > >> > > >
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > --
> > > > >> > > > >> > > > Thanks,
> > > > >> > > > >> > > > Ewen
> > > > >> > > > >> > > >
> > > > >> > > > >> > >
> > > > >> > > > >> >
> > > > >> > > > >> >
> > > > >> > > > >> >
> > > > >> > > > >> > --
> > > > >> > > > >> > Thanks,
> > > > >> > > > >> > Ewen
> > > > >> > > > >> >
> > > > >> > > > >>
> > > > >> > > > >
> > > > >> > > > >
> > > > >> > > >
> > > > >> > >
> > > > >> >
> > > > >>
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Thanks,
> > > > > Neha
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Thanks,
> > > > Neha
> > > >
> > >
> > >
> > >
> > > --
> > > Thanks,
> > > Ewen
> > >
> >
>
>
>
> --
> Thanks,
> Ewen
>

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Neha Narkhede <ne...@confluent.io>.
Jason,

The way this is handled today (in the old consumer) is by grouping several
rebalance events into one rebalance operation (similar to how we handle log
flushes using "group commit"). The idea is to batch several rebalance
events while one rebalance operation is in progress.

This is naturally handled on the consumer side since the consumer would
only periodically refresh its metadata. Any metadata changes that happened
in between would end up contributing to only a single rebalance operation.
There might be more rebalance operations in the new proposal as compared to
the server side assignment since in the presence of lots of metadata
changes, every consumer might have a slightly different view of the global
metadata.

My take is that the intersection of a large number of metadata operations
and a consumer with a large number of topic subscriptions is fairly low.
Though it will be great to run a quick performance test on this scenario to
see if we can convince ourselves of the impact.

Thanks
Neha

On Fri, Aug 14, 2015 at 6:34 PM, Jason Gustafson <ja...@confluent.io> wrote:

> I think metadata churn is an interesting problem and it would be nice if we
> had some approach to deal with it. I wonder if it would be sufficient to
> have a setting on the client (or the server if we use centralized
> assignment) which dampens the rate of rebalancing. Basically the effect
> would be to delay a rebalance from a metadata change until the group has
> been active for some amount of time. This would mean that the group would
> not respond as quickly to metadata changes, but that is probably preferable
> to the the death by churn scenario. It may make sense to have a similar
> setting to delay group membership from causing a rebalance.
>
> -Jason
>
> On Fri, Aug 14, 2015 at 3:01 PM, Neha Narkhede <ne...@confluent.io> wrote:
>
> > >
> > > So if you're just subscribing to one or a couple of topics, why not
> just
> > > compute the hash by filtering out everything but the topics you are
> > > subscribed to? The problem there is if you ever add/remove
> subscriptions
> > > and want to support rolling upgrades. If the group was subscribed to
> > topic
> > > A, but later changes require subscribing to A + B, then to achieve a
> > > seamless rolling upgrade would require one (old) consumer to be
> > subscribing
> > > to A and one (new) consumer to be subscribing to A+B. If we computed
> > > metadata hashes based on filtered metadata, those two would disagree
> and
> > we
> > > could not perform assignment while the upgrade was in progress.
> >
> >
> > When I suggested including just the metadata hash, I didn't mean for all
> > topics in the cluster but just the topics the consumer wants to subscribe
> > to. I understand that it temporarily halts consumption while the topic
> > subscription changes but the question is whether we want to support
> > consumer groups with members that have different subscription
> preferences.
> > This came up during various discussions and the general consensus was
> that
> > we couldn't come up with compelling reasons to allow that. Upgrades are
> one
> > but then the question is how many upgrades would involve letting some
> > instances subscribe to a different set of topics for a long period of
> time
> > as against a simple rolling upgrade.
> >
> > I'm questioning the value of allowing the flexibility of variation in
> > consumer group topic subscriptions while trading off simplicity of the
> > consumer metadata format. The latter is important given the variety of
> > non-java consumer clients that need to exist and evolve with this change.
> >
> > Becket,
> >
> > If # of partitions or topic metadata changes, whether the coordinator
> > handles it or the consumer, there will be rebalance attempts until the
> > changes subside.
> >
> > Thanks,
> > Neha
> >
> > On Fri, Aug 14, 2015 at 12:57 PM, Ewen Cheslack-Postava <
> ewen@confluent.io
> > >
> > wrote:
> >
> > > On Fri, Aug 14, 2015 at 10:59 AM, Jiangjie Qin
> <jqin@linkedin.com.invalid
> > >
> > > wrote:
> > >
> > > > Neha and Ewen,
> > > >
> > > > About the metadata change frequency. I guess it really depends on how
> > > > frequent the metadata change might occur. If we run Kafka as a
> > service, I
> > > > can see that happens from time to time. As I can imagine people will
> > > create
> > > > some topic, test and maybe delete the topic in some automated test.
> If
> > > so,
> > > > the proposed protocol might be a little bit vulnerable.
> > > >
> > > > More specifically the scenario I am thinking is:
> > > > 1. Consumer 0 periodically refresh metadata and detected a metadata
> > > change.
> > > > So it sends a JoinGroupRequest with metadata_hash_0.
> > > > 2. Consumer 1 was notified by controller to start a rebalance, so it
> > > > refreshes its metadata and send a JoingGroupRequest with
> > metadata_hash_1,
> > > > which is different from metadata hash 0.
> > > > 3. Rebalance failed and both consumer refresh there metadata again
> from
> > > > different brokers.
> > > > 4. Depending on the metadata change frequency(or some admin operation
> > > like
> > > > partition reassigment), they may or may not have the same metadata
> > > > returned, so the restart from 3 again.
> > > >
> > > > I agree that step 4 might not be a big concern if consumers updates
> > > > metadata at almost the same time, but I'm a little bit worried
> whether
> > > that
> > > > assumption really stands because we do not have control over how
> > frequent
> > > > the metadata can change.
> > > >
> > > >
> > > Is this really that different from what would happen if the coordinator
> > > distributed the metadata to consumers? In that case you would trivially
> > > have everyone in a consistent state, but those metadata changes would
> > still
> > > cause churn and require JoinGroup rounds, during which processing is
> > > stalled for the nodes that are waiting on other members to re-join the
> > > group.
> > >
> > > -Ewen
> > >
> > >
> > > > Thanks,
> > > >
> > > > Jiangjie (Becket) Qin
> > > >
> > > > On Fri, Aug 14, 2015 at 2:03 AM, Ewen Cheslack-Postava <
> > > ewen@confluent.io>
> > > > wrote:
> > > >
> > > > > On Thu, Aug 13, 2015 at 11:07 PM, Neha Narkhede <neha@confluent.io
> >
> > > > wrote:
> > > > >
> > > > > > Becket,
> > > > > >
> > > > > > As you say, the metadata hash addresses the concern you
> originally
> > > > raised
> > > > > > about large topic subscriptions. Can you please list other
> problems
> > > you
> > > > > are
> > > > > > raising more clearly? It is more helpful to know problems that
> the
> > > > > proposal
> > > > > > does not address or addresses poorly.
> > > > > >
> > > > > > Regarding other things you said -
> > > > > >
> > > > > > it is required that each
> > > > > > > consumer refresh their metadata before sending a
> JoinGroupRequest
> > > > > > >
> > > > > >
> > > > > > This is required for wildcard topic subscriptions anyway. So this
> > > > > proposal
> > > > > > does not introduce a regression. We had agreed earlier that it
> does
> > > not
> > > > > > make sense for the server to deserialize regular expressions sent
> > by
> > > > the
> > > > > > consumer.
> > > > > >
> > > > >
> > > > > I don't think consumers need to do a metadata refresh before
> sending
> > a
> > > > > JoinGroupRequest. Metadata changes that affect assignment are rare
> --
> > > it
> > > > > requires changing the number of partitions in a topic. But you
> might
> > > > send a
> > > > > JoinGroupRequest simply because a new member is trying to join the
> > > group.
> > > > > That case is presumably much more common.
> > > > >
> > > > > I think it's actually a good idea to have the first JoinGroup cycle
> > > fail
> > > > in
> > > > > some cases, and has little impact. Lets say the metadata does
> change
> > > > > because partitions are added. Then we might fail in the first
> round,
> > > but
> > > > > then all members detect that issue *immediately*, refresh their
> > > metadata,
> > > > > and submit a new join group request. This second cycle does not
> > > require a
> > > > > full heartbeat cycle. It happens much more quickly because everyone
> > > > > detected the inconsistency based on the first JoinGroupResponse.
> The
> > > > > inconsistency should be resolved very quickly (barring other
> failures
> > > > like
> > > > > a member leaving mid-rebalance)
> > > >
> > > >
> > > >
> > > >
> > > > > >
> > > > > >
> > > > > > > the metadata might still be inconsistent if there is a topic or
> > > > > partition
> > > > > > > change because the
> > > > > > > UpdateMetadataRequest from controller might be handled at
> > different
> > > > > time.
> > > > > > >
> > > > > >
> > > > > > Topic metadata does not change frequently and even if it did, a
> > > couple
> > > > > > rebalance attempts will be needed whether the coordinator drives
> > the
> > > > > > assignments or the consumer. Because guess how the coordinator
> > knows
> > > > > about
> > > > > > the topic metadata changes -- indirectly through either a zk
> > callback
> > > > or
> > > > > > UpdateMetadataRequest, so it is completely possible the
> coordinator
> > > > sees
> > > > > > the topic metadata changes in batches, not all at once.
> > > > > >
> > > > >
> > > > > > On Thu, Aug 13, 2015 at 10:50 PM, Neha Narkhede <
> neha@confluent.io
> > >
> > > > > wrote:
> > > > > >
> > > > > > > Ewen/Jason,
> > > > > > >
> > > > > > > The metadata hash is a clever approach and certainly addresses
> > the
> > > > > > problem
> > > > > > > of large metadata for consumers like mirror maker. Few
> comments -
> > > > > > >
> > > > > > >
> > > > > > >    1. In the interest of simplifying the format of the
> consumer's
> > > > > > >    metadata - Why not just always include only the topic names
> in
> > > the
> > > > > > metadata
> > > > > > >    followed by the metadata hash? If the metadata hash check
> > > > succeeds,
> > > > > > each
> > > > > > >    consumer uses the # of partitions it had fetched. If it
> > fails, a
> > > > > > rebalance
> > > > > > >    happens and the metadata is not used anyway.
> > > > > >
> > > > >
> > > > > Doing this requires that every consumer always fetch the full
> > metadata.
> > > > The
> > > > > most common use case is consumers that just want to consume one or
> a
> > > > couple
> > > > > of topics, in which case grabbing all metadata for the entire
> cluster
> > > is
> > > > > wasteful. If I subscribe only to topic A, why make all consumers
> grab
> > > > > metadata for the entire topic (and need to rebalance every time it
> > > > > changes!). Including the # of partitions for each topic lets you
> > avoid
> > > > > having to grab the global set of metadata.
> > > > >
> > > > > So if you're just subscribing to one or a couple of topics, why not
> > > just
> > > > > compute the hash by filtering out everything but the topics you are
> > > > > subscribed to? The problem there is if you ever add/remove
> > > subscriptions
> > > > > and want to support rolling upgrades. If the group was subscribed
> to
> > > > topic
> > > > > A, but later changes require subscribing to A + B, then to achieve
> a
> > > > > seamless rolling upgrade would require one (old) consumer to be
> > > > subscribing
> > > > > to A and one (new) consumer to be subscribing to A+B. If we
> computed
> > > > > metadata hashes based on filtered metadata, those two would
> disagree
> > > and
> > > > we
> > > > > could not perform assignment while the upgrade was in progress.
> > > > >
> > > > > The solution is to differentiate between the cases when a very
> small
> > > > amount
> > > > > of the metadata is needed (one or a couple of topic subscriptions;
> > > > > communicate and share this via metadata in the JoinGroup protocol)
> vs
> > > > when
> > > > > *all* the metadata is needed (regex subscription; verify agreement
> > via
> > > > > hash).
> > > > >
> > > >
> > > > >
> > > > >
> > > > > > >    2. Do you need a topic list and topic regex to be separate?
> A
> > > > single
> > > > > > >    topic or list of topics can be expressed as a regex.
> > > > > >
> > > > >
> > > > > See above note about collecting all metadata when you really only
> > need
> > > it
> > > > > for 1 or 2 topics. There's probably some debate to be had about
> > whether
> > > > > this cost would be too high -- every consumer would need to request
> > the
> > > > > metadata for all topics, and they'd need to request that all every
> > time
> > > > > they might be out of date.
> > > > >
> > > > Are we going to allow consumers in the same group to subscribe to
> > > different
> > > > topic set? If we do, we need to let them refresh metadata for all the
> > > > topics a group is consuming from. If we don't then in the protocol we
> > > only
> > > > need a subscription set hash.
> > > >
> > > > >
> > > > >
> > > > > > >    3. Let's include a version explicitly at the beginning of
> the
> > > > > > >    ProtocolMetadata. The version dictates how to deserialize
> the
> > > > > > >    ProtocolMetadata blob and is consistent with the rest of
> > Kafka.
> > > > > >
> > > > >
> > > > > If I'm understanding correctly, in JoinGroupRequest I would change
> > > > >
> > > > > GroupProtocols          => [Protocol ProtocolMetadata]
> > > > >
> > > > > to
> > > > >
> > > > > GroupProtocols          => [Protocol ProtocolVersion
> > ProtocolMetadata]
> > > > >
> > > > > We had been talking about just baking the version into the Protocol
> > > > field,
> > > > > but making it separate seems perfectly reasonable to me. Jason, any
> > > issue
> > > > > with splitting the version out into a separate field like this?
> > > > >
> > > > > >
> > > > > > > That can simplify the metadata format to the following:
> > > > > > >
> > > > > > > GroupType => "consumer"
> > > > > > >>
> > > > > > >> Protocol => AssignmentStrategy
> > > > > > >>   AssignmentStrategy   => String
> > > > > > >>
> > > > > > >> ProtocolMetadata => Version Subscription
> > > AssignmentStrategyMetadata
> > > > > > >
> > > > > > >     Version                    => String
> > > > > > >
> > > > > > >   Subscription                 => TopicRegex MetadataHash
> > > > > > >>     TopicRegex                 => String
> > > > > > >>     MetadataHash               => String
> > > > > > >>   AssignmentStrategyMetadata   => bytes
> > > > > >
> > > > > >
> > > > > > >
> > > > > > > On Thu, Aug 13, 2015 at 6:28 PM, Jiangjie Qin
> > > > > <jqin@linkedin.com.invalid
> > > > > > >
> > > > > > > wrote:
> > > > > > >
> > > > > > >> Ewen and Jason,
> > > > > > >>
> > > > > > >> Thanks for the reply. Sorry I missed the metadata hash. Yes,
> > that
> > > > is a
> > > > > > >> clever approach and would solve my concern about the data
> > passing
> > > > > > around.
> > > > > > >> I
> > > > > > >> can see both pros and cons from doing this, though. The
> > advantage
> > > is
> > > > > we
> > > > > > >> don't need the topic metadata in JoinGroupResponse anymore.
> The
> > > > > downside
> > > > > > >> is
> > > > > > >> that now rebalance have extra dependency on the consensus of
> > > > metadata
> > > > > of
> > > > > > >> all consumers, which is obtained separately. So it is required
> > > that
> > > > > each
> > > > > > >> consumer refresh their metadata before sending a
> > JoinGroupRequest,
> > > > > > >> otherwise in some cases (e.g. wildcard consumers) will almost
> > > > > certainly
> > > > > > >> fail for the first rebalance attempt. Even if we do that,
> since
> > > the
> > > > > > >> consumers are getting metadata from different brokers, the
> > > metadata
> > > > > > might
> > > > > > >> still be inconsistent if there is a topic or partition change
> > > > because
> > > > > > the
> > > > > > >> UpdateMetadataRequest from controller might be handled at
> > > different
> > > > > > time.
> > > > > > >> Just want to make sure we think through the cases so the
> > protocol
> > > > does
> > > > > > not
> > > > > > >> cause us unexpected issues.
> > > > > > >>
> > > > > > >> About the number of consumers, I think with the current
> > liveliness
> > > > > > >> definition, we can tolerate churns by bumping up the session
> > > > timeout.
> > > > > > Also
> > > > > > >> I guess we will see an increasing number of consumers for new
> > > > > consumer,
> > > > > > >> because every the old consumer thread will probably become a
> > > > consumer.
> > > > > > >>
> > > > > > >> It is a valid concern for consumers that have large
> subscription
> > > > set.
> > > > > > This
> > > > > > >> might not be avoided though for client side assignment
> approach.
> > > One
> > > > > > >> solution is having topic names associate with a topic ID. And
> > only
> > > > use
> > > > > > >> topic ID in JoinGroupRequest and JoinGroupResponse, There is a
> > > > > > discussion
> > > > > > >> thread about this to solve the topic renaming case but this
> is a
> > > > > > >> completely
> > > > > > >> different discussion.
> > > > > > >>
> > > > > > >> Thanks,
> > > > > > >>
> > > > > > >> Jiangjie (Becket) Qin
> > > > > > >>
> > > > > > >>
> > > > > > >>
> > > > > > >> On Thu, Aug 13, 2015 at 2:14 PM, Jason Gustafson <
> > > > jason@confluent.io>
> > > > > > >> wrote:
> > > > > > >>
> > > > > > >> > Thanks Jiangjie, that information helps. I agree the
> protocol
> > > must
> > > > > > >> consider
> > > > > > >> > scalability. My point was that the synchronization barrier
> in
> > > the
> > > > > > >> current
> > > > > > >> > protocol already effectively limits the number of consumers
> > > since
> > > > it
> > > > > > >> > provides no way to gracefully handle churn. It wouldn't be
> > worth
> > > > > > >> worrying
> > > > > > >> > about scaling up to 100,000 members, for example, because
> > > there's
> > > > no
> > > > > > way
> > > > > > >> > the group would be stable. So we just need to set some clear
> > > > > > >> expectations
> > > > > > >> > on the size we can scale to, and that can help inform the
> > > > discussion
> > > > > > on
> > > > > > >> the
> > > > > > >> > size of messages in this protocol.
> > > > > > >> >
> > > > > > >> > Ewen and I were discussing this morning along similar lines
> to
> > > > what
> > > > > > >> you're
> > > > > > >> > suggesting. However, even if the coordinator decides on the
> > > > metadata
> > > > > > for
> > > > > > >> > the group, each member still needs to communicate its
> > > > subscriptions
> > > > > to
> > > > > > >> the
> > > > > > >> > rest of the group. This is nice for the regex case since the
> > > regex
> > > > > is
> > > > > > >> > probably small, but if the members have a large topic list,
> > then
> > > > we
> > > > > > have
> > > > > > >> > the same problem. One thing I was thinking about was whether
> > we
> > > > > really
> > > > > > >> need
> > > > > > >> > to handle different subscriptions for every member. If the
> > > > > coordinator
> > > > > > >> > could guarantee that all members had the same subscription,
> > then
> > > > > there
> > > > > > >> > would be no need for the coordinator to return the
> > subscriptions
> > > > for
> > > > > > >> each
> > > > > > >> > member. However, this would prevent graceful upgrades. We
> > might
> > > be
> > > > > > able
> > > > > > >> to
> > > > > > >> > fix that problem by allowing the consumer to provide two
> > > > > subscriptions
> > > > > > >> to
> > > > > > >> > allowing rolling updates, but that starts to sound pretty
> > nasty.
> > > > > > >> >
> > > > > > >> > -Jason
> > > > > > >> >
> > > > > > >> > On Thu, Aug 13, 2015 at 1:41 PM, Jiangjie Qin
> > > > > > <jqin@linkedin.com.invalid
> > > > > > >> >
> > > > > > >> > wrote:
> > > > > > >> >
> > > > > > >> > > Jason,
> > > > > > >> > >
> > > > > > >> > > The protocol has to consider the scalability. The protocol
> > in
> > > > the
> > > > > > wiki
> > > > > > >> > > means the JoinGroupResoponse size would be:
> > > > > > >> > > NumberOfTopics * (AvgTopicNameLength + 4) *
> > > > (NumberOfConsumers)^2
> > > > > > >> > >
> > > > > > >> > > To give some real number, we have 26-node Mirror Maker
> > > cluster,
> > > > > each
> > > > > > >> > with 4
> > > > > > >> > > consumers. That is 104 consumers using regex ".*". And
> most
> > of
> > > > our
> > > > > > >> > clusters
> > > > > > >> > > have around 3000 topics, whose topic name are typically
> > around
> > > > 20
> > > > > > >> > > characters.
> > > > > > >> > >
> > > > > > >> > > I think the key issue for client side partition assignment
> > > logic
> > > > > is
> > > > > > to
> > > > > > >> > make
> > > > > > >> > > sure 1) all the clients run the same algorithm. 2) all the
> > > > clients
> > > > > > >> make
> > > > > > >> > > decision on the same topic metadata. The second purpose
> can
> > be
> > > > > done
> > > > > > by
> > > > > > >> > > simply letting coordinator provide the topic metadata and
> > all
> > > > then
> > > > > > >> member
> > > > > > >> > > information as source of truth. Is it necessary to pass
> > topic
> > > > > > >> metadata of
> > > > > > >> > > each consumer around? Can we keep the protocol metadata
> > field
> > > > > > >> completely
> > > > > > >> > > independent of topic metadata? I think In the
> > > JoinGroupResponse,
> > > > > we
> > > > > > >> > should
> > > > > > >> > > have only one copy of topic metadata provided by
> coordinator
> > > and
> > > > > is
> > > > > > >> > outside
> > > > > > >> > > of protocol metadata. If user decides to put some metadata
> > in
> > > > the
> > > > > > >> > > JoinGroupRequest and let coordinator pass around, they are
> > > > > > responsible
> > > > > > >> > for
> > > > > > >> > > understanding the risk.
> > > > > > >> > >
> > > > > > >> > > Thanks,
> > > > > > >> > >
> > > > > > >> > > Jiangjie (Becket) Qin
> > > > > > >> > >
> > > > > > >> > >
> > > > > > >> > > On Thu, Aug 13, 2015 at 12:41 PM, Jason Gustafson <
> > > > > > jason@confluent.io
> > > > > > >> >
> > > > > > >> > > wrote:
> > > > > > >> > >
> > > > > > >> > > > Hey Onur and Jiangjie,
> > > > > > >> > > >
> > > > > > >> > > > I've updated that wiki with a proposal to add regex
> > > > > subscriptions
> > > > > > to
> > > > > > >> > the
> > > > > > >> > > > consumer metadata. Can you have a look to see if it
> > > addresses
> > > > > your
> > > > > > >> > > concern?
> > > > > > >> > > > In general, I think we should be a little careful when
> we
> > > are
> > > > > > >> talking
> > > > > > >> > > about
> > > > > > >> > > > the scalability of the protocol. Regardless of whether
> > > > > assignment
> > > > > > is
> > > > > > >> > done
> > > > > > >> > > > on the server or the client, the protocol assumes a
> > > relatively
> > > > > > >> stable
> > > > > > >> > > > configuration. When the number of consumers increases
> > > beyond a
> > > > > > >> certain
> > > > > > >> > > > limit, then membership churn becomes a major concern.
> > > > Similarly
> > > > > > >> there
> > > > > > >> > is
> > > > > > >> > > a
> > > > > > >> > > > notion of metadata churn when topics are added, deleted,
> > or
> > > > > > >> resized. If
> > > > > > >> > > > either membership or metadata changes, then the protocol
> > > > forces
> > > > > > all
> > > > > > >> > > > consumers to stop consumption and rejoin the group. If
> > this
> > > > > > happens
> > > > > > >> > often
> > > > > > >> > > > enough, then it can severely impact the ability of the
> > > > consumer
> > > > > to
> > > > > > >> make
> > > > > > >> > > > progress. The point is that the protocol may already be
> > > > unsuited
> > > > > > to
> > > > > > >> > cases
> > > > > > >> > > > where there are either a large number of consumers or
> > > topics.
> > > > I
> > > > > > >> wonder
> > > > > > >> > if
> > > > > > >> > > > you guys can share your thoughts about your scaling
> > > > > expectations?
> > > > > > >> > > >
> > > > > > >> > > > -Jason
> > > > > > >> > > >
> > > > > > >> > > >
> > > > > > >> > > >
> > > > > > >> > > >
> > > > > > >> > > > On Wed, Aug 12, 2015 at 12:28 PM, Jason Gustafson <
> > > > > > >> jason@confluent.io>
> > > > > > >> > > > wrote:
> > > > > > >> > > >
> > > > > > >> > > > > Hey Jiangjie,
> > > > > > >> > > > >
> > > > > > >> > > > > That's a great point. In the worst case (the mirror
> > maker
> > > > > case I
> > > > > > >> > > guess),
> > > > > > >> > > > > the join group response can be massive. This would be
> > > > > especially
> > > > > > >> > deadly
> > > > > > >> > > > > when there is a lot of churn in the group (e.g. in a
> > > rolling
> > > > > > >> > upgrade).
> > > > > > >> > > > The
> > > > > > >> > > > > current protocol is not great for this case either,
> but
> > > it's
> > > > > > >> > > > significantly
> > > > > > >> > > > > better. Here are a couple ways to deal with the size:
> > > > > > >> > > > >
> > > > > > >> > > > > 1. First, we could have the coordinator compress the
> > > > > responses.
> > > > > > >> This
> > > > > > >> > > > would
> > > > > > >> > > > > probably be pretty effective if applied across the
> > > metadata
> > > > > from
> > > > > > >> all
> > > > > > >> > > > > members.
> > > > > > >> > > > >
> > > > > > >> > > > > 2. I think the regex case is the main problem. Is that
> > > > right?
> > > > > We
> > > > > > >> > could
> > > > > > >> > > > > extend the metadata to allow the consumer to embed its
> > > regex
> > > > > > >> > > subscription
> > > > > > >> > > > > in the metadata directly (note this might be a good
> idea
> > > > > > >> regardless
> > > > > > >> > of
> > > > > > >> > > > the
> > > > > > >> > > > > rest of this proposal). To support regex on the
> > consumer,
> > > we
> > > > > > must
> > > > > > >> > fetch
> > > > > > >> > > > > metadata for all topics. Rather than having all regex
> > > > > > subscribers
> > > > > > >> > embed
> > > > > > >> > > > all
> > > > > > >> > > > > of this metadata in their join group requests, they
> > could
> > > > > > instead
> > > > > > >> > > embed a
> > > > > > >> > > > > hash of it. Then after the join group responses are
> > > > received,
> > > > > > they
> > > > > > >> > just
> > > > > > >> > > > > need to check that the hashes are the same. If there
> is
> > a
> > > > > > mismatch
> > > > > > >> > > (which
> > > > > > >> > > > > should only occur when topics are created, deleted, or
> > > > > resized),
> > > > > > >> then
> > > > > > >> > > the
> > > > > > >> > > > > group members must refetch the metadata and rejoin the
> > > > group.
> > > > > > >> This is
> > > > > > >> > > > also
> > > > > > >> > > > > how the current protocol behaves when there is a
> change
> > in
> > > > the
> > > > > > >> topic
> > > > > > >> > > > > metadata affecting the group--someone (either the
> > > > coordinator
> > > > > or
> > > > > > >> the
> > > > > > >> > > > > consumer) detects the change and forces the group to
> > > > > rebalance.
> > > > > > >> > > > >
> > > > > > >> > > > > What do you think?
> > > > > > >> > > > >
> > > > > > >> > > > > (Also I think adding groupId/generationId to fetch and
> > > > produce
> > > > > > >> > requests
> > > > > > >> > > > > seems like an interesting line of thought.)
> > > > > > >> > > > >
> > > > > > >> > > > > -Jason
> > > > > > >> > > > >
> > > > > > >> > > > >
> > > > > > >> > > > >
> > > > > > >> > > > > On Wed, Aug 12, 2015 at 10:57 AM, Jiangjie Qin
> > > > > > >> > > <jqin@linkedin.com.invalid
> > > > > > >> > > > >
> > > > > > >> > > > > wrote:
> > > > > > >> > > > >
> > > > > > >> > > > >> Hey Ewen,
> > > > > > >> > > > >>
> > > > > > >> > > > >> Onur and I discussed this a little bit more. And we
> are
> > > > still
> > > > > > >> > worrying
> > > > > > >> > > > >> about passing all the metadata of all consumers
> around.
> > > > > > >> > > > >>
> > > > > > >> > > > >> Let's say I have a cluster has 10,000 topics, the
> > average
> > > > > topic
> > > > > > >> name
> > > > > > >> > > > >> length
> > > > > > >> > > > >> is 10 bytes. In this case, the opaque metadata will
> > have
> > > > 10 *
> > > > > > >> > 10,000 =
> > > > > > >> > > > >> 100KB for topic name, for each topic, there is a
> 4-byte
> > > > > integer
> > > > > > >> of
> > > > > > >> > > > number
> > > > > > >> > > > >> of partitions, that's another 40KB. So one global
> topic
> > > > > > metadata
> > > > > > >> > will
> > > > > > >> > > > have
> > > > > > >> > > > >> 140KB data. If I have 100 consumers who are using
> > > wildcard
> > > > to
> > > > > > >> > consume
> > > > > > >> > > > from
> > > > > > >> > > > >> all the topics. That means the protocol metadata end
> up
> > > in
> > > > > the
> > > > > > >> > > > >> JoinGroupResponse will be 140KB * 100 = 14MB. And the
> > > > > > >> > > JoinGroupResponse
> > > > > > >> > > > >> will need to be sent to 100 different consumers, that
> > > means
> > > > > > 14MB
> > > > > > >> *
> > > > > > >> > > 100 =
> > > > > > >> > > > >> 1.4GB need to be sent by the consumer coordinator for
> > one
> > > > > > >> rebalance.
> > > > > > >> > > How
> > > > > > >> > > > >> would that work?
> > > > > > >> > > > >>
> > > > > > >> > > > >> Also, having two consumers (old owner and new owner)
> > > > > consuming
> > > > > > >> from
> > > > > > >> > > the
> > > > > > >> > > > >> same partition might also be a problem. e.g. people
> are
> > > > > > updating
> > > > > > >> > > > database.
> > > > > > >> > > > >> One thing might worth doing is to add GroupId and
> > > > Generation
> > > > > ID
> > > > > > >> to
> > > > > > >> > > > >> ProducerRequest and FetchRequest as well. This will
> > also
> > > > help
> > > > > > >> with
> > > > > > >> > the
> > > > > > >> > > > >> single producer use case. However, this is probably
> > > > > orthogonal
> > > > > > to
> > > > > > >> > this
> > > > > > >> > > > >> thread given the current new consumer also has this
> > > problem
> > > > > > and I
> > > > > > >> > > > believe
> > > > > > >> > > > >> we need to fix it.
> > > > > > >> > > > >>
> > > > > > >> > > > >> Thanks,
> > > > > > >> > > > >>
> > > > > > >> > > > >> Jiangjie (Becket) Qin
> > > > > > >> > > > >>
> > > > > > >> > > > >> On Tue, Aug 11, 2015 at 11:43 PM, Ewen
> > Cheslack-Postava <
> > > > > > >> > > > >> ewen@confluent.io>
> > > > > > >> > > > >> wrote:
> > > > > > >> > > > >>
> > > > > > >> > > > >> > On Tue, Aug 11, 2015 at 11:29 PM, Jiangjie Qin
> > > > > > >> > > > >> <jq...@linkedin.com.invalid>
> > > > > > >> > > > >> > wrote:
> > > > > > >> > > > >> >
> > > > > > >> > > > >> > > Ewen,
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> > > Thanks for the explanation.
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> > > For (1), I am more concerned about the failure
> case
> > > > > instead
> > > > > > >> of
> > > > > > >> > > > normal
> > > > > > >> > > > >> > case.
> > > > > > >> > > > >> > > What if a consumer somehow was kick out of a
> group
> > > but
> > > > is
> > > > > > >> still
> > > > > > >> > > > >> consuming
> > > > > > >> > > > >> > > and committing offsets? Does that mean the new
> > owner
> > > > and
> > > > > > old
> > > > > > >> > owner
> > > > > > >> > > > >> might
> > > > > > >> > > > >> > > potentially consuming from and committing offsets
> > for
> > > > the
> > > > > > >> same
> > > > > > >> > > > >> partition?
> > > > > > >> > > > >> > > In the old consumer, this won't happen because
> the
> > > new
> > > > > > >> consumer
> > > > > > >> > > will
> > > > > > >> > > > >> not
> > > > > > >> > > > >> > be
> > > > > > >> > > > >> > > able to start consumption unless the previous
> owner
> > > has
> > > > > > >> released
> > > > > > >> > > its
> > > > > > >> > > > >> > > ownership. Basically, without the ownership
> > > guarantee,
> > > > I
> > > > > > >> don't
> > > > > > >> > see
> > > > > > >> > > > how
> > > > > > >> > > > >> > the
> > > > > > >> > > > >> > > communication among consumers themselves alone
> can
> > > > solve
> > > > > > the
> > > > > > >> > > problem
> > > > > > >> > > > >> > here.
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> >
> > > > > > >> > > > >> > The generation ID check still applies to offset
> > > commits.
> > > > If
> > > > > > >> one of
> > > > > > >> > > the
> > > > > > >> > > > >> > consumers is kicked out and misbehaving, it can
> > > obviously
> > > > > > still
> > > > > > >> > > fetch
> > > > > > >> > > > >> and
> > > > > > >> > > > >> > process messages, but offset commits will not work
> > > since
> > > > it
> > > > > > >> will
> > > > > > >> > not
> > > > > > >> > > > >> have
> > > > > > >> > > > >> > the current generation ID.
> > > > > > >> > > > >> >
> > > > > > >> > > > >> >
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> > > For (2) and (3), now I understand how metadata
> are
> > > > used.
> > > > > > But
> > > > > > >> I
> > > > > > >> > > still
> > > > > > >> > > > >> > don't
> > > > > > >> > > > >> > > see why should we let the consumers to pass the
> > topic
> > > > > > >> > information
> > > > > > >> > > > >> across
> > > > > > >> > > > >> > > instead of letting coordinator give the
> > information.
> > > > The
> > > > > > >> single
> > > > > > >> > > > >> producer
> > > > > > >> > > > >> > > use case does not solve the ownership problem in
> > > > abnormal
> > > > > > >> case
> > > > > > >> > > > either,
> > > > > > >> > > > >> > > which seems to be a little bit vulnerable.
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> >
> > > > > > >> > > > >> > One of the goals here was to generalize group
> > > membership
> > > > so
> > > > > > we
> > > > > > >> > can,
> > > > > > >> > > > for
> > > > > > >> > > > >> > example, use it for balancing Copycat tasks across
> > > > workers.
> > > > > > >> > There's
> > > > > > >> > > no
> > > > > > >> > > > >> > topic subscription info in that case. The metadata
> > for
> > > > > > copycat
> > > > > > >> > > workers
> > > > > > >> > > > >> > would instead need to somehow indicate the current
> > set
> > > of
> > > > > > tasks
> > > > > > >> > that
> > > > > > >> > > > >> need
> > > > > > >> > > > >> > to be assigned to workers. By making the metadata
> > > > > completely
> > > > > > >> > opaque
> > > > > > >> > > to
> > > > > > >> > > > >> the
> > > > > > >> > > > >> > protocol, it becomes more generally useful since it
> > > > focuses
> > > > > > >> > squarely
> > > > > > >> > > > on
> > > > > > >> > > > >> the
> > > > > > >> > > > >> > group membership problem, allowing for that
> > additional
> > > > bit
> > > > > of
> > > > > > >> > > metadata
> > > > > > >> > > > >> so
> > > > > > >> > > > >> > you don't just get a list of members, but also get
> a
> > > > little
> > > > > > >> bit of
> > > > > > >> > > > info
> > > > > > >> > > > >> > about each of them.
> > > > > > >> > > > >> >
> > > > > > >> > > > >> > A different option that we explored is to use a
> sort
> > of
> > > > > mixed
> > > > > > >> > model
> > > > > > >> > > --
> > > > > > >> > > > >> > still bake all the topic subscriptions directly
> into
> > > the
> > > > > > >> protocol
> > > > > > >> > > but
> > > > > > >> > > > >> also
> > > > > > >> > > > >> > include metadata. That would allow us to maintain
> the
> > > > > > existing
> > > > > > >> > > > >> > coordinator-driven approach to handling the
> metadata
> > > and
> > > > > > change
> > > > > > >> > > events
> > > > > > >> > > > >> like
> > > > > > >> > > > >> > the ones Onur pointed out. Then something like the
> > > > Copycat
> > > > > > >> workers
> > > > > > >> > > > would
> > > > > > >> > > > >> > just not fill in any topic subscriptions and it
> would
> > > be
> > > > > > >> handled
> > > > > > >> > as
> > > > > > >> > > a
> > > > > > >> > > > >> > degenerate case. Based on the way I explained that
> we
> > > can
> > > > > > >> handle
> > > > > > >> > > those
> > > > > > >> > > > >> > types of events, I personally feel its cleaner and
> a
> > > > nicer
> > > > > > >> > > > >> generalization
> > > > > > >> > > > >> > to not include the subscriptions in the join group
> > > > > protocol,
> > > > > > >> > making
> > > > > > >> > > it
> > > > > > >> > > > >> part
> > > > > > >> > > > >> > of the metadata instead.
> > > > > > >> > > > >> >
> > > > > > >> > > > >> > For the single producer case, are you saying it
> > doesn't
> > > > > solve
> > > > > > >> > > > ownership
> > > > > > >> > > > >> in
> > > > > > >> > > > >> > the abnormal case because a producer that doesn't
> > know
> > > it
> > > > > has
> > > > > > >> been
> > > > > > >> > > > >> kicked
> > > > > > >> > > > >> > out of the group yet can still produce data even
> > though
> > > > it
> > > > > > >> > shouldn't
> > > > > > >> > > > be
> > > > > > >> > > > >> > able to anymore? I definitely agree that that is a
> > risk
> > > > --
> > > > > > this
> > > > > > >> > > > >> provides a
> > > > > > >> > > > >> > way to get closer to a true single-writer, but
> there
> > > are
> > > > > > >> > definitely
> > > > > > >> > > > >> still
> > > > > > >> > > > >> > failure modes that this does not address.
> > > > > > >> > > > >> >
> > > > > > >> > > > >> > -Ewen
> > > > > > >> > > > >> >
> > > > > > >> > > > >> >
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> > > Thanks,
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> > > Jiangjie (Becket) Qin
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> > > On Tue, Aug 11, 2015 at 11:06 PM, Ewen
> > > > Cheslack-Postava <
> > > > > > >> > > > >> > ewen@confluent.io
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > wrote:
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> > > > On Tue, Aug 11, 2015 at 10:15 PM, Jiangjie Qin
> > > > > > >> > > > >> > <jqin@linkedin.com.invalid
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > wrote:
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > > Hi Jason,
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > > > Thanks for writing this up. It would be
> useful
> > to
> > > > > > >> generalize
> > > > > > >> > > the
> > > > > > >> > > > >> > group
> > > > > > >> > > > >> > > > > concept. I have a few questions below.
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > > > 1. In old consumer actually the partition
> > > > assignment
> > > > > > are
> > > > > > >> > done
> > > > > > >> > > by
> > > > > > >> > > > >> > > > consumers
> > > > > > >> > > > >> > > > > themselves. We used zookeeper to guarantee
> > that a
> > > > > > >> partition
> > > > > > >> > > will
> > > > > > >> > > > >> only
> > > > > > >> > > > >> > > be
> > > > > > >> > > > >> > > > > consumed by one consumer thread who
> > successfully
> > > > > > claimed
> > > > > > >> its
> > > > > > >> > > > >> > ownership.
> > > > > > >> > > > >> > > > > Does the new protocol plan to provide the
> same
> > > > > > guarantee?
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > Once you have all the metadata from all the
> > > > consumers,
> > > > > > >> > > assignment
> > > > > > >> > > > >> > should
> > > > > > >> > > > >> > > > just be a simple function mapping that
> > > > Map<ConsumerId,
> > > > > > >> > Metadata>
> > > > > > >> > > > to
> > > > > > >> > > > >> > > > Map<ConsumerId, List<TopicPartition>>. If
> > everyone
> > > is
> > > > > > >> > consistent
> > > > > > >> > > > in
> > > > > > >> > > > >> > > > computing that, you don't need ZK involved at
> > all.
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > In practice, this shouldn't be that hard to
> > ensure
> > > > for
> > > > > > most
> > > > > > >> > > > >> assignment
> > > > > > >> > > > >> > > > strategies just by having decent unit testing
> on
> > > > them.
> > > > > > You
> > > > > > >> > just
> > > > > > >> > > > >> have to
> > > > > > >> > > > >> > > do
> > > > > > >> > > > >> > > > things like ensure your assignment strategy
> sorts
> > > > lists
> > > > > > >> into a
> > > > > > >> > > > >> > consistent
> > > > > > >> > > > >> > > > order.
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > You do give up the ability to use some
> techniques
> > > > (e.g.
> > > > > > any
> > > > > > >> > > > >> randomized
> > > > > > >> > > > >> > > > algorithm if you can't distribute the seed w/
> the
> > > > > > metadata)
> > > > > > >> > and
> > > > > > >> > > > it's
> > > > > > >> > > > >> > true
> > > > > > >> > > > >> > > > that nothing validates the assignment, but if
> > that
> > > > > > >> assignment
> > > > > > >> > > > >> algorithm
> > > > > > >> > > > >> > > > step is kept simple, small, and well tested,
> the
> > > risk
> > > > > is
> > > > > > >> very
> > > > > > >> > > > >> minimal.
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > > > 2. It looks that both JoinGroupRequest and
> > > > > > >> JoinGroupResponse
> > > > > > >> > > has
> > > > > > >> > > > >> the
> > > > > > >> > > > >> > > > > ProtocolMetadata.AssignmentStrategyMetadata,
> > what
> > > > > would
> > > > > > >> be
> > > > > > >> > the
> > > > > > >> > > > >> > metadata
> > > > > > >> > > > >> > > > be
> > > > > > >> > > > >> > > > > sent and returned by coordinator? How will
> the
> > > > > > >> coordinator
> > > > > > >> > > > handle
> > > > > > >> > > > >> the
> > > > > > >> > > > >> > > > > metadata?
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > The coordinator is basically just blindly
> > > > broadcasting
> > > > > > all
> > > > > > >> of
> > > > > > >> > it
> > > > > > >> > > > to
> > > > > > >> > > > >> > group
> > > > > > >> > > > >> > > > members so they have a consistent view.
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > So from the coordinators perspective, it sees
> > > > something
> > > > > > >> like:
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > Consumer 1 -> JoinGroupRequest with
> > GroupProtocols
> > > =
> > > > [
> > > > > > >> > > "consumer"
> > > > > > >> > > > >> > > > <Consumer1 opaque byte[]>]
> > > > > > >> > > > >> > > > Consumer 2 -> JoinGroupRequest with
> > GroupProtocols
> > > =
> > > > [
> > > > > > >> > > "consumer"
> > > > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > Then, in the responses would look like:
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > Consumer 1 <- JoinGroupResponse with
> > GroupProtocol
> > > =
> > > > > > >> > "consumer"
> > > > > > >> > > > and
> > > > > > >> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque
> > > > byte[]>,
> > > > > > >> > Consumer
> > > > > > >> > > 2
> > > > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > > > >> > > > >> > > > Consumer 2 <- JoinGroupResponse with
> > GroupProtocol
> > > =
> > > > > > >> > "consumer"
> > > > > > >> > > > and
> > > > > > >> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque
> > > > byte[]>,
> > > > > > >> > Consumer
> > > > > > >> > > 2
> > > > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > So all the responses include all the metadata
> for
> > > > every
> > > > > > >> member
> > > > > > >> > > in
> > > > > > >> > > > >> the
> > > > > > >> > > > >> > > > group, and everyone can use that to
> consistently
> > > > decide
> > > > > > on
> > > > > > >> > > > >> assignment.
> > > > > > >> > > > >> > > The
> > > > > > >> > > > >> > > > broker doesn't care and cannot even understand
> > the
> > > > > > metadata
> > > > > > >> > > since
> > > > > > >> > > > >> the
> > > > > > >> > > > >> > > data
> > > > > > >> > > > >> > > > format for it is dependent on the assignment
> > > strategy
> > > > > > being
> > > > > > >> > > used.
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > As another example that is *not* a consumer,
> > let's
> > > > say
> > > > > > you
> > > > > > >> > just
> > > > > > >> > > > >> want to
> > > > > > >> > > > >> > > > have a single writer in the group which
> everyone
> > > will
> > > > > > >> forward
> > > > > > >> > > > >> requests
> > > > > > >> > > > >> > > to.
> > > > > > >> > > > >> > > > To accomplish this, you could use a very dumb
> > > > > assignment
> > > > > > >> > > strategy:
> > > > > > >> > > > >> > there
> > > > > > >> > > > >> > > is
> > > > > > >> > > > >> > > > no metadata (empty byte[]) and all we care
> about
> > is
> > > > who
> > > > > > is
> > > > > > >> the
> > > > > > >> > > > first
> > > > > > >> > > > >> > > member
> > > > > > >> > > > >> > > > in the group (e.g. when IDs are sorted
> > > > > > lexicographically).
> > > > > > >> > That
> > > > > > >> > > > >> member
> > > > > > >> > > > >> > is
> > > > > > >> > > > >> > > > selected as the writer. In that case, we
> actually
> > > > just
> > > > > > care
> > > > > > >> > > about
> > > > > > >> > > > >> the
> > > > > > >> > > > >> > > > membership list, there's no additional info
> about
> > > > each
> > > > > > >> member
> > > > > > >> > > that
> > > > > > >> > > > >> is
> > > > > > >> > > > >> > > > required to determine who is the writer.
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > > 3. Do you mean that the number of partitions
> in
> > > > > > >> > > > JoinGroupResponse
> > > > > > >> > > > >> > will
> > > > > > >> > > > >> > > be
> > > > > > >> > > > >> > > > > the max partition number of a topic among all
> > the
> > > > > > >> reported
> > > > > > >> > > > >> partition
> > > > > > >> > > > >> > > > number
> > > > > > >> > > > >> > > > > by consumers? Is there any reason not just
> let
> > > > > > >> Coordinator
> > > > > > >> > to
> > > > > > >> > > > >> return
> > > > > > >> > > > >> > > the
> > > > > > >> > > > >> > > > > number of partitions of a topic in its
> metadata
> > > > > cache?
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > Nothing from the embedded protocol is touched
> by
> > > the
> > > > > > >> broker.
> > > > > > >> > The
> > > > > > >> > > > >> broker
> > > > > > >> > > > >> > > > just collects opaque bytes of metadata, does
> the
> > > > > > selection
> > > > > > >> of
> > > > > > >> > > the
> > > > > > >> > > > >> > > strategy
> > > > > > >> > > > >> > > > if multiple are supported by some consumers,
> and
> > > then
> > > > > > >> returns
> > > > > > >> > > that
> > > > > > >> > > > >> > opaque
> > > > > > >> > > > >> > > > metadata for all the members back to every
> > member.
> > > In
> > > > > > that
> > > > > > >> way
> > > > > > >> > > > they
> > > > > > >> > > > >> all
> > > > > > >> > > > >> > > > have a consistent view of the group. For
> regular
> > > > > > consumers,
> > > > > > >> > that
> > > > > > >> > > > >> view
> > > > > > >> > > > >> > of
> > > > > > >> > > > >> > > > the group includes information about how many
> > > > > partitions
> > > > > > >> each
> > > > > > >> > > > >> consumer
> > > > > > >> > > > >> > > > currently thinks the topics it is subscribed to
> > > has.
> > > > > > These
> > > > > > >> > could
> > > > > > >> > > > be
> > > > > > >> > > > >> > > > inconsistent due to out of date metadata and it
> > > would
> > > > > be
> > > > > > >> up to
> > > > > > >> > > the
> > > > > > >> > > > >> > > > assignment strategy on the *client* to resolve
> > > that.
> > > > As
> > > > > > you
> > > > > > >> > > point
> > > > > > >> > > > >> out,
> > > > > > >> > > > >> > in
> > > > > > >> > > > >> > > > that case they could just take the max value
> that
> > > any
> > > > > > >> consumer
> > > > > > >> > > > >> reported
> > > > > > >> > > > >> > > > seeing and use that. The consumers that notice
> > that
> > > > > their
> > > > > > >> > > metadata
> > > > > > >> > > > >> had
> > > > > > >> > > > >> > a
> > > > > > >> > > > >> > > > smaller # of partitions should also trigger a
> > > > metadata
> > > > > > >> update
> > > > > > >> > > when
> > > > > > >> > > > >> they
> > > > > > >> > > > >> > > see
> > > > > > >> > > > >> > > > someone else observing a larger # of
> partitions.
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > > > Thanks,
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > > > Jiangjie (Becket) Qin
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason
> > Gustafson
> > > <
> > > > > > >> > > > >> jason@confluent.io
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> > > > > wrote:
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > > > > Hi Kafka Devs,
> > > > > > >> > > > >> > > > > >
> > > > > > >> > > > >> > > > > > One of the nagging issues in the current
> > design
> > > > of
> > > > > > the
> > > > > > >> new
> > > > > > >> > > > >> consumer
> > > > > > >> > > > >> > > has
> > > > > > >> > > > >> > > > > > been the need to support a variety of
> > > assignment
> > > > > > >> > strategies.
> > > > > > >> > > > >> We've
> > > > > > >> > > > >> > > > > > encountered this in particular in the
> design
> > of
> > > > > > copycat
> > > > > > >> > and
> > > > > > >> > > > the
> > > > > > >> > > > >> > > > > processing
> > > > > > >> > > > >> > > > > > framework (KIP-28). From what I understand,
> > > Samza
> > > > > > also
> > > > > > >> > has a
> > > > > > >> > > > >> number
> > > > > > >> > > > >> > > of
> > > > > > >> > > > >> > > > > use
> > > > > > >> > > > >> > > > > > cases with custom assignment needs. The new
> > > > > consumer
> > > > > > >> > > protocol
> > > > > > >> > > > >> > > supports
> > > > > > >> > > > >> > > > > new
> > > > > > >> > > > >> > > > > > assignment strategies by hooking them into
> > the
> > > > > > broker.
> > > > > > >> For
> > > > > > >> > > > many
> > > > > > >> > > > >> > > > > > environments, this is a major pain and in
> > some
> > > > > > cases, a
> > > > > > >> > > > >> > non-starter.
> > > > > > >> > > > >> > > It
> > > > > > >> > > > >> > > > > > also challenges the validation that the
> > > > coordinator
> > > > > > can
> > > > > > >> > > > provide.
> > > > > > >> > > > >> > For
> > > > > > >> > > > >> > > > > > example, some assignment strategies call
> for
> > > > > > >> partitions to
> > > > > > >> > > be
> > > > > > >> > > > >> > > assigned
> > > > > > >> > > > >> > > > > > multiple times, which means that the
> > > coordinator
> > > > > can
> > > > > > >> only
> > > > > > >> > > > check
> > > > > > >> > > > >> > that
> > > > > > >> > > > >> > > > > > partitions have been assigned at least
> once.
> > > > > > >> > > > >> > > > > >
> > > > > > >> > > > >> > > > > > To solve these issues, we'd like to propose
> > > > moving
> > > > > > >> > > assignment
> > > > > > >> > > > to
> > > > > > >> > > > >> > the
> > > > > > >> > > > >> > > > > > client. I've written a wiki which outlines
> > some
> > > > > > >> protocol
> > > > > > >> > > > >> changes to
> > > > > > >> > > > >> > > > > achieve
> > > > > > >> > > > >> > > > > > this:
> > > > > > >> > > > >> > > > > >
> > > > > > >> > > > >> > > > > >
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> >
> > > > > > >> > > > >>
> > > > > > >> > > >
> > > > > > >> > >
> > > > > > >> >
> > > > > > >>
> > > > > >
> > > > >
> > > >
> > >
> >
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> > > > > > >> > > > >> > > > > > .
> > > > > > >> > > > >> > > > > > To summarize briefly, instead of the
> > > coordinator
> > > > > > >> assigning
> > > > > > >> > > the
> > > > > > >> > > > >> > > > partitions
> > > > > > >> > > > >> > > > > > itself, all subscriptions are forwarded to
> > each
> > > > > > member
> > > > > > >> of
> > > > > > >> > > the
> > > > > > >> > > > >> group
> > > > > > >> > > > >> > > > which
> > > > > > >> > > > >> > > > > > then decides independently which partitions
> > it
> > > > > should
> > > > > > >> > > consume.
> > > > > > >> > > > >> The
> > > > > > >> > > > >> > > > > protocol
> > > > > > >> > > > >> > > > > > provides a mechanism for the coordinator to
> > > > > validate
> > > > > > >> that
> > > > > > >> > > all
> > > > > > >> > > > >> > > consumers
> > > > > > >> > > > >> > > > > use
> > > > > > >> > > > >> > > > > > the same assignment strategy, but it does
> not
> > > > > ensure
> > > > > > >> that
> > > > > > >> > > the
> > > > > > >> > > > >> > > resulting
> > > > > > >> > > > >> > > > > > assignment is "correct." This provides a
> > > powerful
> > > > > > >> > capability
> > > > > > >> > > > for
> > > > > > >> > > > >> > > users
> > > > > > >> > > > >> > > > to
> > > > > > >> > > > >> > > > > > control the full data flow on the client
> > side.
> > > > They
> > > > > > >> > control
> > > > > > >> > > > how
> > > > > > >> > > > >> > data
> > > > > > >> > > > >> > > is
> > > > > > >> > > > >> > > > > > written to partitions through the
> Partitioner
> > > > > > interface
> > > > > > >> > and
> > > > > > >> > > > they
> > > > > > >> > > > >> > > > control
> > > > > > >> > > > >> > > > > > how data is consumed through the assignment
> > > > > strategy,
> > > > > > >> all
> > > > > > >> > > > >> without
> > > > > > >> > > > >> > > > > touching
> > > > > > >> > > > >> > > > > > the server.
> > > > > > >> > > > >> > > > > >
> > > > > > >> > > > >> > > > > > Of course nothing comes for free. In
> > > particular,
> > > > > this
> > > > > > >> > change
> > > > > > >> > > > >> > removes
> > > > > > >> > > > >> > > > the
> > > > > > >> > > > >> > > > > > ability of the coordinator to validate that
> > > > commits
> > > > > > are
> > > > > > >> > made
> > > > > > >> > > > by
> > > > > > >> > > > >> > > > consumers
> > > > > > >> > > > >> > > > > > who were assigned the respective partition.
> > > This
> > > > > > might
> > > > > > >> not
> > > > > > >> > > be
> > > > > > >> > > > >> too
> > > > > > >> > > > >> > bad
> > > > > > >> > > > >> > > > > since
> > > > > > >> > > > >> > > > > > we retain the ability to validate the
> > > generation
> > > > > id,
> > > > > > >> but
> > > > > > >> > it
> > > > > > >> > > > is a
> > > > > > >> > > > >> > > > > potential
> > > > > > >> > > > >> > > > > > concern. We have considered alternative
> > > protocols
> > > > > > which
> > > > > > >> > add
> > > > > > >> > > a
> > > > > > >> > > > >> > second
> > > > > > >> > > > >> > > > > > round-trip to the protocol in order to give
> > the
> > > > > > >> > coordinator
> > > > > > >> > > > the
> > > > > > >> > > > >> > > ability
> > > > > > >> > > > >> > > > > to
> > > > > > >> > > > >> > > > > > confirm the assignment. As mentioned above,
> > the
> > > > > > >> > coordinator
> > > > > > >> > > is
> > > > > > >> > > > >> > > somewhat
> > > > > > >> > > > >> > > > > > limited in what it can actually validate,
> but
> > > > this
> > > > > > >> would
> > > > > > >> > > > return
> > > > > > >> > > > >> its
> > > > > > >> > > > >> > > > > ability
> > > > > > >> > > > >> > > > > > to validate commits. The tradeoff is that
> it
> > > > > > increases
> > > > > > >> the
> > > > > > >> > > > >> > protocol's
> > > > > > >> > > > >> > > > > > complexity which means more ways for the
> > > protocol
> > > > > to
> > > > > > >> fail
> > > > > > >> > > and
> > > > > > >> > > > >> > > > > consequently
> > > > > > >> > > > >> > > > > > more edge cases in the code.
> > > > > > >> > > > >> > > > > >
> > > > > > >> > > > >> > > > > > It also misses an opportunity to generalize
> > the
> > > > > group
> > > > > > >> > > > membership
> > > > > > >> > > > >> > > > protocol
> > > > > > >> > > > >> > > > > > for additional use cases. In fact, after
> > you've
> > > > > gone
> > > > > > to
> > > > > > >> > the
> > > > > > >> > > > >> trouble
> > > > > > >> > > > >> > > of
> > > > > > >> > > > >> > > > > > moving assignment to the client, the main
> > thing
> > > > > that
> > > > > > is
> > > > > > >> > left
> > > > > > >> > > > in
> > > > > > >> > > > >> > this
> > > > > > >> > > > >> > > > > > protocol is basically a general group
> > > management
> > > > > > >> > capability.
> > > > > > >> > > > >> This
> > > > > > >> > > > >> > is
> > > > > > >> > > > >> > > > > > exactly what is needed for a few cases that
> > are
> > > > > > >> currently
> > > > > > >> > > > under
> > > > > > >> > > > >> > > > > discussion
> > > > > > >> > > > >> > > > > > (e.g. copycat or single-writer producer).
> > We've
> > > > > taken
> > > > > > >> this
> > > > > > >> > > > >> further
> > > > > > >> > > > >> > > step
> > > > > > >> > > > >> > > > > in
> > > > > > >> > > > >> > > > > > the proposal and attempted to envision what
> > > that
> > > > > > >> general
> > > > > > >> > > > >> protocol
> > > > > > >> > > > >> > > might
> > > > > > >> > > > >> > > > > > look like and how it could be used both by
> > the
> > > > > > consumer
> > > > > > >> > and
> > > > > > >> > > > for
> > > > > > >> > > > >> > some
> > > > > > >> > > > >> > > of
> > > > > > >> > > > >> > > > > > these other cases.
> > > > > > >> > > > >> > > > > >
> > > > > > >> > > > >> > > > > > Anyway, since time is running out on the
> new
> > > > > > consumer,
> > > > > > >> we
> > > > > > >> > > have
> > > > > > >> > > > >> > > perhaps
> > > > > > >> > > > >> > > > > one
> > > > > > >> > > > >> > > > > > last chance to consider a significant
> change
> > in
> > > > the
> > > > > > >> > protocol
> > > > > > >> > > > >> like
> > > > > > >> > > > >> > > this,
> > > > > > >> > > > >> > > > > so
> > > > > > >> > > > >> > > > > > have a look at the wiki and share your
> > > thoughts.
> > > > > I've
> > > > > > >> no
> > > > > > >> > > doubt
> > > > > > >> > > > >> that
> > > > > > >> > > > >> > > > some
> > > > > > >> > > > >> > > > > > ideas seem clearer in my mind than they do
> on
> > > > > paper,
> > > > > > so
> > > > > > >> > ask
> > > > > > >> > > > >> > questions
> > > > > > >> > > > >> > > > if
> > > > > > >> > > > >> > > > > > there is any confusion.
> > > > > > >> > > > >> > > > > >
> > > > > > >> > > > >> > > > > > Thanks!
> > > > > > >> > > > >> > > > > > Jason
> > > > > > >> > > > >> > > > > >
> > > > > > >> > > > >> > > > >
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > > > --
> > > > > > >> > > > >> > > > Thanks,
> > > > > > >> > > > >> > > > Ewen
> > > > > > >> > > > >> > > >
> > > > > > >> > > > >> > >
> > > > > > >> > > > >> >
> > > > > > >> > > > >> >
> > > > > > >> > > > >> >
> > > > > > >> > > > >> > --
> > > > > > >> > > > >> > Thanks,
> > > > > > >> > > > >> > Ewen
> > > > > > >> > > > >> >
> > > > > > >> > > > >>
> > > > > > >> > > > >
> > > > > > >> > > > >
> > > > > > >> > > >
> > > > > > >> > >
> > > > > > >> >
> > > > > > >>
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Thanks,
> > > > > > > Neha
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Thanks,
> > > > > > Neha
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Thanks,
> > > > > Ewen
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Thanks,
> > > Ewen
> > >
> >
> >
> >
> > --
> > Thanks,
> > Neha
> >
>



-- 
Thanks,
Neha

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Jason Gustafson <ja...@confluent.io>.
I think metadata churn is an interesting problem and it would be nice if we
had some approach to deal with it. I wonder if it would be sufficient to
have a setting on the client (or the server if we use centralized
assignment) which dampens the rate of rebalancing. Basically the effect
would be to delay a rebalance from a metadata change until the group has
been active for some amount of time. This would mean that the group would
not respond as quickly to metadata changes, but that is probably preferable
to the the death by churn scenario. It may make sense to have a similar
setting to delay group membership from causing a rebalance.

-Jason

On Fri, Aug 14, 2015 at 3:01 PM, Neha Narkhede <ne...@confluent.io> wrote:

> >
> > So if you're just subscribing to one or a couple of topics, why not just
> > compute the hash by filtering out everything but the topics you are
> > subscribed to? The problem there is if you ever add/remove subscriptions
> > and want to support rolling upgrades. If the group was subscribed to
> topic
> > A, but later changes require subscribing to A + B, then to achieve a
> > seamless rolling upgrade would require one (old) consumer to be
> subscribing
> > to A and one (new) consumer to be subscribing to A+B. If we computed
> > metadata hashes based on filtered metadata, those two would disagree and
> we
> > could not perform assignment while the upgrade was in progress.
>
>
> When I suggested including just the metadata hash, I didn't mean for all
> topics in the cluster but just the topics the consumer wants to subscribe
> to. I understand that it temporarily halts consumption while the topic
> subscription changes but the question is whether we want to support
> consumer groups with members that have different subscription preferences.
> This came up during various discussions and the general consensus was that
> we couldn't come up with compelling reasons to allow that. Upgrades are one
> but then the question is how many upgrades would involve letting some
> instances subscribe to a different set of topics for a long period of time
> as against a simple rolling upgrade.
>
> I'm questioning the value of allowing the flexibility of variation in
> consumer group topic subscriptions while trading off simplicity of the
> consumer metadata format. The latter is important given the variety of
> non-java consumer clients that need to exist and evolve with this change.
>
> Becket,
>
> If # of partitions or topic metadata changes, whether the coordinator
> handles it or the consumer, there will be rebalance attempts until the
> changes subside.
>
> Thanks,
> Neha
>
> On Fri, Aug 14, 2015 at 12:57 PM, Ewen Cheslack-Postava <ewen@confluent.io
> >
> wrote:
>
> > On Fri, Aug 14, 2015 at 10:59 AM, Jiangjie Qin <jqin@linkedin.com.invalid
> >
> > wrote:
> >
> > > Neha and Ewen,
> > >
> > > About the metadata change frequency. I guess it really depends on how
> > > frequent the metadata change might occur. If we run Kafka as a
> service, I
> > > can see that happens from time to time. As I can imagine people will
> > create
> > > some topic, test and maybe delete the topic in some automated test. If
> > so,
> > > the proposed protocol might be a little bit vulnerable.
> > >
> > > More specifically the scenario I am thinking is:
> > > 1. Consumer 0 periodically refresh metadata and detected a metadata
> > change.
> > > So it sends a JoinGroupRequest with metadata_hash_0.
> > > 2. Consumer 1 was notified by controller to start a rebalance, so it
> > > refreshes its metadata and send a JoingGroupRequest with
> metadata_hash_1,
> > > which is different from metadata hash 0.
> > > 3. Rebalance failed and both consumer refresh there metadata again from
> > > different brokers.
> > > 4. Depending on the metadata change frequency(or some admin operation
> > like
> > > partition reassigment), they may or may not have the same metadata
> > > returned, so the restart from 3 again.
> > >
> > > I agree that step 4 might not be a big concern if consumers updates
> > > metadata at almost the same time, but I'm a little bit worried whether
> > that
> > > assumption really stands because we do not have control over how
> frequent
> > > the metadata can change.
> > >
> > >
> > Is this really that different from what would happen if the coordinator
> > distributed the metadata to consumers? In that case you would trivially
> > have everyone in a consistent state, but those metadata changes would
> still
> > cause churn and require JoinGroup rounds, during which processing is
> > stalled for the nodes that are waiting on other members to re-join the
> > group.
> >
> > -Ewen
> >
> >
> > > Thanks,
> > >
> > > Jiangjie (Becket) Qin
> > >
> > > On Fri, Aug 14, 2015 at 2:03 AM, Ewen Cheslack-Postava <
> > ewen@confluent.io>
> > > wrote:
> > >
> > > > On Thu, Aug 13, 2015 at 11:07 PM, Neha Narkhede <ne...@confluent.io>
> > > wrote:
> > > >
> > > > > Becket,
> > > > >
> > > > > As you say, the metadata hash addresses the concern you originally
> > > raised
> > > > > about large topic subscriptions. Can you please list other problems
> > you
> > > > are
> > > > > raising more clearly? It is more helpful to know problems that the
> > > > proposal
> > > > > does not address or addresses poorly.
> > > > >
> > > > > Regarding other things you said -
> > > > >
> > > > > it is required that each
> > > > > > consumer refresh their metadata before sending a JoinGroupRequest
> > > > > >
> > > > >
> > > > > This is required for wildcard topic subscriptions anyway. So this
> > > > proposal
> > > > > does not introduce a regression. We had agreed earlier that it does
> > not
> > > > > make sense for the server to deserialize regular expressions sent
> by
> > > the
> > > > > consumer.
> > > > >
> > > >
> > > > I don't think consumers need to do a metadata refresh before sending
> a
> > > > JoinGroupRequest. Metadata changes that affect assignment are rare --
> > it
> > > > requires changing the number of partitions in a topic. But you might
> > > send a
> > > > JoinGroupRequest simply because a new member is trying to join the
> > group.
> > > > That case is presumably much more common.
> > > >
> > > > I think it's actually a good idea to have the first JoinGroup cycle
> > fail
> > > in
> > > > some cases, and has little impact. Lets say the metadata does change
> > > > because partitions are added. Then we might fail in the first round,
> > but
> > > > then all members detect that issue *immediately*, refresh their
> > metadata,
> > > > and submit a new join group request. This second cycle does not
> > require a
> > > > full heartbeat cycle. It happens much more quickly because everyone
> > > > detected the inconsistency based on the first JoinGroupResponse. The
> > > > inconsistency should be resolved very quickly (barring other failures
> > > like
> > > > a member leaving mid-rebalance)
> > >
> > >
> > >
> > >
> > > > >
> > > > >
> > > > > > the metadata might still be inconsistent if there is a topic or
> > > > partition
> > > > > > change because the
> > > > > > UpdateMetadataRequest from controller might be handled at
> different
> > > > time.
> > > > > >
> > > > >
> > > > > Topic metadata does not change frequently and even if it did, a
> > couple
> > > > > rebalance attempts will be needed whether the coordinator drives
> the
> > > > > assignments or the consumer. Because guess how the coordinator
> knows
> > > > about
> > > > > the topic metadata changes -- indirectly through either a zk
> callback
> > > or
> > > > > UpdateMetadataRequest, so it is completely possible the coordinator
> > > sees
> > > > > the topic metadata changes in batches, not all at once.
> > > > >
> > > >
> > > > > On Thu, Aug 13, 2015 at 10:50 PM, Neha Narkhede <neha@confluent.io
> >
> > > > wrote:
> > > > >
> > > > > > Ewen/Jason,
> > > > > >
> > > > > > The metadata hash is a clever approach and certainly addresses
> the
> > > > > problem
> > > > > > of large metadata for consumers like mirror maker. Few comments -
> > > > > >
> > > > > >
> > > > > >    1. In the interest of simplifying the format of the consumer's
> > > > > >    metadata - Why not just always include only the topic names in
> > the
> > > > > metadata
> > > > > >    followed by the metadata hash? If the metadata hash check
> > > succeeds,
> > > > > each
> > > > > >    consumer uses the # of partitions it had fetched. If it
> fails, a
> > > > > rebalance
> > > > > >    happens and the metadata is not used anyway.
> > > > >
> > > >
> > > > Doing this requires that every consumer always fetch the full
> metadata.
> > > The
> > > > most common use case is consumers that just want to consume one or a
> > > couple
> > > > of topics, in which case grabbing all metadata for the entire cluster
> > is
> > > > wasteful. If I subscribe only to topic A, why make all consumers grab
> > > > metadata for the entire topic (and need to rebalance every time it
> > > > changes!). Including the # of partitions for each topic lets you
> avoid
> > > > having to grab the global set of metadata.
> > > >
> > > > So if you're just subscribing to one or a couple of topics, why not
> > just
> > > > compute the hash by filtering out everything but the topics you are
> > > > subscribed to? The problem there is if you ever add/remove
> > subscriptions
> > > > and want to support rolling upgrades. If the group was subscribed to
> > > topic
> > > > A, but later changes require subscribing to A + B, then to achieve a
> > > > seamless rolling upgrade would require one (old) consumer to be
> > > subscribing
> > > > to A and one (new) consumer to be subscribing to A+B. If we computed
> > > > metadata hashes based on filtered metadata, those two would disagree
> > and
> > > we
> > > > could not perform assignment while the upgrade was in progress.
> > > >
> > > > The solution is to differentiate between the cases when a very small
> > > amount
> > > > of the metadata is needed (one or a couple of topic subscriptions;
> > > > communicate and share this via metadata in the JoinGroup protocol) vs
> > > when
> > > > *all* the metadata is needed (regex subscription; verify agreement
> via
> > > > hash).
> > > >
> > >
> > > >
> > > >
> > > > > >    2. Do you need a topic list and topic regex to be separate? A
> > > single
> > > > > >    topic or list of topics can be expressed as a regex.
> > > > >
> > > >
> > > > See above note about collecting all metadata when you really only
> need
> > it
> > > > for 1 or 2 topics. There's probably some debate to be had about
> whether
> > > > this cost would be too high -- every consumer would need to request
> the
> > > > metadata for all topics, and they'd need to request that all every
> time
> > > > they might be out of date.
> > > >
> > > Are we going to allow consumers in the same group to subscribe to
> > different
> > > topic set? If we do, we need to let them refresh metadata for all the
> > > topics a group is consuming from. If we don't then in the protocol we
> > only
> > > need a subscription set hash.
> > >
> > > >
> > > >
> > > > > >    3. Let's include a version explicitly at the beginning of the
> > > > > >    ProtocolMetadata. The version dictates how to deserialize the
> > > > > >    ProtocolMetadata blob and is consistent with the rest of
> Kafka.
> > > > >
> > > >
> > > > If I'm understanding correctly, in JoinGroupRequest I would change
> > > >
> > > > GroupProtocols          => [Protocol ProtocolMetadata]
> > > >
> > > > to
> > > >
> > > > GroupProtocols          => [Protocol ProtocolVersion
> ProtocolMetadata]
> > > >
> > > > We had been talking about just baking the version into the Protocol
> > > field,
> > > > but making it separate seems perfectly reasonable to me. Jason, any
> > issue
> > > > with splitting the version out into a separate field like this?
> > > >
> > > > >
> > > > > > That can simplify the metadata format to the following:
> > > > > >
> > > > > > GroupType => "consumer"
> > > > > >>
> > > > > >> Protocol => AssignmentStrategy
> > > > > >>   AssignmentStrategy   => String
> > > > > >>
> > > > > >> ProtocolMetadata => Version Subscription
> > AssignmentStrategyMetadata
> > > > > >
> > > > > >     Version                    => String
> > > > > >
> > > > > >   Subscription                 => TopicRegex MetadataHash
> > > > > >>     TopicRegex                 => String
> > > > > >>     MetadataHash               => String
> > > > > >>   AssignmentStrategyMetadata   => bytes
> > > > >
> > > > >
> > > > > >
> > > > > > On Thu, Aug 13, 2015 at 6:28 PM, Jiangjie Qin
> > > > <jqin@linkedin.com.invalid
> > > > > >
> > > > > > wrote:
> > > > > >
> > > > > >> Ewen and Jason,
> > > > > >>
> > > > > >> Thanks for the reply. Sorry I missed the metadata hash. Yes,
> that
> > > is a
> > > > > >> clever approach and would solve my concern about the data
> passing
> > > > > around.
> > > > > >> I
> > > > > >> can see both pros and cons from doing this, though. The
> advantage
> > is
> > > > we
> > > > > >> don't need the topic metadata in JoinGroupResponse anymore. The
> > > > downside
> > > > > >> is
> > > > > >> that now rebalance have extra dependency on the consensus of
> > > metadata
> > > > of
> > > > > >> all consumers, which is obtained separately. So it is required
> > that
> > > > each
> > > > > >> consumer refresh their metadata before sending a
> JoinGroupRequest,
> > > > > >> otherwise in some cases (e.g. wildcard consumers) will almost
> > > > certainly
> > > > > >> fail for the first rebalance attempt. Even if we do that, since
> > the
> > > > > >> consumers are getting metadata from different brokers, the
> > metadata
> > > > > might
> > > > > >> still be inconsistent if there is a topic or partition change
> > > because
> > > > > the
> > > > > >> UpdateMetadataRequest from controller might be handled at
> > different
> > > > > time.
> > > > > >> Just want to make sure we think through the cases so the
> protocol
> > > does
> > > > > not
> > > > > >> cause us unexpected issues.
> > > > > >>
> > > > > >> About the number of consumers, I think with the current
> liveliness
> > > > > >> definition, we can tolerate churns by bumping up the session
> > > timeout.
> > > > > Also
> > > > > >> I guess we will see an increasing number of consumers for new
> > > > consumer,
> > > > > >> because every the old consumer thread will probably become a
> > > consumer.
> > > > > >>
> > > > > >> It is a valid concern for consumers that have large subscription
> > > set.
> > > > > This
> > > > > >> might not be avoided though for client side assignment approach.
> > One
> > > > > >> solution is having topic names associate with a topic ID. And
> only
> > > use
> > > > > >> topic ID in JoinGroupRequest and JoinGroupResponse, There is a
> > > > > discussion
> > > > > >> thread about this to solve the topic renaming case but this is a
> > > > > >> completely
> > > > > >> different discussion.
> > > > > >>
> > > > > >> Thanks,
> > > > > >>
> > > > > >> Jiangjie (Becket) Qin
> > > > > >>
> > > > > >>
> > > > > >>
> > > > > >> On Thu, Aug 13, 2015 at 2:14 PM, Jason Gustafson <
> > > jason@confluent.io>
> > > > > >> wrote:
> > > > > >>
> > > > > >> > Thanks Jiangjie, that information helps. I agree the protocol
> > must
> > > > > >> consider
> > > > > >> > scalability. My point was that the synchronization barrier in
> > the
> > > > > >> current
> > > > > >> > protocol already effectively limits the number of consumers
> > since
> > > it
> > > > > >> > provides no way to gracefully handle churn. It wouldn't be
> worth
> > > > > >> worrying
> > > > > >> > about scaling up to 100,000 members, for example, because
> > there's
> > > no
> > > > > way
> > > > > >> > the group would be stable. So we just need to set some clear
> > > > > >> expectations
> > > > > >> > on the size we can scale to, and that can help inform the
> > > discussion
> > > > > on
> > > > > >> the
> > > > > >> > size of messages in this protocol.
> > > > > >> >
> > > > > >> > Ewen and I were discussing this morning along similar lines to
> > > what
> > > > > >> you're
> > > > > >> > suggesting. However, even if the coordinator decides on the
> > > metadata
> > > > > for
> > > > > >> > the group, each member still needs to communicate its
> > > subscriptions
> > > > to
> > > > > >> the
> > > > > >> > rest of the group. This is nice for the regex case since the
> > regex
> > > > is
> > > > > >> > probably small, but if the members have a large topic list,
> then
> > > we
> > > > > have
> > > > > >> > the same problem. One thing I was thinking about was whether
> we
> > > > really
> > > > > >> need
> > > > > >> > to handle different subscriptions for every member. If the
> > > > coordinator
> > > > > >> > could guarantee that all members had the same subscription,
> then
> > > > there
> > > > > >> > would be no need for the coordinator to return the
> subscriptions
> > > for
> > > > > >> each
> > > > > >> > member. However, this would prevent graceful upgrades. We
> might
> > be
> > > > > able
> > > > > >> to
> > > > > >> > fix that problem by allowing the consumer to provide two
> > > > subscriptions
> > > > > >> to
> > > > > >> > allowing rolling updates, but that starts to sound pretty
> nasty.
> > > > > >> >
> > > > > >> > -Jason
> > > > > >> >
> > > > > >> > On Thu, Aug 13, 2015 at 1:41 PM, Jiangjie Qin
> > > > > <jqin@linkedin.com.invalid
> > > > > >> >
> > > > > >> > wrote:
> > > > > >> >
> > > > > >> > > Jason,
> > > > > >> > >
> > > > > >> > > The protocol has to consider the scalability. The protocol
> in
> > > the
> > > > > wiki
> > > > > >> > > means the JoinGroupResoponse size would be:
> > > > > >> > > NumberOfTopics * (AvgTopicNameLength + 4) *
> > > (NumberOfConsumers)^2
> > > > > >> > >
> > > > > >> > > To give some real number, we have 26-node Mirror Maker
> > cluster,
> > > > each
> > > > > >> > with 4
> > > > > >> > > consumers. That is 104 consumers using regex ".*". And most
> of
> > > our
> > > > > >> > clusters
> > > > > >> > > have around 3000 topics, whose topic name are typically
> around
> > > 20
> > > > > >> > > characters.
> > > > > >> > >
> > > > > >> > > I think the key issue for client side partition assignment
> > logic
> > > > is
> > > > > to
> > > > > >> > make
> > > > > >> > > sure 1) all the clients run the same algorithm. 2) all the
> > > clients
> > > > > >> make
> > > > > >> > > decision on the same topic metadata. The second purpose can
> be
> > > > done
> > > > > by
> > > > > >> > > simply letting coordinator provide the topic metadata and
> all
> > > then
> > > > > >> member
> > > > > >> > > information as source of truth. Is it necessary to pass
> topic
> > > > > >> metadata of
> > > > > >> > > each consumer around? Can we keep the protocol metadata
> field
> > > > > >> completely
> > > > > >> > > independent of topic metadata? I think In the
> > JoinGroupResponse,
> > > > we
> > > > > >> > should
> > > > > >> > > have only one copy of topic metadata provided by coordinator
> > and
> > > > is
> > > > > >> > outside
> > > > > >> > > of protocol metadata. If user decides to put some metadata
> in
> > > the
> > > > > >> > > JoinGroupRequest and let coordinator pass around, they are
> > > > > responsible
> > > > > >> > for
> > > > > >> > > understanding the risk.
> > > > > >> > >
> > > > > >> > > Thanks,
> > > > > >> > >
> > > > > >> > > Jiangjie (Becket) Qin
> > > > > >> > >
> > > > > >> > >
> > > > > >> > > On Thu, Aug 13, 2015 at 12:41 PM, Jason Gustafson <
> > > > > jason@confluent.io
> > > > > >> >
> > > > > >> > > wrote:
> > > > > >> > >
> > > > > >> > > > Hey Onur and Jiangjie,
> > > > > >> > > >
> > > > > >> > > > I've updated that wiki with a proposal to add regex
> > > > subscriptions
> > > > > to
> > > > > >> > the
> > > > > >> > > > consumer metadata. Can you have a look to see if it
> > addresses
> > > > your
> > > > > >> > > concern?
> > > > > >> > > > In general, I think we should be a little careful when we
> > are
> > > > > >> talking
> > > > > >> > > about
> > > > > >> > > > the scalability of the protocol. Regardless of whether
> > > > assignment
> > > > > is
> > > > > >> > done
> > > > > >> > > > on the server or the client, the protocol assumes a
> > relatively
> > > > > >> stable
> > > > > >> > > > configuration. When the number of consumers increases
> > beyond a
> > > > > >> certain
> > > > > >> > > > limit, then membership churn becomes a major concern.
> > > Similarly
> > > > > >> there
> > > > > >> > is
> > > > > >> > > a
> > > > > >> > > > notion of metadata churn when topics are added, deleted,
> or
> > > > > >> resized. If
> > > > > >> > > > either membership or metadata changes, then the protocol
> > > forces
> > > > > all
> > > > > >> > > > consumers to stop consumption and rejoin the group. If
> this
> > > > > happens
> > > > > >> > often
> > > > > >> > > > enough, then it can severely impact the ability of the
> > > consumer
> > > > to
> > > > > >> make
> > > > > >> > > > progress. The point is that the protocol may already be
> > > unsuited
> > > > > to
> > > > > >> > cases
> > > > > >> > > > where there are either a large number of consumers or
> > topics.
> > > I
> > > > > >> wonder
> > > > > >> > if
> > > > > >> > > > you guys can share your thoughts about your scaling
> > > > expectations?
> > > > > >> > > >
> > > > > >> > > > -Jason
> > > > > >> > > >
> > > > > >> > > >
> > > > > >> > > >
> > > > > >> > > >
> > > > > >> > > > On Wed, Aug 12, 2015 at 12:28 PM, Jason Gustafson <
> > > > > >> jason@confluent.io>
> > > > > >> > > > wrote:
> > > > > >> > > >
> > > > > >> > > > > Hey Jiangjie,
> > > > > >> > > > >
> > > > > >> > > > > That's a great point. In the worst case (the mirror
> maker
> > > > case I
> > > > > >> > > guess),
> > > > > >> > > > > the join group response can be massive. This would be
> > > > especially
> > > > > >> > deadly
> > > > > >> > > > > when there is a lot of churn in the group (e.g. in a
> > rolling
> > > > > >> > upgrade).
> > > > > >> > > > The
> > > > > >> > > > > current protocol is not great for this case either, but
> > it's
> > > > > >> > > > significantly
> > > > > >> > > > > better. Here are a couple ways to deal with the size:
> > > > > >> > > > >
> > > > > >> > > > > 1. First, we could have the coordinator compress the
> > > > responses.
> > > > > >> This
> > > > > >> > > > would
> > > > > >> > > > > probably be pretty effective if applied across the
> > metadata
> > > > from
> > > > > >> all
> > > > > >> > > > > members.
> > > > > >> > > > >
> > > > > >> > > > > 2. I think the regex case is the main problem. Is that
> > > right?
> > > > We
> > > > > >> > could
> > > > > >> > > > > extend the metadata to allow the consumer to embed its
> > regex
> > > > > >> > > subscription
> > > > > >> > > > > in the metadata directly (note this might be a good idea
> > > > > >> regardless
> > > > > >> > of
> > > > > >> > > > the
> > > > > >> > > > > rest of this proposal). To support regex on the
> consumer,
> > we
> > > > > must
> > > > > >> > fetch
> > > > > >> > > > > metadata for all topics. Rather than having all regex
> > > > > subscribers
> > > > > >> > embed
> > > > > >> > > > all
> > > > > >> > > > > of this metadata in their join group requests, they
> could
> > > > > instead
> > > > > >> > > embed a
> > > > > >> > > > > hash of it. Then after the join group responses are
> > > received,
> > > > > they
> > > > > >> > just
> > > > > >> > > > > need to check that the hashes are the same. If there is
> a
> > > > > mismatch
> > > > > >> > > (which
> > > > > >> > > > > should only occur when topics are created, deleted, or
> > > > resized),
> > > > > >> then
> > > > > >> > > the
> > > > > >> > > > > group members must refetch the metadata and rejoin the
> > > group.
> > > > > >> This is
> > > > > >> > > > also
> > > > > >> > > > > how the current protocol behaves when there is a change
> in
> > > the
> > > > > >> topic
> > > > > >> > > > > metadata affecting the group--someone (either the
> > > coordinator
> > > > or
> > > > > >> the
> > > > > >> > > > > consumer) detects the change and forces the group to
> > > > rebalance.
> > > > > >> > > > >
> > > > > >> > > > > What do you think?
> > > > > >> > > > >
> > > > > >> > > > > (Also I think adding groupId/generationId to fetch and
> > > produce
> > > > > >> > requests
> > > > > >> > > > > seems like an interesting line of thought.)
> > > > > >> > > > >
> > > > > >> > > > > -Jason
> > > > > >> > > > >
> > > > > >> > > > >
> > > > > >> > > > >
> > > > > >> > > > > On Wed, Aug 12, 2015 at 10:57 AM, Jiangjie Qin
> > > > > >> > > <jqin@linkedin.com.invalid
> > > > > >> > > > >
> > > > > >> > > > > wrote:
> > > > > >> > > > >
> > > > > >> > > > >> Hey Ewen,
> > > > > >> > > > >>
> > > > > >> > > > >> Onur and I discussed this a little bit more. And we are
> > > still
> > > > > >> > worrying
> > > > > >> > > > >> about passing all the metadata of all consumers around.
> > > > > >> > > > >>
> > > > > >> > > > >> Let's say I have a cluster has 10,000 topics, the
> average
> > > > topic
> > > > > >> name
> > > > > >> > > > >> length
> > > > > >> > > > >> is 10 bytes. In this case, the opaque metadata will
> have
> > > 10 *
> > > > > >> > 10,000 =
> > > > > >> > > > >> 100KB for topic name, for each topic, there is a 4-byte
> > > > integer
> > > > > >> of
> > > > > >> > > > number
> > > > > >> > > > >> of partitions, that's another 40KB. So one global topic
> > > > > metadata
> > > > > >> > will
> > > > > >> > > > have
> > > > > >> > > > >> 140KB data. If I have 100 consumers who are using
> > wildcard
> > > to
> > > > > >> > consume
> > > > > >> > > > from
> > > > > >> > > > >> all the topics. That means the protocol metadata end up
> > in
> > > > the
> > > > > >> > > > >> JoinGroupResponse will be 140KB * 100 = 14MB. And the
> > > > > >> > > JoinGroupResponse
> > > > > >> > > > >> will need to be sent to 100 different consumers, that
> > means
> > > > > 14MB
> > > > > >> *
> > > > > >> > > 100 =
> > > > > >> > > > >> 1.4GB need to be sent by the consumer coordinator for
> one
> > > > > >> rebalance.
> > > > > >> > > How
> > > > > >> > > > >> would that work?
> > > > > >> > > > >>
> > > > > >> > > > >> Also, having two consumers (old owner and new owner)
> > > > consuming
> > > > > >> from
> > > > > >> > > the
> > > > > >> > > > >> same partition might also be a problem. e.g. people are
> > > > > updating
> > > > > >> > > > database.
> > > > > >> > > > >> One thing might worth doing is to add GroupId and
> > > Generation
> > > > ID
> > > > > >> to
> > > > > >> > > > >> ProducerRequest and FetchRequest as well. This will
> also
> > > help
> > > > > >> with
> > > > > >> > the
> > > > > >> > > > >> single producer use case. However, this is probably
> > > > orthogonal
> > > > > to
> > > > > >> > this
> > > > > >> > > > >> thread given the current new consumer also has this
> > problem
> > > > > and I
> > > > > >> > > > believe
> > > > > >> > > > >> we need to fix it.
> > > > > >> > > > >>
> > > > > >> > > > >> Thanks,
> > > > > >> > > > >>
> > > > > >> > > > >> Jiangjie (Becket) Qin
> > > > > >> > > > >>
> > > > > >> > > > >> On Tue, Aug 11, 2015 at 11:43 PM, Ewen
> Cheslack-Postava <
> > > > > >> > > > >> ewen@confluent.io>
> > > > > >> > > > >> wrote:
> > > > > >> > > > >>
> > > > > >> > > > >> > On Tue, Aug 11, 2015 at 11:29 PM, Jiangjie Qin
> > > > > >> > > > >> <jq...@linkedin.com.invalid>
> > > > > >> > > > >> > wrote:
> > > > > >> > > > >> >
> > > > > >> > > > >> > > Ewen,
> > > > > >> > > > >> > >
> > > > > >> > > > >> > > Thanks for the explanation.
> > > > > >> > > > >> > >
> > > > > >> > > > >> > > For (1), I am more concerned about the failure case
> > > > instead
> > > > > >> of
> > > > > >> > > > normal
> > > > > >> > > > >> > case.
> > > > > >> > > > >> > > What if a consumer somehow was kick out of a group
> > but
> > > is
> > > > > >> still
> > > > > >> > > > >> consuming
> > > > > >> > > > >> > > and committing offsets? Does that mean the new
> owner
> > > and
> > > > > old
> > > > > >> > owner
> > > > > >> > > > >> might
> > > > > >> > > > >> > > potentially consuming from and committing offsets
> for
> > > the
> > > > > >> same
> > > > > >> > > > >> partition?
> > > > > >> > > > >> > > In the old consumer, this won't happen because the
> > new
> > > > > >> consumer
> > > > > >> > > will
> > > > > >> > > > >> not
> > > > > >> > > > >> > be
> > > > > >> > > > >> > > able to start consumption unless the previous owner
> > has
> > > > > >> released
> > > > > >> > > its
> > > > > >> > > > >> > > ownership. Basically, without the ownership
> > guarantee,
> > > I
> > > > > >> don't
> > > > > >> > see
> > > > > >> > > > how
> > > > > >> > > > >> > the
> > > > > >> > > > >> > > communication among consumers themselves alone can
> > > solve
> > > > > the
> > > > > >> > > problem
> > > > > >> > > > >> > here.
> > > > > >> > > > >> > >
> > > > > >> > > > >> >
> > > > > >> > > > >> > The generation ID check still applies to offset
> > commits.
> > > If
> > > > > >> one of
> > > > > >> > > the
> > > > > >> > > > >> > consumers is kicked out and misbehaving, it can
> > obviously
> > > > > still
> > > > > >> > > fetch
> > > > > >> > > > >> and
> > > > > >> > > > >> > process messages, but offset commits will not work
> > since
> > > it
> > > > > >> will
> > > > > >> > not
> > > > > >> > > > >> have
> > > > > >> > > > >> > the current generation ID.
> > > > > >> > > > >> >
> > > > > >> > > > >> >
> > > > > >> > > > >> > >
> > > > > >> > > > >> > > For (2) and (3), now I understand how metadata are
> > > used.
> > > > > But
> > > > > >> I
> > > > > >> > > still
> > > > > >> > > > >> > don't
> > > > > >> > > > >> > > see why should we let the consumers to pass the
> topic
> > > > > >> > information
> > > > > >> > > > >> across
> > > > > >> > > > >> > > instead of letting coordinator give the
> information.
> > > The
> > > > > >> single
> > > > > >> > > > >> producer
> > > > > >> > > > >> > > use case does not solve the ownership problem in
> > > abnormal
> > > > > >> case
> > > > > >> > > > either,
> > > > > >> > > > >> > > which seems to be a little bit vulnerable.
> > > > > >> > > > >> > >
> > > > > >> > > > >> >
> > > > > >> > > > >> > One of the goals here was to generalize group
> > membership
> > > so
> > > > > we
> > > > > >> > can,
> > > > > >> > > > for
> > > > > >> > > > >> > example, use it for balancing Copycat tasks across
> > > workers.
> > > > > >> > There's
> > > > > >> > > no
> > > > > >> > > > >> > topic subscription info in that case. The metadata
> for
> > > > > copycat
> > > > > >> > > workers
> > > > > >> > > > >> > would instead need to somehow indicate the current
> set
> > of
> > > > > tasks
> > > > > >> > that
> > > > > >> > > > >> need
> > > > > >> > > > >> > to be assigned to workers. By making the metadata
> > > > completely
> > > > > >> > opaque
> > > > > >> > > to
> > > > > >> > > > >> the
> > > > > >> > > > >> > protocol, it becomes more generally useful since it
> > > focuses
> > > > > >> > squarely
> > > > > >> > > > on
> > > > > >> > > > >> the
> > > > > >> > > > >> > group membership problem, allowing for that
> additional
> > > bit
> > > > of
> > > > > >> > > metadata
> > > > > >> > > > >> so
> > > > > >> > > > >> > you don't just get a list of members, but also get a
> > > little
> > > > > >> bit of
> > > > > >> > > > info
> > > > > >> > > > >> > about each of them.
> > > > > >> > > > >> >
> > > > > >> > > > >> > A different option that we explored is to use a sort
> of
> > > > mixed
> > > > > >> > model
> > > > > >> > > --
> > > > > >> > > > >> > still bake all the topic subscriptions directly into
> > the
> > > > > >> protocol
> > > > > >> > > but
> > > > > >> > > > >> also
> > > > > >> > > > >> > include metadata. That would allow us to maintain the
> > > > > existing
> > > > > >> > > > >> > coordinator-driven approach to handling the metadata
> > and
> > > > > change
> > > > > >> > > events
> > > > > >> > > > >> like
> > > > > >> > > > >> > the ones Onur pointed out. Then something like the
> > > Copycat
> > > > > >> workers
> > > > > >> > > > would
> > > > > >> > > > >> > just not fill in any topic subscriptions and it would
> > be
> > > > > >> handled
> > > > > >> > as
> > > > > >> > > a
> > > > > >> > > > >> > degenerate case. Based on the way I explained that we
> > can
> > > > > >> handle
> > > > > >> > > those
> > > > > >> > > > >> > types of events, I personally feel its cleaner and a
> > > nicer
> > > > > >> > > > >> generalization
> > > > > >> > > > >> > to not include the subscriptions in the join group
> > > > protocol,
> > > > > >> > making
> > > > > >> > > it
> > > > > >> > > > >> part
> > > > > >> > > > >> > of the metadata instead.
> > > > > >> > > > >> >
> > > > > >> > > > >> > For the single producer case, are you saying it
> doesn't
> > > > solve
> > > > > >> > > > ownership
> > > > > >> > > > >> in
> > > > > >> > > > >> > the abnormal case because a producer that doesn't
> know
> > it
> > > > has
> > > > > >> been
> > > > > >> > > > >> kicked
> > > > > >> > > > >> > out of the group yet can still produce data even
> though
> > > it
> > > > > >> > shouldn't
> > > > > >> > > > be
> > > > > >> > > > >> > able to anymore? I definitely agree that that is a
> risk
> > > --
> > > > > this
> > > > > >> > > > >> provides a
> > > > > >> > > > >> > way to get closer to a true single-writer, but there
> > are
> > > > > >> > definitely
> > > > > >> > > > >> still
> > > > > >> > > > >> > failure modes that this does not address.
> > > > > >> > > > >> >
> > > > > >> > > > >> > -Ewen
> > > > > >> > > > >> >
> > > > > >> > > > >> >
> > > > > >> > > > >> > >
> > > > > >> > > > >> > > Thanks,
> > > > > >> > > > >> > >
> > > > > >> > > > >> > > Jiangjie (Becket) Qin
> > > > > >> > > > >> > >
> > > > > >> > > > >> > >
> > > > > >> > > > >> > > On Tue, Aug 11, 2015 at 11:06 PM, Ewen
> > > Cheslack-Postava <
> > > > > >> > > > >> > ewen@confluent.io
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > wrote:
> > > > > >> > > > >> > >
> > > > > >> > > > >> > > > On Tue, Aug 11, 2015 at 10:15 PM, Jiangjie Qin
> > > > > >> > > > >> > <jqin@linkedin.com.invalid
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > wrote:
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > > Hi Jason,
> > > > > >> > > > >> > > > >
> > > > > >> > > > >> > > > > Thanks for writing this up. It would be useful
> to
> > > > > >> generalize
> > > > > >> > > the
> > > > > >> > > > >> > group
> > > > > >> > > > >> > > > > concept. I have a few questions below.
> > > > > >> > > > >> > > > >
> > > > > >> > > > >> > > > > 1. In old consumer actually the partition
> > > assignment
> > > > > are
> > > > > >> > done
> > > > > >> > > by
> > > > > >> > > > >> > > > consumers
> > > > > >> > > > >> > > > > themselves. We used zookeeper to guarantee
> that a
> > > > > >> partition
> > > > > >> > > will
> > > > > >> > > > >> only
> > > > > >> > > > >> > > be
> > > > > >> > > > >> > > > > consumed by one consumer thread who
> successfully
> > > > > claimed
> > > > > >> its
> > > > > >> > > > >> > ownership.
> > > > > >> > > > >> > > > > Does the new protocol plan to provide the same
> > > > > guarantee?
> > > > > >> > > > >> > > > >
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > Once you have all the metadata from all the
> > > consumers,
> > > > > >> > > assignment
> > > > > >> > > > >> > should
> > > > > >> > > > >> > > > just be a simple function mapping that
> > > Map<ConsumerId,
> > > > > >> > Metadata>
> > > > > >> > > > to
> > > > > >> > > > >> > > > Map<ConsumerId, List<TopicPartition>>. If
> everyone
> > is
> > > > > >> > consistent
> > > > > >> > > > in
> > > > > >> > > > >> > > > computing that, you don't need ZK involved at
> all.
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > In practice, this shouldn't be that hard to
> ensure
> > > for
> > > > > most
> > > > > >> > > > >> assignment
> > > > > >> > > > >> > > > strategies just by having decent unit testing on
> > > them.
> > > > > You
> > > > > >> > just
> > > > > >> > > > >> have to
> > > > > >> > > > >> > > do
> > > > > >> > > > >> > > > things like ensure your assignment strategy sorts
> > > lists
> > > > > >> into a
> > > > > >> > > > >> > consistent
> > > > > >> > > > >> > > > order.
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > You do give up the ability to use some techniques
> > > (e.g.
> > > > > any
> > > > > >> > > > >> randomized
> > > > > >> > > > >> > > > algorithm if you can't distribute the seed w/ the
> > > > > metadata)
> > > > > >> > and
> > > > > >> > > > it's
> > > > > >> > > > >> > true
> > > > > >> > > > >> > > > that nothing validates the assignment, but if
> that
> > > > > >> assignment
> > > > > >> > > > >> algorithm
> > > > > >> > > > >> > > > step is kept simple, small, and well tested, the
> > risk
> > > > is
> > > > > >> very
> > > > > >> > > > >> minimal.
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > >
> > > > > >> > > > >> > > > > 2. It looks that both JoinGroupRequest and
> > > > > >> JoinGroupResponse
> > > > > >> > > has
> > > > > >> > > > >> the
> > > > > >> > > > >> > > > > ProtocolMetadata.AssignmentStrategyMetadata,
> what
> > > > would
> > > > > >> be
> > > > > >> > the
> > > > > >> > > > >> > metadata
> > > > > >> > > > >> > > > be
> > > > > >> > > > >> > > > > sent and returned by coordinator? How will the
> > > > > >> coordinator
> > > > > >> > > > handle
> > > > > >> > > > >> the
> > > > > >> > > > >> > > > > metadata?
> > > > > >> > > > >> > > > >
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > The coordinator is basically just blindly
> > > broadcasting
> > > > > all
> > > > > >> of
> > > > > >> > it
> > > > > >> > > > to
> > > > > >> > > > >> > group
> > > > > >> > > > >> > > > members so they have a consistent view.
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > So from the coordinators perspective, it sees
> > > something
> > > > > >> like:
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > Consumer 1 -> JoinGroupRequest with
> GroupProtocols
> > =
> > > [
> > > > > >> > > "consumer"
> > > > > >> > > > >> > > > <Consumer1 opaque byte[]>]
> > > > > >> > > > >> > > > Consumer 2 -> JoinGroupRequest with
> GroupProtocols
> > =
> > > [
> > > > > >> > > "consumer"
> > > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > Then, in the responses would look like:
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > Consumer 1 <- JoinGroupResponse with
> GroupProtocol
> > =
> > > > > >> > "consumer"
> > > > > >> > > > and
> > > > > >> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque
> > > byte[]>,
> > > > > >> > Consumer
> > > > > >> > > 2
> > > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > > >> > > > >> > > > Consumer 2 <- JoinGroupResponse with
> GroupProtocol
> > =
> > > > > >> > "consumer"
> > > > > >> > > > and
> > > > > >> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque
> > > byte[]>,
> > > > > >> > Consumer
> > > > > >> > > 2
> > > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > So all the responses include all the metadata for
> > > every
> > > > > >> member
> > > > > >> > > in
> > > > > >> > > > >> the
> > > > > >> > > > >> > > > group, and everyone can use that to consistently
> > > decide
> > > > > on
> > > > > >> > > > >> assignment.
> > > > > >> > > > >> > > The
> > > > > >> > > > >> > > > broker doesn't care and cannot even understand
> the
> > > > > metadata
> > > > > >> > > since
> > > > > >> > > > >> the
> > > > > >> > > > >> > > data
> > > > > >> > > > >> > > > format for it is dependent on the assignment
> > strategy
> > > > > being
> > > > > >> > > used.
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > As another example that is *not* a consumer,
> let's
> > > say
> > > > > you
> > > > > >> > just
> > > > > >> > > > >> want to
> > > > > >> > > > >> > > > have a single writer in the group which everyone
> > will
> > > > > >> forward
> > > > > >> > > > >> requests
> > > > > >> > > > >> > > to.
> > > > > >> > > > >> > > > To accomplish this, you could use a very dumb
> > > > assignment
> > > > > >> > > strategy:
> > > > > >> > > > >> > there
> > > > > >> > > > >> > > is
> > > > > >> > > > >> > > > no metadata (empty byte[]) and all we care about
> is
> > > who
> > > > > is
> > > > > >> the
> > > > > >> > > > first
> > > > > >> > > > >> > > member
> > > > > >> > > > >> > > > in the group (e.g. when IDs are sorted
> > > > > lexicographically).
> > > > > >> > That
> > > > > >> > > > >> member
> > > > > >> > > > >> > is
> > > > > >> > > > >> > > > selected as the writer. In that case, we actually
> > > just
> > > > > care
> > > > > >> > > about
> > > > > >> > > > >> the
> > > > > >> > > > >> > > > membership list, there's no additional info about
> > > each
> > > > > >> member
> > > > > >> > > that
> > > > > >> > > > >> is
> > > > > >> > > > >> > > > required to determine who is the writer.
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > > 3. Do you mean that the number of partitions in
> > > > > >> > > > JoinGroupResponse
> > > > > >> > > > >> > will
> > > > > >> > > > >> > > be
> > > > > >> > > > >> > > > > the max partition number of a topic among all
> the
> > > > > >> reported
> > > > > >> > > > >> partition
> > > > > >> > > > >> > > > number
> > > > > >> > > > >> > > > > by consumers? Is there any reason not just let
> > > > > >> Coordinator
> > > > > >> > to
> > > > > >> > > > >> return
> > > > > >> > > > >> > > the
> > > > > >> > > > >> > > > > number of partitions of a topic in its metadata
> > > > cache?
> > > > > >> > > > >> > > > >
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > Nothing from the embedded protocol is touched by
> > the
> > > > > >> broker.
> > > > > >> > The
> > > > > >> > > > >> broker
> > > > > >> > > > >> > > > just collects opaque bytes of metadata, does the
> > > > > selection
> > > > > >> of
> > > > > >> > > the
> > > > > >> > > > >> > > strategy
> > > > > >> > > > >> > > > if multiple are supported by some consumers, and
> > then
> > > > > >> returns
> > > > > >> > > that
> > > > > >> > > > >> > opaque
> > > > > >> > > > >> > > > metadata for all the members back to every
> member.
> > In
> > > > > that
> > > > > >> way
> > > > > >> > > > they
> > > > > >> > > > >> all
> > > > > >> > > > >> > > > have a consistent view of the group. For regular
> > > > > consumers,
> > > > > >> > that
> > > > > >> > > > >> view
> > > > > >> > > > >> > of
> > > > > >> > > > >> > > > the group includes information about how many
> > > > partitions
> > > > > >> each
> > > > > >> > > > >> consumer
> > > > > >> > > > >> > > > currently thinks the topics it is subscribed to
> > has.
> > > > > These
> > > > > >> > could
> > > > > >> > > > be
> > > > > >> > > > >> > > > inconsistent due to out of date metadata and it
> > would
> > > > be
> > > > > >> up to
> > > > > >> > > the
> > > > > >> > > > >> > > > assignment strategy on the *client* to resolve
> > that.
> > > As
> > > > > you
> > > > > >> > > point
> > > > > >> > > > >> out,
> > > > > >> > > > >> > in
> > > > > >> > > > >> > > > that case they could just take the max value that
> > any
> > > > > >> consumer
> > > > > >> > > > >> reported
> > > > > >> > > > >> > > > seeing and use that. The consumers that notice
> that
> > > > their
> > > > > >> > > metadata
> > > > > >> > > > >> had
> > > > > >> > > > >> > a
> > > > > >> > > > >> > > > smaller # of partitions should also trigger a
> > > metadata
> > > > > >> update
> > > > > >> > > when
> > > > > >> > > > >> they
> > > > > >> > > > >> > > see
> > > > > >> > > > >> > > > someone else observing a larger # of partitions.
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > >
> > > > > >> > > > >> > > > > Thanks,
> > > > > >> > > > >> > > > >
> > > > > >> > > > >> > > > > Jiangjie (Becket) Qin
> > > > > >> > > > >> > > > >
> > > > > >> > > > >> > > > >
> > > > > >> > > > >> > > > >
> > > > > >> > > > >> > > > >
> > > > > >> > > > >> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason
> Gustafson
> > <
> > > > > >> > > > >> jason@confluent.io
> > > > > >> > > > >> > >
> > > > > >> > > > >> > > > > wrote:
> > > > > >> > > > >> > > > >
> > > > > >> > > > >> > > > > > Hi Kafka Devs,
> > > > > >> > > > >> > > > > >
> > > > > >> > > > >> > > > > > One of the nagging issues in the current
> design
> > > of
> > > > > the
> > > > > >> new
> > > > > >> > > > >> consumer
> > > > > >> > > > >> > > has
> > > > > >> > > > >> > > > > > been the need to support a variety of
> > assignment
> > > > > >> > strategies.
> > > > > >> > > > >> We've
> > > > > >> > > > >> > > > > > encountered this in particular in the design
> of
> > > > > copycat
> > > > > >> > and
> > > > > >> > > > the
> > > > > >> > > > >> > > > > processing
> > > > > >> > > > >> > > > > > framework (KIP-28). From what I understand,
> > Samza
> > > > > also
> > > > > >> > has a
> > > > > >> > > > >> number
> > > > > >> > > > >> > > of
> > > > > >> > > > >> > > > > use
> > > > > >> > > > >> > > > > > cases with custom assignment needs. The new
> > > > consumer
> > > > > >> > > protocol
> > > > > >> > > > >> > > supports
> > > > > >> > > > >> > > > > new
> > > > > >> > > > >> > > > > > assignment strategies by hooking them into
> the
> > > > > broker.
> > > > > >> For
> > > > > >> > > > many
> > > > > >> > > > >> > > > > > environments, this is a major pain and in
> some
> > > > > cases, a
> > > > > >> > > > >> > non-starter.
> > > > > >> > > > >> > > It
> > > > > >> > > > >> > > > > > also challenges the validation that the
> > > coordinator
> > > > > can
> > > > > >> > > > provide.
> > > > > >> > > > >> > For
> > > > > >> > > > >> > > > > > example, some assignment strategies call for
> > > > > >> partitions to
> > > > > >> > > be
> > > > > >> > > > >> > > assigned
> > > > > >> > > > >> > > > > > multiple times, which means that the
> > coordinator
> > > > can
> > > > > >> only
> > > > > >> > > > check
> > > > > >> > > > >> > that
> > > > > >> > > > >> > > > > > partitions have been assigned at least once.
> > > > > >> > > > >> > > > > >
> > > > > >> > > > >> > > > > > To solve these issues, we'd like to propose
> > > moving
> > > > > >> > > assignment
> > > > > >> > > > to
> > > > > >> > > > >> > the
> > > > > >> > > > >> > > > > > client. I've written a wiki which outlines
> some
> > > > > >> protocol
> > > > > >> > > > >> changes to
> > > > > >> > > > >> > > > > achieve
> > > > > >> > > > >> > > > > > this:
> > > > > >> > > > >> > > > > >
> > > > > >> > > > >> > > > > >
> > > > > >> > > > >> > > > >
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > >
> > > > > >> > > > >> >
> > > > > >> > > > >>
> > > > > >> > > >
> > > > > >> > >
> > > > > >> >
> > > > > >>
> > > > >
> > > >
> > >
> >
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> > > > > >> > > > >> > > > > > .
> > > > > >> > > > >> > > > > > To summarize briefly, instead of the
> > coordinator
> > > > > >> assigning
> > > > > >> > > the
> > > > > >> > > > >> > > > partitions
> > > > > >> > > > >> > > > > > itself, all subscriptions are forwarded to
> each
> > > > > member
> > > > > >> of
> > > > > >> > > the
> > > > > >> > > > >> group
> > > > > >> > > > >> > > > which
> > > > > >> > > > >> > > > > > then decides independently which partitions
> it
> > > > should
> > > > > >> > > consume.
> > > > > >> > > > >> The
> > > > > >> > > > >> > > > > protocol
> > > > > >> > > > >> > > > > > provides a mechanism for the coordinator to
> > > > validate
> > > > > >> that
> > > > > >> > > all
> > > > > >> > > > >> > > consumers
> > > > > >> > > > >> > > > > use
> > > > > >> > > > >> > > > > > the same assignment strategy, but it does not
> > > > ensure
> > > > > >> that
> > > > > >> > > the
> > > > > >> > > > >> > > resulting
> > > > > >> > > > >> > > > > > assignment is "correct." This provides a
> > powerful
> > > > > >> > capability
> > > > > >> > > > for
> > > > > >> > > > >> > > users
> > > > > >> > > > >> > > > to
> > > > > >> > > > >> > > > > > control the full data flow on the client
> side.
> > > They
> > > > > >> > control
> > > > > >> > > > how
> > > > > >> > > > >> > data
> > > > > >> > > > >> > > is
> > > > > >> > > > >> > > > > > written to partitions through the Partitioner
> > > > > interface
> > > > > >> > and
> > > > > >> > > > they
> > > > > >> > > > >> > > > control
> > > > > >> > > > >> > > > > > how data is consumed through the assignment
> > > > strategy,
> > > > > >> all
> > > > > >> > > > >> without
> > > > > >> > > > >> > > > > touching
> > > > > >> > > > >> > > > > > the server.
> > > > > >> > > > >> > > > > >
> > > > > >> > > > >> > > > > > Of course nothing comes for free. In
> > particular,
> > > > this
> > > > > >> > change
> > > > > >> > > > >> > removes
> > > > > >> > > > >> > > > the
> > > > > >> > > > >> > > > > > ability of the coordinator to validate that
> > > commits
> > > > > are
> > > > > >> > made
> > > > > >> > > > by
> > > > > >> > > > >> > > > consumers
> > > > > >> > > > >> > > > > > who were assigned the respective partition.
> > This
> > > > > might
> > > > > >> not
> > > > > >> > > be
> > > > > >> > > > >> too
> > > > > >> > > > >> > bad
> > > > > >> > > > >> > > > > since
> > > > > >> > > > >> > > > > > we retain the ability to validate the
> > generation
> > > > id,
> > > > > >> but
> > > > > >> > it
> > > > > >> > > > is a
> > > > > >> > > > >> > > > > potential
> > > > > >> > > > >> > > > > > concern. We have considered alternative
> > protocols
> > > > > which
> > > > > >> > add
> > > > > >> > > a
> > > > > >> > > > >> > second
> > > > > >> > > > >> > > > > > round-trip to the protocol in order to give
> the
> > > > > >> > coordinator
> > > > > >> > > > the
> > > > > >> > > > >> > > ability
> > > > > >> > > > >> > > > > to
> > > > > >> > > > >> > > > > > confirm the assignment. As mentioned above,
> the
> > > > > >> > coordinator
> > > > > >> > > is
> > > > > >> > > > >> > > somewhat
> > > > > >> > > > >> > > > > > limited in what it can actually validate, but
> > > this
> > > > > >> would
> > > > > >> > > > return
> > > > > >> > > > >> its
> > > > > >> > > > >> > > > > ability
> > > > > >> > > > >> > > > > > to validate commits. The tradeoff is that it
> > > > > increases
> > > > > >> the
> > > > > >> > > > >> > protocol's
> > > > > >> > > > >> > > > > > complexity which means more ways for the
> > protocol
> > > > to
> > > > > >> fail
> > > > > >> > > and
> > > > > >> > > > >> > > > > consequently
> > > > > >> > > > >> > > > > > more edge cases in the code.
> > > > > >> > > > >> > > > > >
> > > > > >> > > > >> > > > > > It also misses an opportunity to generalize
> the
> > > > group
> > > > > >> > > > membership
> > > > > >> > > > >> > > > protocol
> > > > > >> > > > >> > > > > > for additional use cases. In fact, after
> you've
> > > > gone
> > > > > to
> > > > > >> > the
> > > > > >> > > > >> trouble
> > > > > >> > > > >> > > of
> > > > > >> > > > >> > > > > > moving assignment to the client, the main
> thing
> > > > that
> > > > > is
> > > > > >> > left
> > > > > >> > > > in
> > > > > >> > > > >> > this
> > > > > >> > > > >> > > > > > protocol is basically a general group
> > management
> > > > > >> > capability.
> > > > > >> > > > >> This
> > > > > >> > > > >> > is
> > > > > >> > > > >> > > > > > exactly what is needed for a few cases that
> are
> > > > > >> currently
> > > > > >> > > > under
> > > > > >> > > > >> > > > > discussion
> > > > > >> > > > >> > > > > > (e.g. copycat or single-writer producer).
> We've
> > > > taken
> > > > > >> this
> > > > > >> > > > >> further
> > > > > >> > > > >> > > step
> > > > > >> > > > >> > > > > in
> > > > > >> > > > >> > > > > > the proposal and attempted to envision what
> > that
> > > > > >> general
> > > > > >> > > > >> protocol
> > > > > >> > > > >> > > might
> > > > > >> > > > >> > > > > > look like and how it could be used both by
> the
> > > > > consumer
> > > > > >> > and
> > > > > >> > > > for
> > > > > >> > > > >> > some
> > > > > >> > > > >> > > of
> > > > > >> > > > >> > > > > > these other cases.
> > > > > >> > > > >> > > > > >
> > > > > >> > > > >> > > > > > Anyway, since time is running out on the new
> > > > > consumer,
> > > > > >> we
> > > > > >> > > have
> > > > > >> > > > >> > > perhaps
> > > > > >> > > > >> > > > > one
> > > > > >> > > > >> > > > > > last chance to consider a significant change
> in
> > > the
> > > > > >> > protocol
> > > > > >> > > > >> like
> > > > > >> > > > >> > > this,
> > > > > >> > > > >> > > > > so
> > > > > >> > > > >> > > > > > have a look at the wiki and share your
> > thoughts.
> > > > I've
> > > > > >> no
> > > > > >> > > doubt
> > > > > >> > > > >> that
> > > > > >> > > > >> > > > some
> > > > > >> > > > >> > > > > > ideas seem clearer in my mind than they do on
> > > > paper,
> > > > > so
> > > > > >> > ask
> > > > > >> > > > >> > questions
> > > > > >> > > > >> > > > if
> > > > > >> > > > >> > > > > > there is any confusion.
> > > > > >> > > > >> > > > > >
> > > > > >> > > > >> > > > > > Thanks!
> > > > > >> > > > >> > > > > > Jason
> > > > > >> > > > >> > > > > >
> > > > > >> > > > >> > > > >
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > > > --
> > > > > >> > > > >> > > > Thanks,
> > > > > >> > > > >> > > > Ewen
> > > > > >> > > > >> > > >
> > > > > >> > > > >> > >
> > > > > >> > > > >> >
> > > > > >> > > > >> >
> > > > > >> > > > >> >
> > > > > >> > > > >> > --
> > > > > >> > > > >> > Thanks,
> > > > > >> > > > >> > Ewen
> > > > > >> > > > >> >
> > > > > >> > > > >>
> > > > > >> > > > >
> > > > > >> > > > >
> > > > > >> > > >
> > > > > >> > >
> > > > > >> >
> > > > > >>
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Thanks,
> > > > > > Neha
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Thanks,
> > > > > Neha
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Thanks,
> > > > Ewen
> > > >
> > >
> >
> >
> >
> > --
> > Thanks,
> > Ewen
> >
>
>
>
> --
> Thanks,
> Neha
>

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Neha Narkhede <ne...@confluent.io>.
>
> So if you're just subscribing to one or a couple of topics, why not just
> compute the hash by filtering out everything but the topics you are
> subscribed to? The problem there is if you ever add/remove subscriptions
> and want to support rolling upgrades. If the group was subscribed to topic
> A, but later changes require subscribing to A + B, then to achieve a
> seamless rolling upgrade would require one (old) consumer to be subscribing
> to A and one (new) consumer to be subscribing to A+B. If we computed
> metadata hashes based on filtered metadata, those two would disagree and we
> could not perform assignment while the upgrade was in progress.


When I suggested including just the metadata hash, I didn't mean for all
topics in the cluster but just the topics the consumer wants to subscribe
to. I understand that it temporarily halts consumption while the topic
subscription changes but the question is whether we want to support
consumer groups with members that have different subscription preferences.
This came up during various discussions and the general consensus was that
we couldn't come up with compelling reasons to allow that. Upgrades are one
but then the question is how many upgrades would involve letting some
instances subscribe to a different set of topics for a long period of time
as against a simple rolling upgrade.

I'm questioning the value of allowing the flexibility of variation in
consumer group topic subscriptions while trading off simplicity of the
consumer metadata format. The latter is important given the variety of
non-java consumer clients that need to exist and evolve with this change.

Becket,

If # of partitions or topic metadata changes, whether the coordinator
handles it or the consumer, there will be rebalance attempts until the
changes subside.

Thanks,
Neha

On Fri, Aug 14, 2015 at 12:57 PM, Ewen Cheslack-Postava <ew...@confluent.io>
wrote:

> On Fri, Aug 14, 2015 at 10:59 AM, Jiangjie Qin <jq...@linkedin.com.invalid>
> wrote:
>
> > Neha and Ewen,
> >
> > About the metadata change frequency. I guess it really depends on how
> > frequent the metadata change might occur. If we run Kafka as a service, I
> > can see that happens from time to time. As I can imagine people will
> create
> > some topic, test and maybe delete the topic in some automated test. If
> so,
> > the proposed protocol might be a little bit vulnerable.
> >
> > More specifically the scenario I am thinking is:
> > 1. Consumer 0 periodically refresh metadata and detected a metadata
> change.
> > So it sends a JoinGroupRequest with metadata_hash_0.
> > 2. Consumer 1 was notified by controller to start a rebalance, so it
> > refreshes its metadata and send a JoingGroupRequest with metadata_hash_1,
> > which is different from metadata hash 0.
> > 3. Rebalance failed and both consumer refresh there metadata again from
> > different brokers.
> > 4. Depending on the metadata change frequency(or some admin operation
> like
> > partition reassigment), they may or may not have the same metadata
> > returned, so the restart from 3 again.
> >
> > I agree that step 4 might not be a big concern if consumers updates
> > metadata at almost the same time, but I'm a little bit worried whether
> that
> > assumption really stands because we do not have control over how frequent
> > the metadata can change.
> >
> >
> Is this really that different from what would happen if the coordinator
> distributed the metadata to consumers? In that case you would trivially
> have everyone in a consistent state, but those metadata changes would still
> cause churn and require JoinGroup rounds, during which processing is
> stalled for the nodes that are waiting on other members to re-join the
> group.
>
> -Ewen
>
>
> > Thanks,
> >
> > Jiangjie (Becket) Qin
> >
> > On Fri, Aug 14, 2015 at 2:03 AM, Ewen Cheslack-Postava <
> ewen@confluent.io>
> > wrote:
> >
> > > On Thu, Aug 13, 2015 at 11:07 PM, Neha Narkhede <ne...@confluent.io>
> > wrote:
> > >
> > > > Becket,
> > > >
> > > > As you say, the metadata hash addresses the concern you originally
> > raised
> > > > about large topic subscriptions. Can you please list other problems
> you
> > > are
> > > > raising more clearly? It is more helpful to know problems that the
> > > proposal
> > > > does not address or addresses poorly.
> > > >
> > > > Regarding other things you said -
> > > >
> > > > it is required that each
> > > > > consumer refresh their metadata before sending a JoinGroupRequest
> > > > >
> > > >
> > > > This is required for wildcard topic subscriptions anyway. So this
> > > proposal
> > > > does not introduce a regression. We had agreed earlier that it does
> not
> > > > make sense for the server to deserialize regular expressions sent by
> > the
> > > > consumer.
> > > >
> > >
> > > I don't think consumers need to do a metadata refresh before sending a
> > > JoinGroupRequest. Metadata changes that affect assignment are rare --
> it
> > > requires changing the number of partitions in a topic. But you might
> > send a
> > > JoinGroupRequest simply because a new member is trying to join the
> group.
> > > That case is presumably much more common.
> > >
> > > I think it's actually a good idea to have the first JoinGroup cycle
> fail
> > in
> > > some cases, and has little impact. Lets say the metadata does change
> > > because partitions are added. Then we might fail in the first round,
> but
> > > then all members detect that issue *immediately*, refresh their
> metadata,
> > > and submit a new join group request. This second cycle does not
> require a
> > > full heartbeat cycle. It happens much more quickly because everyone
> > > detected the inconsistency based on the first JoinGroupResponse. The
> > > inconsistency should be resolved very quickly (barring other failures
> > like
> > > a member leaving mid-rebalance)
> >
> >
> >
> >
> > > >
> > > >
> > > > > the metadata might still be inconsistent if there is a topic or
> > > partition
> > > > > change because the
> > > > > UpdateMetadataRequest from controller might be handled at different
> > > time.
> > > > >
> > > >
> > > > Topic metadata does not change frequently and even if it did, a
> couple
> > > > rebalance attempts will be needed whether the coordinator drives the
> > > > assignments or the consumer. Because guess how the coordinator knows
> > > about
> > > > the topic metadata changes -- indirectly through either a zk callback
> > or
> > > > UpdateMetadataRequest, so it is completely possible the coordinator
> > sees
> > > > the topic metadata changes in batches, not all at once.
> > > >
> > >
> > > > On Thu, Aug 13, 2015 at 10:50 PM, Neha Narkhede <ne...@confluent.io>
> > > wrote:
> > > >
> > > > > Ewen/Jason,
> > > > >
> > > > > The metadata hash is a clever approach and certainly addresses the
> > > > problem
> > > > > of large metadata for consumers like mirror maker. Few comments -
> > > > >
> > > > >
> > > > >    1. In the interest of simplifying the format of the consumer's
> > > > >    metadata - Why not just always include only the topic names in
> the
> > > > metadata
> > > > >    followed by the metadata hash? If the metadata hash check
> > succeeds,
> > > > each
> > > > >    consumer uses the # of partitions it had fetched. If it fails, a
> > > > rebalance
> > > > >    happens and the metadata is not used anyway.
> > > >
> > >
> > > Doing this requires that every consumer always fetch the full metadata.
> > The
> > > most common use case is consumers that just want to consume one or a
> > couple
> > > of topics, in which case grabbing all metadata for the entire cluster
> is
> > > wasteful. If I subscribe only to topic A, why make all consumers grab
> > > metadata for the entire topic (and need to rebalance every time it
> > > changes!). Including the # of partitions for each topic lets you avoid
> > > having to grab the global set of metadata.
> > >
> > > So if you're just subscribing to one or a couple of topics, why not
> just
> > > compute the hash by filtering out everything but the topics you are
> > > subscribed to? The problem there is if you ever add/remove
> subscriptions
> > > and want to support rolling upgrades. If the group was subscribed to
> > topic
> > > A, but later changes require subscribing to A + B, then to achieve a
> > > seamless rolling upgrade would require one (old) consumer to be
> > subscribing
> > > to A and one (new) consumer to be subscribing to A+B. If we computed
> > > metadata hashes based on filtered metadata, those two would disagree
> and
> > we
> > > could not perform assignment while the upgrade was in progress.
> > >
> > > The solution is to differentiate between the cases when a very small
> > amount
> > > of the metadata is needed (one or a couple of topic subscriptions;
> > > communicate and share this via metadata in the JoinGroup protocol) vs
> > when
> > > *all* the metadata is needed (regex subscription; verify agreement via
> > > hash).
> > >
> >
> > >
> > >
> > > > >    2. Do you need a topic list and topic regex to be separate? A
> > single
> > > > >    topic or list of topics can be expressed as a regex.
> > > >
> > >
> > > See above note about collecting all metadata when you really only need
> it
> > > for 1 or 2 topics. There's probably some debate to be had about whether
> > > this cost would be too high -- every consumer would need to request the
> > > metadata for all topics, and they'd need to request that all every time
> > > they might be out of date.
> > >
> > Are we going to allow consumers in the same group to subscribe to
> different
> > topic set? If we do, we need to let them refresh metadata for all the
> > topics a group is consuming from. If we don't then in the protocol we
> only
> > need a subscription set hash.
> >
> > >
> > >
> > > > >    3. Let's include a version explicitly at the beginning of the
> > > > >    ProtocolMetadata. The version dictates how to deserialize the
> > > > >    ProtocolMetadata blob and is consistent with the rest of Kafka.
> > > >
> > >
> > > If I'm understanding correctly, in JoinGroupRequest I would change
> > >
> > > GroupProtocols          => [Protocol ProtocolMetadata]
> > >
> > > to
> > >
> > > GroupProtocols          => [Protocol ProtocolVersion ProtocolMetadata]
> > >
> > > We had been talking about just baking the version into the Protocol
> > field,
> > > but making it separate seems perfectly reasonable to me. Jason, any
> issue
> > > with splitting the version out into a separate field like this?
> > >
> > > >
> > > > > That can simplify the metadata format to the following:
> > > > >
> > > > > GroupType => "consumer"
> > > > >>
> > > > >> Protocol => AssignmentStrategy
> > > > >>   AssignmentStrategy   => String
> > > > >>
> > > > >> ProtocolMetadata => Version Subscription
> AssignmentStrategyMetadata
> > > > >
> > > > >     Version                    => String
> > > > >
> > > > >   Subscription                 => TopicRegex MetadataHash
> > > > >>     TopicRegex                 => String
> > > > >>     MetadataHash               => String
> > > > >>   AssignmentStrategyMetadata   => bytes
> > > >
> > > >
> > > > >
> > > > > On Thu, Aug 13, 2015 at 6:28 PM, Jiangjie Qin
> > > <jqin@linkedin.com.invalid
> > > > >
> > > > > wrote:
> > > > >
> > > > >> Ewen and Jason,
> > > > >>
> > > > >> Thanks for the reply. Sorry I missed the metadata hash. Yes, that
> > is a
> > > > >> clever approach and would solve my concern about the data passing
> > > > around.
> > > > >> I
> > > > >> can see both pros and cons from doing this, though. The advantage
> is
> > > we
> > > > >> don't need the topic metadata in JoinGroupResponse anymore. The
> > > downside
> > > > >> is
> > > > >> that now rebalance have extra dependency on the consensus of
> > metadata
> > > of
> > > > >> all consumers, which is obtained separately. So it is required
> that
> > > each
> > > > >> consumer refresh their metadata before sending a JoinGroupRequest,
> > > > >> otherwise in some cases (e.g. wildcard consumers) will almost
> > > certainly
> > > > >> fail for the first rebalance attempt. Even if we do that, since
> the
> > > > >> consumers are getting metadata from different brokers, the
> metadata
> > > > might
> > > > >> still be inconsistent if there is a topic or partition change
> > because
> > > > the
> > > > >> UpdateMetadataRequest from controller might be handled at
> different
> > > > time.
> > > > >> Just want to make sure we think through the cases so the protocol
> > does
> > > > not
> > > > >> cause us unexpected issues.
> > > > >>
> > > > >> About the number of consumers, I think with the current liveliness
> > > > >> definition, we can tolerate churns by bumping up the session
> > timeout.
> > > > Also
> > > > >> I guess we will see an increasing number of consumers for new
> > > consumer,
> > > > >> because every the old consumer thread will probably become a
> > consumer.
> > > > >>
> > > > >> It is a valid concern for consumers that have large subscription
> > set.
> > > > This
> > > > >> might not be avoided though for client side assignment approach.
> One
> > > > >> solution is having topic names associate with a topic ID. And only
> > use
> > > > >> topic ID in JoinGroupRequest and JoinGroupResponse, There is a
> > > > discussion
> > > > >> thread about this to solve the topic renaming case but this is a
> > > > >> completely
> > > > >> different discussion.
> > > > >>
> > > > >> Thanks,
> > > > >>
> > > > >> Jiangjie (Becket) Qin
> > > > >>
> > > > >>
> > > > >>
> > > > >> On Thu, Aug 13, 2015 at 2:14 PM, Jason Gustafson <
> > jason@confluent.io>
> > > > >> wrote:
> > > > >>
> > > > >> > Thanks Jiangjie, that information helps. I agree the protocol
> must
> > > > >> consider
> > > > >> > scalability. My point was that the synchronization barrier in
> the
> > > > >> current
> > > > >> > protocol already effectively limits the number of consumers
> since
> > it
> > > > >> > provides no way to gracefully handle churn. It wouldn't be worth
> > > > >> worrying
> > > > >> > about scaling up to 100,000 members, for example, because
> there's
> > no
> > > > way
> > > > >> > the group would be stable. So we just need to set some clear
> > > > >> expectations
> > > > >> > on the size we can scale to, and that can help inform the
> > discussion
> > > > on
> > > > >> the
> > > > >> > size of messages in this protocol.
> > > > >> >
> > > > >> > Ewen and I were discussing this morning along similar lines to
> > what
> > > > >> you're
> > > > >> > suggesting. However, even if the coordinator decides on the
> > metadata
> > > > for
> > > > >> > the group, each member still needs to communicate its
> > subscriptions
> > > to
> > > > >> the
> > > > >> > rest of the group. This is nice for the regex case since the
> regex
> > > is
> > > > >> > probably small, but if the members have a large topic list, then
> > we
> > > > have
> > > > >> > the same problem. One thing I was thinking about was whether we
> > > really
> > > > >> need
> > > > >> > to handle different subscriptions for every member. If the
> > > coordinator
> > > > >> > could guarantee that all members had the same subscription, then
> > > there
> > > > >> > would be no need for the coordinator to return the subscriptions
> > for
> > > > >> each
> > > > >> > member. However, this would prevent graceful upgrades. We might
> be
> > > > able
> > > > >> to
> > > > >> > fix that problem by allowing the consumer to provide two
> > > subscriptions
> > > > >> to
> > > > >> > allowing rolling updates, but that starts to sound pretty nasty.
> > > > >> >
> > > > >> > -Jason
> > > > >> >
> > > > >> > On Thu, Aug 13, 2015 at 1:41 PM, Jiangjie Qin
> > > > <jqin@linkedin.com.invalid
> > > > >> >
> > > > >> > wrote:
> > > > >> >
> > > > >> > > Jason,
> > > > >> > >
> > > > >> > > The protocol has to consider the scalability. The protocol in
> > the
> > > > wiki
> > > > >> > > means the JoinGroupResoponse size would be:
> > > > >> > > NumberOfTopics * (AvgTopicNameLength + 4) *
> > (NumberOfConsumers)^2
> > > > >> > >
> > > > >> > > To give some real number, we have 26-node Mirror Maker
> cluster,
> > > each
> > > > >> > with 4
> > > > >> > > consumers. That is 104 consumers using regex ".*". And most of
> > our
> > > > >> > clusters
> > > > >> > > have around 3000 topics, whose topic name are typically around
> > 20
> > > > >> > > characters.
> > > > >> > >
> > > > >> > > I think the key issue for client side partition assignment
> logic
> > > is
> > > > to
> > > > >> > make
> > > > >> > > sure 1) all the clients run the same algorithm. 2) all the
> > clients
> > > > >> make
> > > > >> > > decision on the same topic metadata. The second purpose can be
> > > done
> > > > by
> > > > >> > > simply letting coordinator provide the topic metadata and all
> > then
> > > > >> member
> > > > >> > > information as source of truth. Is it necessary to pass topic
> > > > >> metadata of
> > > > >> > > each consumer around? Can we keep the protocol metadata field
> > > > >> completely
> > > > >> > > independent of topic metadata? I think In the
> JoinGroupResponse,
> > > we
> > > > >> > should
> > > > >> > > have only one copy of topic metadata provided by coordinator
> and
> > > is
> > > > >> > outside
> > > > >> > > of protocol metadata. If user decides to put some metadata in
> > the
> > > > >> > > JoinGroupRequest and let coordinator pass around, they are
> > > > responsible
> > > > >> > for
> > > > >> > > understanding the risk.
> > > > >> > >
> > > > >> > > Thanks,
> > > > >> > >
> > > > >> > > Jiangjie (Becket) Qin
> > > > >> > >
> > > > >> > >
> > > > >> > > On Thu, Aug 13, 2015 at 12:41 PM, Jason Gustafson <
> > > > jason@confluent.io
> > > > >> >
> > > > >> > > wrote:
> > > > >> > >
> > > > >> > > > Hey Onur and Jiangjie,
> > > > >> > > >
> > > > >> > > > I've updated that wiki with a proposal to add regex
> > > subscriptions
> > > > to
> > > > >> > the
> > > > >> > > > consumer metadata. Can you have a look to see if it
> addresses
> > > your
> > > > >> > > concern?
> > > > >> > > > In general, I think we should be a little careful when we
> are
> > > > >> talking
> > > > >> > > about
> > > > >> > > > the scalability of the protocol. Regardless of whether
> > > assignment
> > > > is
> > > > >> > done
> > > > >> > > > on the server or the client, the protocol assumes a
> relatively
> > > > >> stable
> > > > >> > > > configuration. When the number of consumers increases
> beyond a
> > > > >> certain
> > > > >> > > > limit, then membership churn becomes a major concern.
> > Similarly
> > > > >> there
> > > > >> > is
> > > > >> > > a
> > > > >> > > > notion of metadata churn when topics are added, deleted, or
> > > > >> resized. If
> > > > >> > > > either membership or metadata changes, then the protocol
> > forces
> > > > all
> > > > >> > > > consumers to stop consumption and rejoin the group. If this
> > > > happens
> > > > >> > often
> > > > >> > > > enough, then it can severely impact the ability of the
> > consumer
> > > to
> > > > >> make
> > > > >> > > > progress. The point is that the protocol may already be
> > unsuited
> > > > to
> > > > >> > cases
> > > > >> > > > where there are either a large number of consumers or
> topics.
> > I
> > > > >> wonder
> > > > >> > if
> > > > >> > > > you guys can share your thoughts about your scaling
> > > expectations?
> > > > >> > > >
> > > > >> > > > -Jason
> > > > >> > > >
> > > > >> > > >
> > > > >> > > >
> > > > >> > > >
> > > > >> > > > On Wed, Aug 12, 2015 at 12:28 PM, Jason Gustafson <
> > > > >> jason@confluent.io>
> > > > >> > > > wrote:
> > > > >> > > >
> > > > >> > > > > Hey Jiangjie,
> > > > >> > > > >
> > > > >> > > > > That's a great point. In the worst case (the mirror maker
> > > case I
> > > > >> > > guess),
> > > > >> > > > > the join group response can be massive. This would be
> > > especially
> > > > >> > deadly
> > > > >> > > > > when there is a lot of churn in the group (e.g. in a
> rolling
> > > > >> > upgrade).
> > > > >> > > > The
> > > > >> > > > > current protocol is not great for this case either, but
> it's
> > > > >> > > > significantly
> > > > >> > > > > better. Here are a couple ways to deal with the size:
> > > > >> > > > >
> > > > >> > > > > 1. First, we could have the coordinator compress the
> > > responses.
> > > > >> This
> > > > >> > > > would
> > > > >> > > > > probably be pretty effective if applied across the
> metadata
> > > from
> > > > >> all
> > > > >> > > > > members.
> > > > >> > > > >
> > > > >> > > > > 2. I think the regex case is the main problem. Is that
> > right?
> > > We
> > > > >> > could
> > > > >> > > > > extend the metadata to allow the consumer to embed its
> regex
> > > > >> > > subscription
> > > > >> > > > > in the metadata directly (note this might be a good idea
> > > > >> regardless
> > > > >> > of
> > > > >> > > > the
> > > > >> > > > > rest of this proposal). To support regex on the consumer,
> we
> > > > must
> > > > >> > fetch
> > > > >> > > > > metadata for all topics. Rather than having all regex
> > > > subscribers
> > > > >> > embed
> > > > >> > > > all
> > > > >> > > > > of this metadata in their join group requests, they could
> > > > instead
> > > > >> > > embed a
> > > > >> > > > > hash of it. Then after the join group responses are
> > received,
> > > > they
> > > > >> > just
> > > > >> > > > > need to check that the hashes are the same. If there is a
> > > > mismatch
> > > > >> > > (which
> > > > >> > > > > should only occur when topics are created, deleted, or
> > > resized),
> > > > >> then
> > > > >> > > the
> > > > >> > > > > group members must refetch the metadata and rejoin the
> > group.
> > > > >> This is
> > > > >> > > > also
> > > > >> > > > > how the current protocol behaves when there is a change in
> > the
> > > > >> topic
> > > > >> > > > > metadata affecting the group--someone (either the
> > coordinator
> > > or
> > > > >> the
> > > > >> > > > > consumer) detects the change and forces the group to
> > > rebalance.
> > > > >> > > > >
> > > > >> > > > > What do you think?
> > > > >> > > > >
> > > > >> > > > > (Also I think adding groupId/generationId to fetch and
> > produce
> > > > >> > requests
> > > > >> > > > > seems like an interesting line of thought.)
> > > > >> > > > >
> > > > >> > > > > -Jason
> > > > >> > > > >
> > > > >> > > > >
> > > > >> > > > >
> > > > >> > > > > On Wed, Aug 12, 2015 at 10:57 AM, Jiangjie Qin
> > > > >> > > <jqin@linkedin.com.invalid
> > > > >> > > > >
> > > > >> > > > > wrote:
> > > > >> > > > >
> > > > >> > > > >> Hey Ewen,
> > > > >> > > > >>
> > > > >> > > > >> Onur and I discussed this a little bit more. And we are
> > still
> > > > >> > worrying
> > > > >> > > > >> about passing all the metadata of all consumers around.
> > > > >> > > > >>
> > > > >> > > > >> Let's say I have a cluster has 10,000 topics, the average
> > > topic
> > > > >> name
> > > > >> > > > >> length
> > > > >> > > > >> is 10 bytes. In this case, the opaque metadata will have
> > 10 *
> > > > >> > 10,000 =
> > > > >> > > > >> 100KB for topic name, for each topic, there is a 4-byte
> > > integer
> > > > >> of
> > > > >> > > > number
> > > > >> > > > >> of partitions, that's another 40KB. So one global topic
> > > > metadata
> > > > >> > will
> > > > >> > > > have
> > > > >> > > > >> 140KB data. If I have 100 consumers who are using
> wildcard
> > to
> > > > >> > consume
> > > > >> > > > from
> > > > >> > > > >> all the topics. That means the protocol metadata end up
> in
> > > the
> > > > >> > > > >> JoinGroupResponse will be 140KB * 100 = 14MB. And the
> > > > >> > > JoinGroupResponse
> > > > >> > > > >> will need to be sent to 100 different consumers, that
> means
> > > > 14MB
> > > > >> *
> > > > >> > > 100 =
> > > > >> > > > >> 1.4GB need to be sent by the consumer coordinator for one
> > > > >> rebalance.
> > > > >> > > How
> > > > >> > > > >> would that work?
> > > > >> > > > >>
> > > > >> > > > >> Also, having two consumers (old owner and new owner)
> > > consuming
> > > > >> from
> > > > >> > > the
> > > > >> > > > >> same partition might also be a problem. e.g. people are
> > > > updating
> > > > >> > > > database.
> > > > >> > > > >> One thing might worth doing is to add GroupId and
> > Generation
> > > ID
> > > > >> to
> > > > >> > > > >> ProducerRequest and FetchRequest as well. This will also
> > help
> > > > >> with
> > > > >> > the
> > > > >> > > > >> single producer use case. However, this is probably
> > > orthogonal
> > > > to
> > > > >> > this
> > > > >> > > > >> thread given the current new consumer also has this
> problem
> > > > and I
> > > > >> > > > believe
> > > > >> > > > >> we need to fix it.
> > > > >> > > > >>
> > > > >> > > > >> Thanks,
> > > > >> > > > >>
> > > > >> > > > >> Jiangjie (Becket) Qin
> > > > >> > > > >>
> > > > >> > > > >> On Tue, Aug 11, 2015 at 11:43 PM, Ewen Cheslack-Postava <
> > > > >> > > > >> ewen@confluent.io>
> > > > >> > > > >> wrote:
> > > > >> > > > >>
> > > > >> > > > >> > On Tue, Aug 11, 2015 at 11:29 PM, Jiangjie Qin
> > > > >> > > > >> <jq...@linkedin.com.invalid>
> > > > >> > > > >> > wrote:
> > > > >> > > > >> >
> > > > >> > > > >> > > Ewen,
> > > > >> > > > >> > >
> > > > >> > > > >> > > Thanks for the explanation.
> > > > >> > > > >> > >
> > > > >> > > > >> > > For (1), I am more concerned about the failure case
> > > instead
> > > > >> of
> > > > >> > > > normal
> > > > >> > > > >> > case.
> > > > >> > > > >> > > What if a consumer somehow was kick out of a group
> but
> > is
> > > > >> still
> > > > >> > > > >> consuming
> > > > >> > > > >> > > and committing offsets? Does that mean the new owner
> > and
> > > > old
> > > > >> > owner
> > > > >> > > > >> might
> > > > >> > > > >> > > potentially consuming from and committing offsets for
> > the
> > > > >> same
> > > > >> > > > >> partition?
> > > > >> > > > >> > > In the old consumer, this won't happen because the
> new
> > > > >> consumer
> > > > >> > > will
> > > > >> > > > >> not
> > > > >> > > > >> > be
> > > > >> > > > >> > > able to start consumption unless the previous owner
> has
> > > > >> released
> > > > >> > > its
> > > > >> > > > >> > > ownership. Basically, without the ownership
> guarantee,
> > I
> > > > >> don't
> > > > >> > see
> > > > >> > > > how
> > > > >> > > > >> > the
> > > > >> > > > >> > > communication among consumers themselves alone can
> > solve
> > > > the
> > > > >> > > problem
> > > > >> > > > >> > here.
> > > > >> > > > >> > >
> > > > >> > > > >> >
> > > > >> > > > >> > The generation ID check still applies to offset
> commits.
> > If
> > > > >> one of
> > > > >> > > the
> > > > >> > > > >> > consumers is kicked out and misbehaving, it can
> obviously
> > > > still
> > > > >> > > fetch
> > > > >> > > > >> and
> > > > >> > > > >> > process messages, but offset commits will not work
> since
> > it
> > > > >> will
> > > > >> > not
> > > > >> > > > >> have
> > > > >> > > > >> > the current generation ID.
> > > > >> > > > >> >
> > > > >> > > > >> >
> > > > >> > > > >> > >
> > > > >> > > > >> > > For (2) and (3), now I understand how metadata are
> > used.
> > > > But
> > > > >> I
> > > > >> > > still
> > > > >> > > > >> > don't
> > > > >> > > > >> > > see why should we let the consumers to pass the topic
> > > > >> > information
> > > > >> > > > >> across
> > > > >> > > > >> > > instead of letting coordinator give the information.
> > The
> > > > >> single
> > > > >> > > > >> producer
> > > > >> > > > >> > > use case does not solve the ownership problem in
> > abnormal
> > > > >> case
> > > > >> > > > either,
> > > > >> > > > >> > > which seems to be a little bit vulnerable.
> > > > >> > > > >> > >
> > > > >> > > > >> >
> > > > >> > > > >> > One of the goals here was to generalize group
> membership
> > so
> > > > we
> > > > >> > can,
> > > > >> > > > for
> > > > >> > > > >> > example, use it for balancing Copycat tasks across
> > workers.
> > > > >> > There's
> > > > >> > > no
> > > > >> > > > >> > topic subscription info in that case. The metadata for
> > > > copycat
> > > > >> > > workers
> > > > >> > > > >> > would instead need to somehow indicate the current set
> of
> > > > tasks
> > > > >> > that
> > > > >> > > > >> need
> > > > >> > > > >> > to be assigned to workers. By making the metadata
> > > completely
> > > > >> > opaque
> > > > >> > > to
> > > > >> > > > >> the
> > > > >> > > > >> > protocol, it becomes more generally useful since it
> > focuses
> > > > >> > squarely
> > > > >> > > > on
> > > > >> > > > >> the
> > > > >> > > > >> > group membership problem, allowing for that additional
> > bit
> > > of
> > > > >> > > metadata
> > > > >> > > > >> so
> > > > >> > > > >> > you don't just get a list of members, but also get a
> > little
> > > > >> bit of
> > > > >> > > > info
> > > > >> > > > >> > about each of them.
> > > > >> > > > >> >
> > > > >> > > > >> > A different option that we explored is to use a sort of
> > > mixed
> > > > >> > model
> > > > >> > > --
> > > > >> > > > >> > still bake all the topic subscriptions directly into
> the
> > > > >> protocol
> > > > >> > > but
> > > > >> > > > >> also
> > > > >> > > > >> > include metadata. That would allow us to maintain the
> > > > existing
> > > > >> > > > >> > coordinator-driven approach to handling the metadata
> and
> > > > change
> > > > >> > > events
> > > > >> > > > >> like
> > > > >> > > > >> > the ones Onur pointed out. Then something like the
> > Copycat
> > > > >> workers
> > > > >> > > > would
> > > > >> > > > >> > just not fill in any topic subscriptions and it would
> be
> > > > >> handled
> > > > >> > as
> > > > >> > > a
> > > > >> > > > >> > degenerate case. Based on the way I explained that we
> can
> > > > >> handle
> > > > >> > > those
> > > > >> > > > >> > types of events, I personally feel its cleaner and a
> > nicer
> > > > >> > > > >> generalization
> > > > >> > > > >> > to not include the subscriptions in the join group
> > > protocol,
> > > > >> > making
> > > > >> > > it
> > > > >> > > > >> part
> > > > >> > > > >> > of the metadata instead.
> > > > >> > > > >> >
> > > > >> > > > >> > For the single producer case, are you saying it doesn't
> > > solve
> > > > >> > > > ownership
> > > > >> > > > >> in
> > > > >> > > > >> > the abnormal case because a producer that doesn't know
> it
> > > has
> > > > >> been
> > > > >> > > > >> kicked
> > > > >> > > > >> > out of the group yet can still produce data even though
> > it
> > > > >> > shouldn't
> > > > >> > > > be
> > > > >> > > > >> > able to anymore? I definitely agree that that is a risk
> > --
> > > > this
> > > > >> > > > >> provides a
> > > > >> > > > >> > way to get closer to a true single-writer, but there
> are
> > > > >> > definitely
> > > > >> > > > >> still
> > > > >> > > > >> > failure modes that this does not address.
> > > > >> > > > >> >
> > > > >> > > > >> > -Ewen
> > > > >> > > > >> >
> > > > >> > > > >> >
> > > > >> > > > >> > >
> > > > >> > > > >> > > Thanks,
> > > > >> > > > >> > >
> > > > >> > > > >> > > Jiangjie (Becket) Qin
> > > > >> > > > >> > >
> > > > >> > > > >> > >
> > > > >> > > > >> > > On Tue, Aug 11, 2015 at 11:06 PM, Ewen
> > Cheslack-Postava <
> > > > >> > > > >> > ewen@confluent.io
> > > > >> > > > >> > > >
> > > > >> > > > >> > > wrote:
> > > > >> > > > >> > >
> > > > >> > > > >> > > > On Tue, Aug 11, 2015 at 10:15 PM, Jiangjie Qin
> > > > >> > > > >> > <jqin@linkedin.com.invalid
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > wrote:
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > > Hi Jason,
> > > > >> > > > >> > > > >
> > > > >> > > > >> > > > > Thanks for writing this up. It would be useful to
> > > > >> generalize
> > > > >> > > the
> > > > >> > > > >> > group
> > > > >> > > > >> > > > > concept. I have a few questions below.
> > > > >> > > > >> > > > >
> > > > >> > > > >> > > > > 1. In old consumer actually the partition
> > assignment
> > > > are
> > > > >> > done
> > > > >> > > by
> > > > >> > > > >> > > > consumers
> > > > >> > > > >> > > > > themselves. We used zookeeper to guarantee that a
> > > > >> partition
> > > > >> > > will
> > > > >> > > > >> only
> > > > >> > > > >> > > be
> > > > >> > > > >> > > > > consumed by one consumer thread who successfully
> > > > claimed
> > > > >> its
> > > > >> > > > >> > ownership.
> > > > >> > > > >> > > > > Does the new protocol plan to provide the same
> > > > guarantee?
> > > > >> > > > >> > > > >
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > Once you have all the metadata from all the
> > consumers,
> > > > >> > > assignment
> > > > >> > > > >> > should
> > > > >> > > > >> > > > just be a simple function mapping that
> > Map<ConsumerId,
> > > > >> > Metadata>
> > > > >> > > > to
> > > > >> > > > >> > > > Map<ConsumerId, List<TopicPartition>>. If everyone
> is
> > > > >> > consistent
> > > > >> > > > in
> > > > >> > > > >> > > > computing that, you don't need ZK involved at all.
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > In practice, this shouldn't be that hard to ensure
> > for
> > > > most
> > > > >> > > > >> assignment
> > > > >> > > > >> > > > strategies just by having decent unit testing on
> > them.
> > > > You
> > > > >> > just
> > > > >> > > > >> have to
> > > > >> > > > >> > > do
> > > > >> > > > >> > > > things like ensure your assignment strategy sorts
> > lists
> > > > >> into a
> > > > >> > > > >> > consistent
> > > > >> > > > >> > > > order.
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > You do give up the ability to use some techniques
> > (e.g.
> > > > any
> > > > >> > > > >> randomized
> > > > >> > > > >> > > > algorithm if you can't distribute the seed w/ the
> > > > metadata)
> > > > >> > and
> > > > >> > > > it's
> > > > >> > > > >> > true
> > > > >> > > > >> > > > that nothing validates the assignment, but if that
> > > > >> assignment
> > > > >> > > > >> algorithm
> > > > >> > > > >> > > > step is kept simple, small, and well tested, the
> risk
> > > is
> > > > >> very
> > > > >> > > > >> minimal.
> > > > >> > > > >> > > >
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > >
> > > > >> > > > >> > > > > 2. It looks that both JoinGroupRequest and
> > > > >> JoinGroupResponse
> > > > >> > > has
> > > > >> > > > >> the
> > > > >> > > > >> > > > > ProtocolMetadata.AssignmentStrategyMetadata, what
> > > would
> > > > >> be
> > > > >> > the
> > > > >> > > > >> > metadata
> > > > >> > > > >> > > > be
> > > > >> > > > >> > > > > sent and returned by coordinator? How will the
> > > > >> coordinator
> > > > >> > > > handle
> > > > >> > > > >> the
> > > > >> > > > >> > > > > metadata?
> > > > >> > > > >> > > > >
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > The coordinator is basically just blindly
> > broadcasting
> > > > all
> > > > >> of
> > > > >> > it
> > > > >> > > > to
> > > > >> > > > >> > group
> > > > >> > > > >> > > > members so they have a consistent view.
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > So from the coordinators perspective, it sees
> > something
> > > > >> like:
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > Consumer 1 -> JoinGroupRequest with GroupProtocols
> =
> > [
> > > > >> > > "consumer"
> > > > >> > > > >> > > > <Consumer1 opaque byte[]>]
> > > > >> > > > >> > > > Consumer 2 -> JoinGroupRequest with GroupProtocols
> =
> > [
> > > > >> > > "consumer"
> > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > Then, in the responses would look like:
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > Consumer 1 <- JoinGroupResponse with GroupProtocol
> =
> > > > >> > "consumer"
> > > > >> > > > and
> > > > >> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque
> > byte[]>,
> > > > >> > Consumer
> > > > >> > > 2
> > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > >> > > > >> > > > Consumer 2 <- JoinGroupResponse with GroupProtocol
> =
> > > > >> > "consumer"
> > > > >> > > > and
> > > > >> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque
> > byte[]>,
> > > > >> > Consumer
> > > > >> > > 2
> > > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > So all the responses include all the metadata for
> > every
> > > > >> member
> > > > >> > > in
> > > > >> > > > >> the
> > > > >> > > > >> > > > group, and everyone can use that to consistently
> > decide
> > > > on
> > > > >> > > > >> assignment.
> > > > >> > > > >> > > The
> > > > >> > > > >> > > > broker doesn't care and cannot even understand the
> > > > metadata
> > > > >> > > since
> > > > >> > > > >> the
> > > > >> > > > >> > > data
> > > > >> > > > >> > > > format for it is dependent on the assignment
> strategy
> > > > being
> > > > >> > > used.
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > As another example that is *not* a consumer, let's
> > say
> > > > you
> > > > >> > just
> > > > >> > > > >> want to
> > > > >> > > > >> > > > have a single writer in the group which everyone
> will
> > > > >> forward
> > > > >> > > > >> requests
> > > > >> > > > >> > > to.
> > > > >> > > > >> > > > To accomplish this, you could use a very dumb
> > > assignment
> > > > >> > > strategy:
> > > > >> > > > >> > there
> > > > >> > > > >> > > is
> > > > >> > > > >> > > > no metadata (empty byte[]) and all we care about is
> > who
> > > > is
> > > > >> the
> > > > >> > > > first
> > > > >> > > > >> > > member
> > > > >> > > > >> > > > in the group (e.g. when IDs are sorted
> > > > lexicographically).
> > > > >> > That
> > > > >> > > > >> member
> > > > >> > > > >> > is
> > > > >> > > > >> > > > selected as the writer. In that case, we actually
> > just
> > > > care
> > > > >> > > about
> > > > >> > > > >> the
> > > > >> > > > >> > > > membership list, there's no additional info about
> > each
> > > > >> member
> > > > >> > > that
> > > > >> > > > >> is
> > > > >> > > > >> > > > required to determine who is the writer.
> > > > >> > > > >> > > >
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > > 3. Do you mean that the number of partitions in
> > > > >> > > > JoinGroupResponse
> > > > >> > > > >> > will
> > > > >> > > > >> > > be
> > > > >> > > > >> > > > > the max partition number of a topic among all the
> > > > >> reported
> > > > >> > > > >> partition
> > > > >> > > > >> > > > number
> > > > >> > > > >> > > > > by consumers? Is there any reason not just let
> > > > >> Coordinator
> > > > >> > to
> > > > >> > > > >> return
> > > > >> > > > >> > > the
> > > > >> > > > >> > > > > number of partitions of a topic in its metadata
> > > cache?
> > > > >> > > > >> > > > >
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > Nothing from the embedded protocol is touched by
> the
> > > > >> broker.
> > > > >> > The
> > > > >> > > > >> broker
> > > > >> > > > >> > > > just collects opaque bytes of metadata, does the
> > > > selection
> > > > >> of
> > > > >> > > the
> > > > >> > > > >> > > strategy
> > > > >> > > > >> > > > if multiple are supported by some consumers, and
> then
> > > > >> returns
> > > > >> > > that
> > > > >> > > > >> > opaque
> > > > >> > > > >> > > > metadata for all the members back to every member.
> In
> > > > that
> > > > >> way
> > > > >> > > > they
> > > > >> > > > >> all
> > > > >> > > > >> > > > have a consistent view of the group. For regular
> > > > consumers,
> > > > >> > that
> > > > >> > > > >> view
> > > > >> > > > >> > of
> > > > >> > > > >> > > > the group includes information about how many
> > > partitions
> > > > >> each
> > > > >> > > > >> consumer
> > > > >> > > > >> > > > currently thinks the topics it is subscribed to
> has.
> > > > These
> > > > >> > could
> > > > >> > > > be
> > > > >> > > > >> > > > inconsistent due to out of date metadata and it
> would
> > > be
> > > > >> up to
> > > > >> > > the
> > > > >> > > > >> > > > assignment strategy on the *client* to resolve
> that.
> > As
> > > > you
> > > > >> > > point
> > > > >> > > > >> out,
> > > > >> > > > >> > in
> > > > >> > > > >> > > > that case they could just take the max value that
> any
> > > > >> consumer
> > > > >> > > > >> reported
> > > > >> > > > >> > > > seeing and use that. The consumers that notice that
> > > their
> > > > >> > > metadata
> > > > >> > > > >> had
> > > > >> > > > >> > a
> > > > >> > > > >> > > > smaller # of partitions should also trigger a
> > metadata
> > > > >> update
> > > > >> > > when
> > > > >> > > > >> they
> > > > >> > > > >> > > see
> > > > >> > > > >> > > > someone else observing a larger # of partitions.
> > > > >> > > > >> > > >
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > >
> > > > >> > > > >> > > > > Thanks,
> > > > >> > > > >> > > > >
> > > > >> > > > >> > > > > Jiangjie (Becket) Qin
> > > > >> > > > >> > > > >
> > > > >> > > > >> > > > >
> > > > >> > > > >> > > > >
> > > > >> > > > >> > > > >
> > > > >> > > > >> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson
> <
> > > > >> > > > >> jason@confluent.io
> > > > >> > > > >> > >
> > > > >> > > > >> > > > > wrote:
> > > > >> > > > >> > > > >
> > > > >> > > > >> > > > > > Hi Kafka Devs,
> > > > >> > > > >> > > > > >
> > > > >> > > > >> > > > > > One of the nagging issues in the current design
> > of
> > > > the
> > > > >> new
> > > > >> > > > >> consumer
> > > > >> > > > >> > > has
> > > > >> > > > >> > > > > > been the need to support a variety of
> assignment
> > > > >> > strategies.
> > > > >> > > > >> We've
> > > > >> > > > >> > > > > > encountered this in particular in the design of
> > > > copycat
> > > > >> > and
> > > > >> > > > the
> > > > >> > > > >> > > > > processing
> > > > >> > > > >> > > > > > framework (KIP-28). From what I understand,
> Samza
> > > > also
> > > > >> > has a
> > > > >> > > > >> number
> > > > >> > > > >> > > of
> > > > >> > > > >> > > > > use
> > > > >> > > > >> > > > > > cases with custom assignment needs. The new
> > > consumer
> > > > >> > > protocol
> > > > >> > > > >> > > supports
> > > > >> > > > >> > > > > new
> > > > >> > > > >> > > > > > assignment strategies by hooking them into the
> > > > broker.
> > > > >> For
> > > > >> > > > many
> > > > >> > > > >> > > > > > environments, this is a major pain and in some
> > > > cases, a
> > > > >> > > > >> > non-starter.
> > > > >> > > > >> > > It
> > > > >> > > > >> > > > > > also challenges the validation that the
> > coordinator
> > > > can
> > > > >> > > > provide.
> > > > >> > > > >> > For
> > > > >> > > > >> > > > > > example, some assignment strategies call for
> > > > >> partitions to
> > > > >> > > be
> > > > >> > > > >> > > assigned
> > > > >> > > > >> > > > > > multiple times, which means that the
> coordinator
> > > can
> > > > >> only
> > > > >> > > > check
> > > > >> > > > >> > that
> > > > >> > > > >> > > > > > partitions have been assigned at least once.
> > > > >> > > > >> > > > > >
> > > > >> > > > >> > > > > > To solve these issues, we'd like to propose
> > moving
> > > > >> > > assignment
> > > > >> > > > to
> > > > >> > > > >> > the
> > > > >> > > > >> > > > > > client. I've written a wiki which outlines some
> > > > >> protocol
> > > > >> > > > >> changes to
> > > > >> > > > >> > > > > achieve
> > > > >> > > > >> > > > > > this:
> > > > >> > > > >> > > > > >
> > > > >> > > > >> > > > > >
> > > > >> > > > >> > > > >
> > > > >> > > > >> > > >
> > > > >> > > > >> > >
> > > > >> > > > >> >
> > > > >> > > > >>
> > > > >> > > >
> > > > >> > >
> > > > >> >
> > > > >>
> > > >
> > >
> >
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> > > > >> > > > >> > > > > > .
> > > > >> > > > >> > > > > > To summarize briefly, instead of the
> coordinator
> > > > >> assigning
> > > > >> > > the
> > > > >> > > > >> > > > partitions
> > > > >> > > > >> > > > > > itself, all subscriptions are forwarded to each
> > > > member
> > > > >> of
> > > > >> > > the
> > > > >> > > > >> group
> > > > >> > > > >> > > > which
> > > > >> > > > >> > > > > > then decides independently which partitions it
> > > should
> > > > >> > > consume.
> > > > >> > > > >> The
> > > > >> > > > >> > > > > protocol
> > > > >> > > > >> > > > > > provides a mechanism for the coordinator to
> > > validate
> > > > >> that
> > > > >> > > all
> > > > >> > > > >> > > consumers
> > > > >> > > > >> > > > > use
> > > > >> > > > >> > > > > > the same assignment strategy, but it does not
> > > ensure
> > > > >> that
> > > > >> > > the
> > > > >> > > > >> > > resulting
> > > > >> > > > >> > > > > > assignment is "correct." This provides a
> powerful
> > > > >> > capability
> > > > >> > > > for
> > > > >> > > > >> > > users
> > > > >> > > > >> > > > to
> > > > >> > > > >> > > > > > control the full data flow on the client side.
> > They
> > > > >> > control
> > > > >> > > > how
> > > > >> > > > >> > data
> > > > >> > > > >> > > is
> > > > >> > > > >> > > > > > written to partitions through the Partitioner
> > > > interface
> > > > >> > and
> > > > >> > > > they
> > > > >> > > > >> > > > control
> > > > >> > > > >> > > > > > how data is consumed through the assignment
> > > strategy,
> > > > >> all
> > > > >> > > > >> without
> > > > >> > > > >> > > > > touching
> > > > >> > > > >> > > > > > the server.
> > > > >> > > > >> > > > > >
> > > > >> > > > >> > > > > > Of course nothing comes for free. In
> particular,
> > > this
> > > > >> > change
> > > > >> > > > >> > removes
> > > > >> > > > >> > > > the
> > > > >> > > > >> > > > > > ability of the coordinator to validate that
> > commits
> > > > are
> > > > >> > made
> > > > >> > > > by
> > > > >> > > > >> > > > consumers
> > > > >> > > > >> > > > > > who were assigned the respective partition.
> This
> > > > might
> > > > >> not
> > > > >> > > be
> > > > >> > > > >> too
> > > > >> > > > >> > bad
> > > > >> > > > >> > > > > since
> > > > >> > > > >> > > > > > we retain the ability to validate the
> generation
> > > id,
> > > > >> but
> > > > >> > it
> > > > >> > > > is a
> > > > >> > > > >> > > > > potential
> > > > >> > > > >> > > > > > concern. We have considered alternative
> protocols
> > > > which
> > > > >> > add
> > > > >> > > a
> > > > >> > > > >> > second
> > > > >> > > > >> > > > > > round-trip to the protocol in order to give the
> > > > >> > coordinator
> > > > >> > > > the
> > > > >> > > > >> > > ability
> > > > >> > > > >> > > > > to
> > > > >> > > > >> > > > > > confirm the assignment. As mentioned above, the
> > > > >> > coordinator
> > > > >> > > is
> > > > >> > > > >> > > somewhat
> > > > >> > > > >> > > > > > limited in what it can actually validate, but
> > this
> > > > >> would
> > > > >> > > > return
> > > > >> > > > >> its
> > > > >> > > > >> > > > > ability
> > > > >> > > > >> > > > > > to validate commits. The tradeoff is that it
> > > > increases
> > > > >> the
> > > > >> > > > >> > protocol's
> > > > >> > > > >> > > > > > complexity which means more ways for the
> protocol
> > > to
> > > > >> fail
> > > > >> > > and
> > > > >> > > > >> > > > > consequently
> > > > >> > > > >> > > > > > more edge cases in the code.
> > > > >> > > > >> > > > > >
> > > > >> > > > >> > > > > > It also misses an opportunity to generalize the
> > > group
> > > > >> > > > membership
> > > > >> > > > >> > > > protocol
> > > > >> > > > >> > > > > > for additional use cases. In fact, after you've
> > > gone
> > > > to
> > > > >> > the
> > > > >> > > > >> trouble
> > > > >> > > > >> > > of
> > > > >> > > > >> > > > > > moving assignment to the client, the main thing
> > > that
> > > > is
> > > > >> > left
> > > > >> > > > in
> > > > >> > > > >> > this
> > > > >> > > > >> > > > > > protocol is basically a general group
> management
> > > > >> > capability.
> > > > >> > > > >> This
> > > > >> > > > >> > is
> > > > >> > > > >> > > > > > exactly what is needed for a few cases that are
> > > > >> currently
> > > > >> > > > under
> > > > >> > > > >> > > > > discussion
> > > > >> > > > >> > > > > > (e.g. copycat or single-writer producer). We've
> > > taken
> > > > >> this
> > > > >> > > > >> further
> > > > >> > > > >> > > step
> > > > >> > > > >> > > > > in
> > > > >> > > > >> > > > > > the proposal and attempted to envision what
> that
> > > > >> general
> > > > >> > > > >> protocol
> > > > >> > > > >> > > might
> > > > >> > > > >> > > > > > look like and how it could be used both by the
> > > > consumer
> > > > >> > and
> > > > >> > > > for
> > > > >> > > > >> > some
> > > > >> > > > >> > > of
> > > > >> > > > >> > > > > > these other cases.
> > > > >> > > > >> > > > > >
> > > > >> > > > >> > > > > > Anyway, since time is running out on the new
> > > > consumer,
> > > > >> we
> > > > >> > > have
> > > > >> > > > >> > > perhaps
> > > > >> > > > >> > > > > one
> > > > >> > > > >> > > > > > last chance to consider a significant change in
> > the
> > > > >> > protocol
> > > > >> > > > >> like
> > > > >> > > > >> > > this,
> > > > >> > > > >> > > > > so
> > > > >> > > > >> > > > > > have a look at the wiki and share your
> thoughts.
> > > I've
> > > > >> no
> > > > >> > > doubt
> > > > >> > > > >> that
> > > > >> > > > >> > > > some
> > > > >> > > > >> > > > > > ideas seem clearer in my mind than they do on
> > > paper,
> > > > so
> > > > >> > ask
> > > > >> > > > >> > questions
> > > > >> > > > >> > > > if
> > > > >> > > > >> > > > > > there is any confusion.
> > > > >> > > > >> > > > > >
> > > > >> > > > >> > > > > > Thanks!
> > > > >> > > > >> > > > > > Jason
> > > > >> > > > >> > > > > >
> > > > >> > > > >> > > > >
> > > > >> > > > >> > > >
> > > > >> > > > >> > > >
> > > > >> > > > >> > > >
> > > > >> > > > >> > > > --
> > > > >> > > > >> > > > Thanks,
> > > > >> > > > >> > > > Ewen
> > > > >> > > > >> > > >
> > > > >> > > > >> > >
> > > > >> > > > >> >
> > > > >> > > > >> >
> > > > >> > > > >> >
> > > > >> > > > >> > --
> > > > >> > > > >> > Thanks,
> > > > >> > > > >> > Ewen
> > > > >> > > > >> >
> > > > >> > > > >>
> > > > >> > > > >
> > > > >> > > > >
> > > > >> > > >
> > > > >> > >
> > > > >> >
> > > > >>
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Thanks,
> > > > > Neha
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Thanks,
> > > > Neha
> > > >
> > >
> > >
> > >
> > > --
> > > Thanks,
> > > Ewen
> > >
> >
>
>
>
> --
> Thanks,
> Ewen
>



-- 
Thanks,
Neha

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Ewen Cheslack-Postava <ew...@confluent.io>.
On Fri, Aug 14, 2015 at 10:59 AM, Jiangjie Qin <jq...@linkedin.com.invalid>
wrote:

> Neha and Ewen,
>
> About the metadata change frequency. I guess it really depends on how
> frequent the metadata change might occur. If we run Kafka as a service, I
> can see that happens from time to time. As I can imagine people will create
> some topic, test and maybe delete the topic in some automated test. If so,
> the proposed protocol might be a little bit vulnerable.
>
> More specifically the scenario I am thinking is:
> 1. Consumer 0 periodically refresh metadata and detected a metadata change.
> So it sends a JoinGroupRequest with metadata_hash_0.
> 2. Consumer 1 was notified by controller to start a rebalance, so it
> refreshes its metadata and send a JoingGroupRequest with metadata_hash_1,
> which is different from metadata hash 0.
> 3. Rebalance failed and both consumer refresh there metadata again from
> different brokers.
> 4. Depending on the metadata change frequency(or some admin operation like
> partition reassigment), they may or may not have the same metadata
> returned, so the restart from 3 again.
>
> I agree that step 4 might not be a big concern if consumers updates
> metadata at almost the same time, but I'm a little bit worried whether that
> assumption really stands because we do not have control over how frequent
> the metadata can change.
>
>
Is this really that different from what would happen if the coordinator
distributed the metadata to consumers? In that case you would trivially
have everyone in a consistent state, but those metadata changes would still
cause churn and require JoinGroup rounds, during which processing is
stalled for the nodes that are waiting on other members to re-join the
group.

-Ewen


> Thanks,
>
> Jiangjie (Becket) Qin
>
> On Fri, Aug 14, 2015 at 2:03 AM, Ewen Cheslack-Postava <ew...@confluent.io>
> wrote:
>
> > On Thu, Aug 13, 2015 at 11:07 PM, Neha Narkhede <ne...@confluent.io>
> wrote:
> >
> > > Becket,
> > >
> > > As you say, the metadata hash addresses the concern you originally
> raised
> > > about large topic subscriptions. Can you please list other problems you
> > are
> > > raising more clearly? It is more helpful to know problems that the
> > proposal
> > > does not address or addresses poorly.
> > >
> > > Regarding other things you said -
> > >
> > > it is required that each
> > > > consumer refresh their metadata before sending a JoinGroupRequest
> > > >
> > >
> > > This is required for wildcard topic subscriptions anyway. So this
> > proposal
> > > does not introduce a regression. We had agreed earlier that it does not
> > > make sense for the server to deserialize regular expressions sent by
> the
> > > consumer.
> > >
> >
> > I don't think consumers need to do a metadata refresh before sending a
> > JoinGroupRequest. Metadata changes that affect assignment are rare -- it
> > requires changing the number of partitions in a topic. But you might
> send a
> > JoinGroupRequest simply because a new member is trying to join the group.
> > That case is presumably much more common.
> >
> > I think it's actually a good idea to have the first JoinGroup cycle fail
> in
> > some cases, and has little impact. Lets say the metadata does change
> > because partitions are added. Then we might fail in the first round, but
> > then all members detect that issue *immediately*, refresh their metadata,
> > and submit a new join group request. This second cycle does not require a
> > full heartbeat cycle. It happens much more quickly because everyone
> > detected the inconsistency based on the first JoinGroupResponse. The
> > inconsistency should be resolved very quickly (barring other failures
> like
> > a member leaving mid-rebalance)
>
>
>
>
> > >
> > >
> > > > the metadata might still be inconsistent if there is a topic or
> > partition
> > > > change because the
> > > > UpdateMetadataRequest from controller might be handled at different
> > time.
> > > >
> > >
> > > Topic metadata does not change frequently and even if it did, a couple
> > > rebalance attempts will be needed whether the coordinator drives the
> > > assignments or the consumer. Because guess how the coordinator knows
> > about
> > > the topic metadata changes -- indirectly through either a zk callback
> or
> > > UpdateMetadataRequest, so it is completely possible the coordinator
> sees
> > > the topic metadata changes in batches, not all at once.
> > >
> >
> > > On Thu, Aug 13, 2015 at 10:50 PM, Neha Narkhede <ne...@confluent.io>
> > wrote:
> > >
> > > > Ewen/Jason,
> > > >
> > > > The metadata hash is a clever approach and certainly addresses the
> > > problem
> > > > of large metadata for consumers like mirror maker. Few comments -
> > > >
> > > >
> > > >    1. In the interest of simplifying the format of the consumer's
> > > >    metadata - Why not just always include only the topic names in the
> > > metadata
> > > >    followed by the metadata hash? If the metadata hash check
> succeeds,
> > > each
> > > >    consumer uses the # of partitions it had fetched. If it fails, a
> > > rebalance
> > > >    happens and the metadata is not used anyway.
> > >
> >
> > Doing this requires that every consumer always fetch the full metadata.
> The
> > most common use case is consumers that just want to consume one or a
> couple
> > of topics, in which case grabbing all metadata for the entire cluster is
> > wasteful. If I subscribe only to topic A, why make all consumers grab
> > metadata for the entire topic (and need to rebalance every time it
> > changes!). Including the # of partitions for each topic lets you avoid
> > having to grab the global set of metadata.
> >
> > So if you're just subscribing to one or a couple of topics, why not just
> > compute the hash by filtering out everything but the topics you are
> > subscribed to? The problem there is if you ever add/remove subscriptions
> > and want to support rolling upgrades. If the group was subscribed to
> topic
> > A, but later changes require subscribing to A + B, then to achieve a
> > seamless rolling upgrade would require one (old) consumer to be
> subscribing
> > to A and one (new) consumer to be subscribing to A+B. If we computed
> > metadata hashes based on filtered metadata, those two would disagree and
> we
> > could not perform assignment while the upgrade was in progress.
> >
> > The solution is to differentiate between the cases when a very small
> amount
> > of the metadata is needed (one or a couple of topic subscriptions;
> > communicate and share this via metadata in the JoinGroup protocol) vs
> when
> > *all* the metadata is needed (regex subscription; verify agreement via
> > hash).
> >
>
> >
> >
> > > >    2. Do you need a topic list and topic regex to be separate? A
> single
> > > >    topic or list of topics can be expressed as a regex.
> > >
> >
> > See above note about collecting all metadata when you really only need it
> > for 1 or 2 topics. There's probably some debate to be had about whether
> > this cost would be too high -- every consumer would need to request the
> > metadata for all topics, and they'd need to request that all every time
> > they might be out of date.
> >
> Are we going to allow consumers in the same group to subscribe to different
> topic set? If we do, we need to let them refresh metadata for all the
> topics a group is consuming from. If we don't then in the protocol we only
> need a subscription set hash.
>
> >
> >
> > > >    3. Let's include a version explicitly at the beginning of the
> > > >    ProtocolMetadata. The version dictates how to deserialize the
> > > >    ProtocolMetadata blob and is consistent with the rest of Kafka.
> > >
> >
> > If I'm understanding correctly, in JoinGroupRequest I would change
> >
> > GroupProtocols          => [Protocol ProtocolMetadata]
> >
> > to
> >
> > GroupProtocols          => [Protocol ProtocolVersion ProtocolMetadata]
> >
> > We had been talking about just baking the version into the Protocol
> field,
> > but making it separate seems perfectly reasonable to me. Jason, any issue
> > with splitting the version out into a separate field like this?
> >
> > >
> > > > That can simplify the metadata format to the following:
> > > >
> > > > GroupType => "consumer"
> > > >>
> > > >> Protocol => AssignmentStrategy
> > > >>   AssignmentStrategy   => String
> > > >>
> > > >> ProtocolMetadata => Version Subscription AssignmentStrategyMetadata
> > > >
> > > >     Version                    => String
> > > >
> > > >   Subscription                 => TopicRegex MetadataHash
> > > >>     TopicRegex                 => String
> > > >>     MetadataHash               => String
> > > >>   AssignmentStrategyMetadata   => bytes
> > >
> > >
> > > >
> > > > On Thu, Aug 13, 2015 at 6:28 PM, Jiangjie Qin
> > <jqin@linkedin.com.invalid
> > > >
> > > > wrote:
> > > >
> > > >> Ewen and Jason,
> > > >>
> > > >> Thanks for the reply. Sorry I missed the metadata hash. Yes, that
> is a
> > > >> clever approach and would solve my concern about the data passing
> > > around.
> > > >> I
> > > >> can see both pros and cons from doing this, though. The advantage is
> > we
> > > >> don't need the topic metadata in JoinGroupResponse anymore. The
> > downside
> > > >> is
> > > >> that now rebalance have extra dependency on the consensus of
> metadata
> > of
> > > >> all consumers, which is obtained separately. So it is required that
> > each
> > > >> consumer refresh their metadata before sending a JoinGroupRequest,
> > > >> otherwise in some cases (e.g. wildcard consumers) will almost
> > certainly
> > > >> fail for the first rebalance attempt. Even if we do that, since the
> > > >> consumers are getting metadata from different brokers, the metadata
> > > might
> > > >> still be inconsistent if there is a topic or partition change
> because
> > > the
> > > >> UpdateMetadataRequest from controller might be handled at different
> > > time.
> > > >> Just want to make sure we think through the cases so the protocol
> does
> > > not
> > > >> cause us unexpected issues.
> > > >>
> > > >> About the number of consumers, I think with the current liveliness
> > > >> definition, we can tolerate churns by bumping up the session
> timeout.
> > > Also
> > > >> I guess we will see an increasing number of consumers for new
> > consumer,
> > > >> because every the old consumer thread will probably become a
> consumer.
> > > >>
> > > >> It is a valid concern for consumers that have large subscription
> set.
> > > This
> > > >> might not be avoided though for client side assignment approach. One
> > > >> solution is having topic names associate with a topic ID. And only
> use
> > > >> topic ID in JoinGroupRequest and JoinGroupResponse, There is a
> > > discussion
> > > >> thread about this to solve the topic renaming case but this is a
> > > >> completely
> > > >> different discussion.
> > > >>
> > > >> Thanks,
> > > >>
> > > >> Jiangjie (Becket) Qin
> > > >>
> > > >>
> > > >>
> > > >> On Thu, Aug 13, 2015 at 2:14 PM, Jason Gustafson <
> jason@confluent.io>
> > > >> wrote:
> > > >>
> > > >> > Thanks Jiangjie, that information helps. I agree the protocol must
> > > >> consider
> > > >> > scalability. My point was that the synchronization barrier in the
> > > >> current
> > > >> > protocol already effectively limits the number of consumers since
> it
> > > >> > provides no way to gracefully handle churn. It wouldn't be worth
> > > >> worrying
> > > >> > about scaling up to 100,000 members, for example, because there's
> no
> > > way
> > > >> > the group would be stable. So we just need to set some clear
> > > >> expectations
> > > >> > on the size we can scale to, and that can help inform the
> discussion
> > > on
> > > >> the
> > > >> > size of messages in this protocol.
> > > >> >
> > > >> > Ewen and I were discussing this morning along similar lines to
> what
> > > >> you're
> > > >> > suggesting. However, even if the coordinator decides on the
> metadata
> > > for
> > > >> > the group, each member still needs to communicate its
> subscriptions
> > to
> > > >> the
> > > >> > rest of the group. This is nice for the regex case since the regex
> > is
> > > >> > probably small, but if the members have a large topic list, then
> we
> > > have
> > > >> > the same problem. One thing I was thinking about was whether we
> > really
> > > >> need
> > > >> > to handle different subscriptions for every member. If the
> > coordinator
> > > >> > could guarantee that all members had the same subscription, then
> > there
> > > >> > would be no need for the coordinator to return the subscriptions
> for
> > > >> each
> > > >> > member. However, this would prevent graceful upgrades. We might be
> > > able
> > > >> to
> > > >> > fix that problem by allowing the consumer to provide two
> > subscriptions
> > > >> to
> > > >> > allowing rolling updates, but that starts to sound pretty nasty.
> > > >> >
> > > >> > -Jason
> > > >> >
> > > >> > On Thu, Aug 13, 2015 at 1:41 PM, Jiangjie Qin
> > > <jqin@linkedin.com.invalid
> > > >> >
> > > >> > wrote:
> > > >> >
> > > >> > > Jason,
> > > >> > >
> > > >> > > The protocol has to consider the scalability. The protocol in
> the
> > > wiki
> > > >> > > means the JoinGroupResoponse size would be:
> > > >> > > NumberOfTopics * (AvgTopicNameLength + 4) *
> (NumberOfConsumers)^2
> > > >> > >
> > > >> > > To give some real number, we have 26-node Mirror Maker cluster,
> > each
> > > >> > with 4
> > > >> > > consumers. That is 104 consumers using regex ".*". And most of
> our
> > > >> > clusters
> > > >> > > have around 3000 topics, whose topic name are typically around
> 20
> > > >> > > characters.
> > > >> > >
> > > >> > > I think the key issue for client side partition assignment logic
> > is
> > > to
> > > >> > make
> > > >> > > sure 1) all the clients run the same algorithm. 2) all the
> clients
> > > >> make
> > > >> > > decision on the same topic metadata. The second purpose can be
> > done
> > > by
> > > >> > > simply letting coordinator provide the topic metadata and all
> then
> > > >> member
> > > >> > > information as source of truth. Is it necessary to pass topic
> > > >> metadata of
> > > >> > > each consumer around? Can we keep the protocol metadata field
> > > >> completely
> > > >> > > independent of topic metadata? I think In the JoinGroupResponse,
> > we
> > > >> > should
> > > >> > > have only one copy of topic metadata provided by coordinator and
> > is
> > > >> > outside
> > > >> > > of protocol metadata. If user decides to put some metadata in
> the
> > > >> > > JoinGroupRequest and let coordinator pass around, they are
> > > responsible
> > > >> > for
> > > >> > > understanding the risk.
> > > >> > >
> > > >> > > Thanks,
> > > >> > >
> > > >> > > Jiangjie (Becket) Qin
> > > >> > >
> > > >> > >
> > > >> > > On Thu, Aug 13, 2015 at 12:41 PM, Jason Gustafson <
> > > jason@confluent.io
> > > >> >
> > > >> > > wrote:
> > > >> > >
> > > >> > > > Hey Onur and Jiangjie,
> > > >> > > >
> > > >> > > > I've updated that wiki with a proposal to add regex
> > subscriptions
> > > to
> > > >> > the
> > > >> > > > consumer metadata. Can you have a look to see if it addresses
> > your
> > > >> > > concern?
> > > >> > > > In general, I think we should be a little careful when we are
> > > >> talking
> > > >> > > about
> > > >> > > > the scalability of the protocol. Regardless of whether
> > assignment
> > > is
> > > >> > done
> > > >> > > > on the server or the client, the protocol assumes a relatively
> > > >> stable
> > > >> > > > configuration. When the number of consumers increases beyond a
> > > >> certain
> > > >> > > > limit, then membership churn becomes a major concern.
> Similarly
> > > >> there
> > > >> > is
> > > >> > > a
> > > >> > > > notion of metadata churn when topics are added, deleted, or
> > > >> resized. If
> > > >> > > > either membership or metadata changes, then the protocol
> forces
> > > all
> > > >> > > > consumers to stop consumption and rejoin the group. If this
> > > happens
> > > >> > often
> > > >> > > > enough, then it can severely impact the ability of the
> consumer
> > to
> > > >> make
> > > >> > > > progress. The point is that the protocol may already be
> unsuited
> > > to
> > > >> > cases
> > > >> > > > where there are either a large number of consumers or topics.
> I
> > > >> wonder
> > > >> > if
> > > >> > > > you guys can share your thoughts about your scaling
> > expectations?
> > > >> > > >
> > > >> > > > -Jason
> > > >> > > >
> > > >> > > >
> > > >> > > >
> > > >> > > >
> > > >> > > > On Wed, Aug 12, 2015 at 12:28 PM, Jason Gustafson <
> > > >> jason@confluent.io>
> > > >> > > > wrote:
> > > >> > > >
> > > >> > > > > Hey Jiangjie,
> > > >> > > > >
> > > >> > > > > That's a great point. In the worst case (the mirror maker
> > case I
> > > >> > > guess),
> > > >> > > > > the join group response can be massive. This would be
> > especially
> > > >> > deadly
> > > >> > > > > when there is a lot of churn in the group (e.g. in a rolling
> > > >> > upgrade).
> > > >> > > > The
> > > >> > > > > current protocol is not great for this case either, but it's
> > > >> > > > significantly
> > > >> > > > > better. Here are a couple ways to deal with the size:
> > > >> > > > >
> > > >> > > > > 1. First, we could have the coordinator compress the
> > responses.
> > > >> This
> > > >> > > > would
> > > >> > > > > probably be pretty effective if applied across the metadata
> > from
> > > >> all
> > > >> > > > > members.
> > > >> > > > >
> > > >> > > > > 2. I think the regex case is the main problem. Is that
> right?
> > We
> > > >> > could
> > > >> > > > > extend the metadata to allow the consumer to embed its regex
> > > >> > > subscription
> > > >> > > > > in the metadata directly (note this might be a good idea
> > > >> regardless
> > > >> > of
> > > >> > > > the
> > > >> > > > > rest of this proposal). To support regex on the consumer, we
> > > must
> > > >> > fetch
> > > >> > > > > metadata for all topics. Rather than having all regex
> > > subscribers
> > > >> > embed
> > > >> > > > all
> > > >> > > > > of this metadata in their join group requests, they could
> > > instead
> > > >> > > embed a
> > > >> > > > > hash of it. Then after the join group responses are
> received,
> > > they
> > > >> > just
> > > >> > > > > need to check that the hashes are the same. If there is a
> > > mismatch
> > > >> > > (which
> > > >> > > > > should only occur when topics are created, deleted, or
> > resized),
> > > >> then
> > > >> > > the
> > > >> > > > > group members must refetch the metadata and rejoin the
> group.
> > > >> This is
> > > >> > > > also
> > > >> > > > > how the current protocol behaves when there is a change in
> the
> > > >> topic
> > > >> > > > > metadata affecting the group--someone (either the
> coordinator
> > or
> > > >> the
> > > >> > > > > consumer) detects the change and forces the group to
> > rebalance.
> > > >> > > > >
> > > >> > > > > What do you think?
> > > >> > > > >
> > > >> > > > > (Also I think adding groupId/generationId to fetch and
> produce
> > > >> > requests
> > > >> > > > > seems like an interesting line of thought.)
> > > >> > > > >
> > > >> > > > > -Jason
> > > >> > > > >
> > > >> > > > >
> > > >> > > > >
> > > >> > > > > On Wed, Aug 12, 2015 at 10:57 AM, Jiangjie Qin
> > > >> > > <jqin@linkedin.com.invalid
> > > >> > > > >
> > > >> > > > > wrote:
> > > >> > > > >
> > > >> > > > >> Hey Ewen,
> > > >> > > > >>
> > > >> > > > >> Onur and I discussed this a little bit more. And we are
> still
> > > >> > worrying
> > > >> > > > >> about passing all the metadata of all consumers around.
> > > >> > > > >>
> > > >> > > > >> Let's say I have a cluster has 10,000 topics, the average
> > topic
> > > >> name
> > > >> > > > >> length
> > > >> > > > >> is 10 bytes. In this case, the opaque metadata will have
> 10 *
> > > >> > 10,000 =
> > > >> > > > >> 100KB for topic name, for each topic, there is a 4-byte
> > integer
> > > >> of
> > > >> > > > number
> > > >> > > > >> of partitions, that's another 40KB. So one global topic
> > > metadata
> > > >> > will
> > > >> > > > have
> > > >> > > > >> 140KB data. If I have 100 consumers who are using wildcard
> to
> > > >> > consume
> > > >> > > > from
> > > >> > > > >> all the topics. That means the protocol metadata end up in
> > the
> > > >> > > > >> JoinGroupResponse will be 140KB * 100 = 14MB. And the
> > > >> > > JoinGroupResponse
> > > >> > > > >> will need to be sent to 100 different consumers, that means
> > > 14MB
> > > >> *
> > > >> > > 100 =
> > > >> > > > >> 1.4GB need to be sent by the consumer coordinator for one
> > > >> rebalance.
> > > >> > > How
> > > >> > > > >> would that work?
> > > >> > > > >>
> > > >> > > > >> Also, having two consumers (old owner and new owner)
> > consuming
> > > >> from
> > > >> > > the
> > > >> > > > >> same partition might also be a problem. e.g. people are
> > > updating
> > > >> > > > database.
> > > >> > > > >> One thing might worth doing is to add GroupId and
> Generation
> > ID
> > > >> to
> > > >> > > > >> ProducerRequest and FetchRequest as well. This will also
> help
> > > >> with
> > > >> > the
> > > >> > > > >> single producer use case. However, this is probably
> > orthogonal
> > > to
> > > >> > this
> > > >> > > > >> thread given the current new consumer also has this problem
> > > and I
> > > >> > > > believe
> > > >> > > > >> we need to fix it.
> > > >> > > > >>
> > > >> > > > >> Thanks,
> > > >> > > > >>
> > > >> > > > >> Jiangjie (Becket) Qin
> > > >> > > > >>
> > > >> > > > >> On Tue, Aug 11, 2015 at 11:43 PM, Ewen Cheslack-Postava <
> > > >> > > > >> ewen@confluent.io>
> > > >> > > > >> wrote:
> > > >> > > > >>
> > > >> > > > >> > On Tue, Aug 11, 2015 at 11:29 PM, Jiangjie Qin
> > > >> > > > >> <jq...@linkedin.com.invalid>
> > > >> > > > >> > wrote:
> > > >> > > > >> >
> > > >> > > > >> > > Ewen,
> > > >> > > > >> > >
> > > >> > > > >> > > Thanks for the explanation.
> > > >> > > > >> > >
> > > >> > > > >> > > For (1), I am more concerned about the failure case
> > instead
> > > >> of
> > > >> > > > normal
> > > >> > > > >> > case.
> > > >> > > > >> > > What if a consumer somehow was kick out of a group but
> is
> > > >> still
> > > >> > > > >> consuming
> > > >> > > > >> > > and committing offsets? Does that mean the new owner
> and
> > > old
> > > >> > owner
> > > >> > > > >> might
> > > >> > > > >> > > potentially consuming from and committing offsets for
> the
> > > >> same
> > > >> > > > >> partition?
> > > >> > > > >> > > In the old consumer, this won't happen because the new
> > > >> consumer
> > > >> > > will
> > > >> > > > >> not
> > > >> > > > >> > be
> > > >> > > > >> > > able to start consumption unless the previous owner has
> > > >> released
> > > >> > > its
> > > >> > > > >> > > ownership. Basically, without the ownership guarantee,
> I
> > > >> don't
> > > >> > see
> > > >> > > > how
> > > >> > > > >> > the
> > > >> > > > >> > > communication among consumers themselves alone can
> solve
> > > the
> > > >> > > problem
> > > >> > > > >> > here.
> > > >> > > > >> > >
> > > >> > > > >> >
> > > >> > > > >> > The generation ID check still applies to offset commits.
> If
> > > >> one of
> > > >> > > the
> > > >> > > > >> > consumers is kicked out and misbehaving, it can obviously
> > > still
> > > >> > > fetch
> > > >> > > > >> and
> > > >> > > > >> > process messages, but offset commits will not work since
> it
> > > >> will
> > > >> > not
> > > >> > > > >> have
> > > >> > > > >> > the current generation ID.
> > > >> > > > >> >
> > > >> > > > >> >
> > > >> > > > >> > >
> > > >> > > > >> > > For (2) and (3), now I understand how metadata are
> used.
> > > But
> > > >> I
> > > >> > > still
> > > >> > > > >> > don't
> > > >> > > > >> > > see why should we let the consumers to pass the topic
> > > >> > information
> > > >> > > > >> across
> > > >> > > > >> > > instead of letting coordinator give the information.
> The
> > > >> single
> > > >> > > > >> producer
> > > >> > > > >> > > use case does not solve the ownership problem in
> abnormal
> > > >> case
> > > >> > > > either,
> > > >> > > > >> > > which seems to be a little bit vulnerable.
> > > >> > > > >> > >
> > > >> > > > >> >
> > > >> > > > >> > One of the goals here was to generalize group membership
> so
> > > we
> > > >> > can,
> > > >> > > > for
> > > >> > > > >> > example, use it for balancing Copycat tasks across
> workers.
> > > >> > There's
> > > >> > > no
> > > >> > > > >> > topic subscription info in that case. The metadata for
> > > copycat
> > > >> > > workers
> > > >> > > > >> > would instead need to somehow indicate the current set of
> > > tasks
> > > >> > that
> > > >> > > > >> need
> > > >> > > > >> > to be assigned to workers. By making the metadata
> > completely
> > > >> > opaque
> > > >> > > to
> > > >> > > > >> the
> > > >> > > > >> > protocol, it becomes more generally useful since it
> focuses
> > > >> > squarely
> > > >> > > > on
> > > >> > > > >> the
> > > >> > > > >> > group membership problem, allowing for that additional
> bit
> > of
> > > >> > > metadata
> > > >> > > > >> so
> > > >> > > > >> > you don't just get a list of members, but also get a
> little
> > > >> bit of
> > > >> > > > info
> > > >> > > > >> > about each of them.
> > > >> > > > >> >
> > > >> > > > >> > A different option that we explored is to use a sort of
> > mixed
> > > >> > model
> > > >> > > --
> > > >> > > > >> > still bake all the topic subscriptions directly into the
> > > >> protocol
> > > >> > > but
> > > >> > > > >> also
> > > >> > > > >> > include metadata. That would allow us to maintain the
> > > existing
> > > >> > > > >> > coordinator-driven approach to handling the metadata and
> > > change
> > > >> > > events
> > > >> > > > >> like
> > > >> > > > >> > the ones Onur pointed out. Then something like the
> Copycat
> > > >> workers
> > > >> > > > would
> > > >> > > > >> > just not fill in any topic subscriptions and it would be
> > > >> handled
> > > >> > as
> > > >> > > a
> > > >> > > > >> > degenerate case. Based on the way I explained that we can
> > > >> handle
> > > >> > > those
> > > >> > > > >> > types of events, I personally feel its cleaner and a
> nicer
> > > >> > > > >> generalization
> > > >> > > > >> > to not include the subscriptions in the join group
> > protocol,
> > > >> > making
> > > >> > > it
> > > >> > > > >> part
> > > >> > > > >> > of the metadata instead.
> > > >> > > > >> >
> > > >> > > > >> > For the single producer case, are you saying it doesn't
> > solve
> > > >> > > > ownership
> > > >> > > > >> in
> > > >> > > > >> > the abnormal case because a producer that doesn't know it
> > has
> > > >> been
> > > >> > > > >> kicked
> > > >> > > > >> > out of the group yet can still produce data even though
> it
> > > >> > shouldn't
> > > >> > > > be
> > > >> > > > >> > able to anymore? I definitely agree that that is a risk
> --
> > > this
> > > >> > > > >> provides a
> > > >> > > > >> > way to get closer to a true single-writer, but there are
> > > >> > definitely
> > > >> > > > >> still
> > > >> > > > >> > failure modes that this does not address.
> > > >> > > > >> >
> > > >> > > > >> > -Ewen
> > > >> > > > >> >
> > > >> > > > >> >
> > > >> > > > >> > >
> > > >> > > > >> > > Thanks,
> > > >> > > > >> > >
> > > >> > > > >> > > Jiangjie (Becket) Qin
> > > >> > > > >> > >
> > > >> > > > >> > >
> > > >> > > > >> > > On Tue, Aug 11, 2015 at 11:06 PM, Ewen
> Cheslack-Postava <
> > > >> > > > >> > ewen@confluent.io
> > > >> > > > >> > > >
> > > >> > > > >> > > wrote:
> > > >> > > > >> > >
> > > >> > > > >> > > > On Tue, Aug 11, 2015 at 10:15 PM, Jiangjie Qin
> > > >> > > > >> > <jqin@linkedin.com.invalid
> > > >> > > > >> > > >
> > > >> > > > >> > > > wrote:
> > > >> > > > >> > > >
> > > >> > > > >> > > > > Hi Jason,
> > > >> > > > >> > > > >
> > > >> > > > >> > > > > Thanks for writing this up. It would be useful to
> > > >> generalize
> > > >> > > the
> > > >> > > > >> > group
> > > >> > > > >> > > > > concept. I have a few questions below.
> > > >> > > > >> > > > >
> > > >> > > > >> > > > > 1. In old consumer actually the partition
> assignment
> > > are
> > > >> > done
> > > >> > > by
> > > >> > > > >> > > > consumers
> > > >> > > > >> > > > > themselves. We used zookeeper to guarantee that a
> > > >> partition
> > > >> > > will
> > > >> > > > >> only
> > > >> > > > >> > > be
> > > >> > > > >> > > > > consumed by one consumer thread who successfully
> > > claimed
> > > >> its
> > > >> > > > >> > ownership.
> > > >> > > > >> > > > > Does the new protocol plan to provide the same
> > > guarantee?
> > > >> > > > >> > > > >
> > > >> > > > >> > > >
> > > >> > > > >> > > > Once you have all the metadata from all the
> consumers,
> > > >> > > assignment
> > > >> > > > >> > should
> > > >> > > > >> > > > just be a simple function mapping that
> Map<ConsumerId,
> > > >> > Metadata>
> > > >> > > > to
> > > >> > > > >> > > > Map<ConsumerId, List<TopicPartition>>. If everyone is
> > > >> > consistent
> > > >> > > > in
> > > >> > > > >> > > > computing that, you don't need ZK involved at all.
> > > >> > > > >> > > >
> > > >> > > > >> > > > In practice, this shouldn't be that hard to ensure
> for
> > > most
> > > >> > > > >> assignment
> > > >> > > > >> > > > strategies just by having decent unit testing on
> them.
> > > You
> > > >> > just
> > > >> > > > >> have to
> > > >> > > > >> > > do
> > > >> > > > >> > > > things like ensure your assignment strategy sorts
> lists
> > > >> into a
> > > >> > > > >> > consistent
> > > >> > > > >> > > > order.
> > > >> > > > >> > > >
> > > >> > > > >> > > > You do give up the ability to use some techniques
> (e.g.
> > > any
> > > >> > > > >> randomized
> > > >> > > > >> > > > algorithm if you can't distribute the seed w/ the
> > > metadata)
> > > >> > and
> > > >> > > > it's
> > > >> > > > >> > true
> > > >> > > > >> > > > that nothing validates the assignment, but if that
> > > >> assignment
> > > >> > > > >> algorithm
> > > >> > > > >> > > > step is kept simple, small, and well tested, the risk
> > is
> > > >> very
> > > >> > > > >> minimal.
> > > >> > > > >> > > >
> > > >> > > > >> > > >
> > > >> > > > >> > > > >
> > > >> > > > >> > > > > 2. It looks that both JoinGroupRequest and
> > > >> JoinGroupResponse
> > > >> > > has
> > > >> > > > >> the
> > > >> > > > >> > > > > ProtocolMetadata.AssignmentStrategyMetadata, what
> > would
> > > >> be
> > > >> > the
> > > >> > > > >> > metadata
> > > >> > > > >> > > > be
> > > >> > > > >> > > > > sent and returned by coordinator? How will the
> > > >> coordinator
> > > >> > > > handle
> > > >> > > > >> the
> > > >> > > > >> > > > > metadata?
> > > >> > > > >> > > > >
> > > >> > > > >> > > >
> > > >> > > > >> > > > The coordinator is basically just blindly
> broadcasting
> > > all
> > > >> of
> > > >> > it
> > > >> > > > to
> > > >> > > > >> > group
> > > >> > > > >> > > > members so they have a consistent view.
> > > >> > > > >> > > >
> > > >> > > > >> > > > So from the coordinators perspective, it sees
> something
> > > >> like:
> > > >> > > > >> > > >
> > > >> > > > >> > > > Consumer 1 -> JoinGroupRequest with GroupProtocols =
> [
> > > >> > > "consumer"
> > > >> > > > >> > > > <Consumer1 opaque byte[]>]
> > > >> > > > >> > > > Consumer 2 -> JoinGroupRequest with GroupProtocols =
> [
> > > >> > > "consumer"
> > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > >> > > > >> > > >
> > > >> > > > >> > > > Then, in the responses would look like:
> > > >> > > > >> > > >
> > > >> > > > >> > > > Consumer 1 <- JoinGroupResponse with GroupProtocol =
> > > >> > "consumer"
> > > >> > > > and
> > > >> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque
> byte[]>,
> > > >> > Consumer
> > > >> > > 2
> > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > >> > > > >> > > > Consumer 2 <- JoinGroupResponse with GroupProtocol =
> > > >> > "consumer"
> > > >> > > > and
> > > >> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque
> byte[]>,
> > > >> > Consumer
> > > >> > > 2
> > > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > > >> > > > >> > > >
> > > >> > > > >> > > > So all the responses include all the metadata for
> every
> > > >> member
> > > >> > > in
> > > >> > > > >> the
> > > >> > > > >> > > > group, and everyone can use that to consistently
> decide
> > > on
> > > >> > > > >> assignment.
> > > >> > > > >> > > The
> > > >> > > > >> > > > broker doesn't care and cannot even understand the
> > > metadata
> > > >> > > since
> > > >> > > > >> the
> > > >> > > > >> > > data
> > > >> > > > >> > > > format for it is dependent on the assignment strategy
> > > being
> > > >> > > used.
> > > >> > > > >> > > >
> > > >> > > > >> > > > As another example that is *not* a consumer, let's
> say
> > > you
> > > >> > just
> > > >> > > > >> want to
> > > >> > > > >> > > > have a single writer in the group which everyone will
> > > >> forward
> > > >> > > > >> requests
> > > >> > > > >> > > to.
> > > >> > > > >> > > > To accomplish this, you could use a very dumb
> > assignment
> > > >> > > strategy:
> > > >> > > > >> > there
> > > >> > > > >> > > is
> > > >> > > > >> > > > no metadata (empty byte[]) and all we care about is
> who
> > > is
> > > >> the
> > > >> > > > first
> > > >> > > > >> > > member
> > > >> > > > >> > > > in the group (e.g. when IDs are sorted
> > > lexicographically).
> > > >> > That
> > > >> > > > >> member
> > > >> > > > >> > is
> > > >> > > > >> > > > selected as the writer. In that case, we actually
> just
> > > care
> > > >> > > about
> > > >> > > > >> the
> > > >> > > > >> > > > membership list, there's no additional info about
> each
> > > >> member
> > > >> > > that
> > > >> > > > >> is
> > > >> > > > >> > > > required to determine who is the writer.
> > > >> > > > >> > > >
> > > >> > > > >> > > >
> > > >> > > > >> > > > > 3. Do you mean that the number of partitions in
> > > >> > > > JoinGroupResponse
> > > >> > > > >> > will
> > > >> > > > >> > > be
> > > >> > > > >> > > > > the max partition number of a topic among all the
> > > >> reported
> > > >> > > > >> partition
> > > >> > > > >> > > > number
> > > >> > > > >> > > > > by consumers? Is there any reason not just let
> > > >> Coordinator
> > > >> > to
> > > >> > > > >> return
> > > >> > > > >> > > the
> > > >> > > > >> > > > > number of partitions of a topic in its metadata
> > cache?
> > > >> > > > >> > > > >
> > > >> > > > >> > > >
> > > >> > > > >> > > > Nothing from the embedded protocol is touched by the
> > > >> broker.
> > > >> > The
> > > >> > > > >> broker
> > > >> > > > >> > > > just collects opaque bytes of metadata, does the
> > > selection
> > > >> of
> > > >> > > the
> > > >> > > > >> > > strategy
> > > >> > > > >> > > > if multiple are supported by some consumers, and then
> > > >> returns
> > > >> > > that
> > > >> > > > >> > opaque
> > > >> > > > >> > > > metadata for all the members back to every member. In
> > > that
> > > >> way
> > > >> > > > they
> > > >> > > > >> all
> > > >> > > > >> > > > have a consistent view of the group. For regular
> > > consumers,
> > > >> > that
> > > >> > > > >> view
> > > >> > > > >> > of
> > > >> > > > >> > > > the group includes information about how many
> > partitions
> > > >> each
> > > >> > > > >> consumer
> > > >> > > > >> > > > currently thinks the topics it is subscribed to has.
> > > These
> > > >> > could
> > > >> > > > be
> > > >> > > > >> > > > inconsistent due to out of date metadata and it would
> > be
> > > >> up to
> > > >> > > the
> > > >> > > > >> > > > assignment strategy on the *client* to resolve that.
> As
> > > you
> > > >> > > point
> > > >> > > > >> out,
> > > >> > > > >> > in
> > > >> > > > >> > > > that case they could just take the max value that any
> > > >> consumer
> > > >> > > > >> reported
> > > >> > > > >> > > > seeing and use that. The consumers that notice that
> > their
> > > >> > > metadata
> > > >> > > > >> had
> > > >> > > > >> > a
> > > >> > > > >> > > > smaller # of partitions should also trigger a
> metadata
> > > >> update
> > > >> > > when
> > > >> > > > >> they
> > > >> > > > >> > > see
> > > >> > > > >> > > > someone else observing a larger # of partitions.
> > > >> > > > >> > > >
> > > >> > > > >> > > >
> > > >> > > > >> > > > >
> > > >> > > > >> > > > > Thanks,
> > > >> > > > >> > > > >
> > > >> > > > >> > > > > Jiangjie (Becket) Qin
> > > >> > > > >> > > > >
> > > >> > > > >> > > > >
> > > >> > > > >> > > > >
> > > >> > > > >> > > > >
> > > >> > > > >> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <
> > > >> > > > >> jason@confluent.io
> > > >> > > > >> > >
> > > >> > > > >> > > > > wrote:
> > > >> > > > >> > > > >
> > > >> > > > >> > > > > > Hi Kafka Devs,
> > > >> > > > >> > > > > >
> > > >> > > > >> > > > > > One of the nagging issues in the current design
> of
> > > the
> > > >> new
> > > >> > > > >> consumer
> > > >> > > > >> > > has
> > > >> > > > >> > > > > > been the need to support a variety of assignment
> > > >> > strategies.
> > > >> > > > >> We've
> > > >> > > > >> > > > > > encountered this in particular in the design of
> > > copycat
> > > >> > and
> > > >> > > > the
> > > >> > > > >> > > > > processing
> > > >> > > > >> > > > > > framework (KIP-28). From what I understand, Samza
> > > also
> > > >> > has a
> > > >> > > > >> number
> > > >> > > > >> > > of
> > > >> > > > >> > > > > use
> > > >> > > > >> > > > > > cases with custom assignment needs. The new
> > consumer
> > > >> > > protocol
> > > >> > > > >> > > supports
> > > >> > > > >> > > > > new
> > > >> > > > >> > > > > > assignment strategies by hooking them into the
> > > broker.
> > > >> For
> > > >> > > > many
> > > >> > > > >> > > > > > environments, this is a major pain and in some
> > > cases, a
> > > >> > > > >> > non-starter.
> > > >> > > > >> > > It
> > > >> > > > >> > > > > > also challenges the validation that the
> coordinator
> > > can
> > > >> > > > provide.
> > > >> > > > >> > For
> > > >> > > > >> > > > > > example, some assignment strategies call for
> > > >> partitions to
> > > >> > > be
> > > >> > > > >> > > assigned
> > > >> > > > >> > > > > > multiple times, which means that the coordinator
> > can
> > > >> only
> > > >> > > > check
> > > >> > > > >> > that
> > > >> > > > >> > > > > > partitions have been assigned at least once.
> > > >> > > > >> > > > > >
> > > >> > > > >> > > > > > To solve these issues, we'd like to propose
> moving
> > > >> > > assignment
> > > >> > > > to
> > > >> > > > >> > the
> > > >> > > > >> > > > > > client. I've written a wiki which outlines some
> > > >> protocol
> > > >> > > > >> changes to
> > > >> > > > >> > > > > achieve
> > > >> > > > >> > > > > > this:
> > > >> > > > >> > > > > >
> > > >> > > > >> > > > > >
> > > >> > > > >> > > > >
> > > >> > > > >> > > >
> > > >> > > > >> > >
> > > >> > > > >> >
> > > >> > > > >>
> > > >> > > >
> > > >> > >
> > > >> >
> > > >>
> > >
> >
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> > > >> > > > >> > > > > > .
> > > >> > > > >> > > > > > To summarize briefly, instead of the coordinator
> > > >> assigning
> > > >> > > the
> > > >> > > > >> > > > partitions
> > > >> > > > >> > > > > > itself, all subscriptions are forwarded to each
> > > member
> > > >> of
> > > >> > > the
> > > >> > > > >> group
> > > >> > > > >> > > > which
> > > >> > > > >> > > > > > then decides independently which partitions it
> > should
> > > >> > > consume.
> > > >> > > > >> The
> > > >> > > > >> > > > > protocol
> > > >> > > > >> > > > > > provides a mechanism for the coordinator to
> > validate
> > > >> that
> > > >> > > all
> > > >> > > > >> > > consumers
> > > >> > > > >> > > > > use
> > > >> > > > >> > > > > > the same assignment strategy, but it does not
> > ensure
> > > >> that
> > > >> > > the
> > > >> > > > >> > > resulting
> > > >> > > > >> > > > > > assignment is "correct." This provides a powerful
> > > >> > capability
> > > >> > > > for
> > > >> > > > >> > > users
> > > >> > > > >> > > > to
> > > >> > > > >> > > > > > control the full data flow on the client side.
> They
> > > >> > control
> > > >> > > > how
> > > >> > > > >> > data
> > > >> > > > >> > > is
> > > >> > > > >> > > > > > written to partitions through the Partitioner
> > > interface
> > > >> > and
> > > >> > > > they
> > > >> > > > >> > > > control
> > > >> > > > >> > > > > > how data is consumed through the assignment
> > strategy,
> > > >> all
> > > >> > > > >> without
> > > >> > > > >> > > > > touching
> > > >> > > > >> > > > > > the server.
> > > >> > > > >> > > > > >
> > > >> > > > >> > > > > > Of course nothing comes for free. In particular,
> > this
> > > >> > change
> > > >> > > > >> > removes
> > > >> > > > >> > > > the
> > > >> > > > >> > > > > > ability of the coordinator to validate that
> commits
> > > are
> > > >> > made
> > > >> > > > by
> > > >> > > > >> > > > consumers
> > > >> > > > >> > > > > > who were assigned the respective partition. This
> > > might
> > > >> not
> > > >> > > be
> > > >> > > > >> too
> > > >> > > > >> > bad
> > > >> > > > >> > > > > since
> > > >> > > > >> > > > > > we retain the ability to validate the generation
> > id,
> > > >> but
> > > >> > it
> > > >> > > > is a
> > > >> > > > >> > > > > potential
> > > >> > > > >> > > > > > concern. We have considered alternative protocols
> > > which
> > > >> > add
> > > >> > > a
> > > >> > > > >> > second
> > > >> > > > >> > > > > > round-trip to the protocol in order to give the
> > > >> > coordinator
> > > >> > > > the
> > > >> > > > >> > > ability
> > > >> > > > >> > > > > to
> > > >> > > > >> > > > > > confirm the assignment. As mentioned above, the
> > > >> > coordinator
> > > >> > > is
> > > >> > > > >> > > somewhat
> > > >> > > > >> > > > > > limited in what it can actually validate, but
> this
> > > >> would
> > > >> > > > return
> > > >> > > > >> its
> > > >> > > > >> > > > > ability
> > > >> > > > >> > > > > > to validate commits. The tradeoff is that it
> > > increases
> > > >> the
> > > >> > > > >> > protocol's
> > > >> > > > >> > > > > > complexity which means more ways for the protocol
> > to
> > > >> fail
> > > >> > > and
> > > >> > > > >> > > > > consequently
> > > >> > > > >> > > > > > more edge cases in the code.
> > > >> > > > >> > > > > >
> > > >> > > > >> > > > > > It also misses an opportunity to generalize the
> > group
> > > >> > > > membership
> > > >> > > > >> > > > protocol
> > > >> > > > >> > > > > > for additional use cases. In fact, after you've
> > gone
> > > to
> > > >> > the
> > > >> > > > >> trouble
> > > >> > > > >> > > of
> > > >> > > > >> > > > > > moving assignment to the client, the main thing
> > that
> > > is
> > > >> > left
> > > >> > > > in
> > > >> > > > >> > this
> > > >> > > > >> > > > > > protocol is basically a general group management
> > > >> > capability.
> > > >> > > > >> This
> > > >> > > > >> > is
> > > >> > > > >> > > > > > exactly what is needed for a few cases that are
> > > >> currently
> > > >> > > > under
> > > >> > > > >> > > > > discussion
> > > >> > > > >> > > > > > (e.g. copycat or single-writer producer). We've
> > taken
> > > >> this
> > > >> > > > >> further
> > > >> > > > >> > > step
> > > >> > > > >> > > > > in
> > > >> > > > >> > > > > > the proposal and attempted to envision what that
> > > >> general
> > > >> > > > >> protocol
> > > >> > > > >> > > might
> > > >> > > > >> > > > > > look like and how it could be used both by the
> > > consumer
> > > >> > and
> > > >> > > > for
> > > >> > > > >> > some
> > > >> > > > >> > > of
> > > >> > > > >> > > > > > these other cases.
> > > >> > > > >> > > > > >
> > > >> > > > >> > > > > > Anyway, since time is running out on the new
> > > consumer,
> > > >> we
> > > >> > > have
> > > >> > > > >> > > perhaps
> > > >> > > > >> > > > > one
> > > >> > > > >> > > > > > last chance to consider a significant change in
> the
> > > >> > protocol
> > > >> > > > >> like
> > > >> > > > >> > > this,
> > > >> > > > >> > > > > so
> > > >> > > > >> > > > > > have a look at the wiki and share your thoughts.
> > I've
> > > >> no
> > > >> > > doubt
> > > >> > > > >> that
> > > >> > > > >> > > > some
> > > >> > > > >> > > > > > ideas seem clearer in my mind than they do on
> > paper,
> > > so
> > > >> > ask
> > > >> > > > >> > questions
> > > >> > > > >> > > > if
> > > >> > > > >> > > > > > there is any confusion.
> > > >> > > > >> > > > > >
> > > >> > > > >> > > > > > Thanks!
> > > >> > > > >> > > > > > Jason
> > > >> > > > >> > > > > >
> > > >> > > > >> > > > >
> > > >> > > > >> > > >
> > > >> > > > >> > > >
> > > >> > > > >> > > >
> > > >> > > > >> > > > --
> > > >> > > > >> > > > Thanks,
> > > >> > > > >> > > > Ewen
> > > >> > > > >> > > >
> > > >> > > > >> > >
> > > >> > > > >> >
> > > >> > > > >> >
> > > >> > > > >> >
> > > >> > > > >> > --
> > > >> > > > >> > Thanks,
> > > >> > > > >> > Ewen
> > > >> > > > >> >
> > > >> > > > >>
> > > >> > > > >
> > > >> > > > >
> > > >> > > >
> > > >> > >
> > > >> >
> > > >>
> > > >
> > > >
> > > >
> > > > --
> > > > Thanks,
> > > > Neha
> > > >
> > >
> > >
> > >
> > > --
> > > Thanks,
> > > Neha
> > >
> >
> >
> >
> > --
> > Thanks,
> > Ewen
> >
>



-- 
Thanks,
Ewen

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Jiangjie Qin <jq...@linkedin.com.INVALID>.
Neha and Ewen,

About the metadata change frequency. I guess it really depends on how
frequent the metadata change might occur. If we run Kafka as a service, I
can see that happens from time to time. As I can imagine people will create
some topic, test and maybe delete the topic in some automated test. If so,
the proposed protocol might be a little bit vulnerable.

More specifically the scenario I am thinking is:
1. Consumer 0 periodically refresh metadata and detected a metadata change.
So it sends a JoinGroupRequest with metadata_hash_0.
2. Consumer 1 was notified by controller to start a rebalance, so it
refreshes its metadata and send a JoingGroupRequest with metadata_hash_1,
which is different from metadata hash 0.
3. Rebalance failed and both consumer refresh there metadata again from
different brokers.
4. Depending on the metadata change frequency(or some admin operation like
partition reassigment), they may or may not have the same metadata
returned, so the restart from 3 again.

I agree that step 4 might not be a big concern if consumers updates
metadata at almost the same time, but I'm a little bit worried whether that
assumption really stands because we do not have control over how frequent
the metadata can change.

Thanks,

Jiangjie (Becket) Qin

On Fri, Aug 14, 2015 at 2:03 AM, Ewen Cheslack-Postava <ew...@confluent.io>
wrote:

> On Thu, Aug 13, 2015 at 11:07 PM, Neha Narkhede <ne...@confluent.io> wrote:
>
> > Becket,
> >
> > As you say, the metadata hash addresses the concern you originally raised
> > about large topic subscriptions. Can you please list other problems you
> are
> > raising more clearly? It is more helpful to know problems that the
> proposal
> > does not address or addresses poorly.
> >
> > Regarding other things you said -
> >
> > it is required that each
> > > consumer refresh their metadata before sending a JoinGroupRequest
> > >
> >
> > This is required for wildcard topic subscriptions anyway. So this
> proposal
> > does not introduce a regression. We had agreed earlier that it does not
> > make sense for the server to deserialize regular expressions sent by the
> > consumer.
> >
>
> I don't think consumers need to do a metadata refresh before sending a
> JoinGroupRequest. Metadata changes that affect assignment are rare -- it
> requires changing the number of partitions in a topic. But you might send a
> JoinGroupRequest simply because a new member is trying to join the group.
> That case is presumably much more common.
>
> I think it's actually a good idea to have the first JoinGroup cycle fail in
> some cases, and has little impact. Lets say the metadata does change
> because partitions are added. Then we might fail in the first round, but
> then all members detect that issue *immediately*, refresh their metadata,
> and submit a new join group request. This second cycle does not require a
> full heartbeat cycle. It happens much more quickly because everyone
> detected the inconsistency based on the first JoinGroupResponse. The
> inconsistency should be resolved very quickly (barring other failures like
> a member leaving mid-rebalance)




> >
> >
> > > the metadata might still be inconsistent if there is a topic or
> partition
> > > change because the
> > > UpdateMetadataRequest from controller might be handled at different
> time.
> > >
> >
> > Topic metadata does not change frequently and even if it did, a couple
> > rebalance attempts will be needed whether the coordinator drives the
> > assignments or the consumer. Because guess how the coordinator knows
> about
> > the topic metadata changes -- indirectly through either a zk callback or
> > UpdateMetadataRequest, so it is completely possible the coordinator sees
> > the topic metadata changes in batches, not all at once.
> >
>
> > On Thu, Aug 13, 2015 at 10:50 PM, Neha Narkhede <ne...@confluent.io>
> wrote:
> >
> > > Ewen/Jason,
> > >
> > > The metadata hash is a clever approach and certainly addresses the
> > problem
> > > of large metadata for consumers like mirror maker. Few comments -
> > >
> > >
> > >    1. In the interest of simplifying the format of the consumer's
> > >    metadata - Why not just always include only the topic names in the
> > metadata
> > >    followed by the metadata hash? If the metadata hash check succeeds,
> > each
> > >    consumer uses the # of partitions it had fetched. If it fails, a
> > rebalance
> > >    happens and the metadata is not used anyway.
> >
>
> Doing this requires that every consumer always fetch the full metadata. The
> most common use case is consumers that just want to consume one or a couple
> of topics, in which case grabbing all metadata for the entire cluster is
> wasteful. If I subscribe only to topic A, why make all consumers grab
> metadata for the entire topic (and need to rebalance every time it
> changes!). Including the # of partitions for each topic lets you avoid
> having to grab the global set of metadata.
>
> So if you're just subscribing to one or a couple of topics, why not just
> compute the hash by filtering out everything but the topics you are
> subscribed to? The problem there is if you ever add/remove subscriptions
> and want to support rolling upgrades. If the group was subscribed to topic
> A, but later changes require subscribing to A + B, then to achieve a
> seamless rolling upgrade would require one (old) consumer to be subscribing
> to A and one (new) consumer to be subscribing to A+B. If we computed
> metadata hashes based on filtered metadata, those two would disagree and we
> could not perform assignment while the upgrade was in progress.
>
> The solution is to differentiate between the cases when a very small amount
> of the metadata is needed (one or a couple of topic subscriptions;
> communicate and share this via metadata in the JoinGroup protocol) vs when
> *all* the metadata is needed (regex subscription; verify agreement via
> hash).
>

>
>
> > >    2. Do you need a topic list and topic regex to be separate? A single
> > >    topic or list of topics can be expressed as a regex.
> >
>
> See above note about collecting all metadata when you really only need it
> for 1 or 2 topics. There's probably some debate to be had about whether
> this cost would be too high -- every consumer would need to request the
> metadata for all topics, and they'd need to request that all every time
> they might be out of date.
>
Are we going to allow consumers in the same group to subscribe to different
topic set? If we do, we need to let them refresh metadata for all the
topics a group is consuming from. If we don't then in the protocol we only
need a subscription set hash.

>
>
> > >    3. Let's include a version explicitly at the beginning of the
> > >    ProtocolMetadata. The version dictates how to deserialize the
> > >    ProtocolMetadata blob and is consistent with the rest of Kafka.
> >
>
> If I'm understanding correctly, in JoinGroupRequest I would change
>
> GroupProtocols          => [Protocol ProtocolMetadata]
>
> to
>
> GroupProtocols          => [Protocol ProtocolVersion ProtocolMetadata]
>
> We had been talking about just baking the version into the Protocol field,
> but making it separate seems perfectly reasonable to me. Jason, any issue
> with splitting the version out into a separate field like this?
>
> >
> > > That can simplify the metadata format to the following:
> > >
> > > GroupType => "consumer"
> > >>
> > >> Protocol => AssignmentStrategy
> > >>   AssignmentStrategy   => String
> > >>
> > >> ProtocolMetadata => Version Subscription AssignmentStrategyMetadata
> > >
> > >     Version                    => String
> > >
> > >   Subscription                 => TopicRegex MetadataHash
> > >>     TopicRegex                 => String
> > >>     MetadataHash               => String
> > >>   AssignmentStrategyMetadata   => bytes
> >
> >
> > >
> > > On Thu, Aug 13, 2015 at 6:28 PM, Jiangjie Qin
> <jqin@linkedin.com.invalid
> > >
> > > wrote:
> > >
> > >> Ewen and Jason,
> > >>
> > >> Thanks for the reply. Sorry I missed the metadata hash. Yes, that is a
> > >> clever approach and would solve my concern about the data passing
> > around.
> > >> I
> > >> can see both pros and cons from doing this, though. The advantage is
> we
> > >> don't need the topic metadata in JoinGroupResponse anymore. The
> downside
> > >> is
> > >> that now rebalance have extra dependency on the consensus of metadata
> of
> > >> all consumers, which is obtained separately. So it is required that
> each
> > >> consumer refresh their metadata before sending a JoinGroupRequest,
> > >> otherwise in some cases (e.g. wildcard consumers) will almost
> certainly
> > >> fail for the first rebalance attempt. Even if we do that, since the
> > >> consumers are getting metadata from different brokers, the metadata
> > might
> > >> still be inconsistent if there is a topic or partition change because
> > the
> > >> UpdateMetadataRequest from controller might be handled at different
> > time.
> > >> Just want to make sure we think through the cases so the protocol does
> > not
> > >> cause us unexpected issues.
> > >>
> > >> About the number of consumers, I think with the current liveliness
> > >> definition, we can tolerate churns by bumping up the session timeout.
> > Also
> > >> I guess we will see an increasing number of consumers for new
> consumer,
> > >> because every the old consumer thread will probably become a consumer.
> > >>
> > >> It is a valid concern for consumers that have large subscription set.
> > This
> > >> might not be avoided though for client side assignment approach. One
> > >> solution is having topic names associate with a topic ID. And only use
> > >> topic ID in JoinGroupRequest and JoinGroupResponse, There is a
> > discussion
> > >> thread about this to solve the topic renaming case but this is a
> > >> completely
> > >> different discussion.
> > >>
> > >> Thanks,
> > >>
> > >> Jiangjie (Becket) Qin
> > >>
> > >>
> > >>
> > >> On Thu, Aug 13, 2015 at 2:14 PM, Jason Gustafson <ja...@confluent.io>
> > >> wrote:
> > >>
> > >> > Thanks Jiangjie, that information helps. I agree the protocol must
> > >> consider
> > >> > scalability. My point was that the synchronization barrier in the
> > >> current
> > >> > protocol already effectively limits the number of consumers since it
> > >> > provides no way to gracefully handle churn. It wouldn't be worth
> > >> worrying
> > >> > about scaling up to 100,000 members, for example, because there's no
> > way
> > >> > the group would be stable. So we just need to set some clear
> > >> expectations
> > >> > on the size we can scale to, and that can help inform the discussion
> > on
> > >> the
> > >> > size of messages in this protocol.
> > >> >
> > >> > Ewen and I were discussing this morning along similar lines to what
> > >> you're
> > >> > suggesting. However, even if the coordinator decides on the metadata
> > for
> > >> > the group, each member still needs to communicate its subscriptions
> to
> > >> the
> > >> > rest of the group. This is nice for the regex case since the regex
> is
> > >> > probably small, but if the members have a large topic list, then we
> > have
> > >> > the same problem. One thing I was thinking about was whether we
> really
> > >> need
> > >> > to handle different subscriptions for every member. If the
> coordinator
> > >> > could guarantee that all members had the same subscription, then
> there
> > >> > would be no need for the coordinator to return the subscriptions for
> > >> each
> > >> > member. However, this would prevent graceful upgrades. We might be
> > able
> > >> to
> > >> > fix that problem by allowing the consumer to provide two
> subscriptions
> > >> to
> > >> > allowing rolling updates, but that starts to sound pretty nasty.
> > >> >
> > >> > -Jason
> > >> >
> > >> > On Thu, Aug 13, 2015 at 1:41 PM, Jiangjie Qin
> > <jqin@linkedin.com.invalid
> > >> >
> > >> > wrote:
> > >> >
> > >> > > Jason,
> > >> > >
> > >> > > The protocol has to consider the scalability. The protocol in the
> > wiki
> > >> > > means the JoinGroupResoponse size would be:
> > >> > > NumberOfTopics * (AvgTopicNameLength + 4) * (NumberOfConsumers)^2
> > >> > >
> > >> > > To give some real number, we have 26-node Mirror Maker cluster,
> each
> > >> > with 4
> > >> > > consumers. That is 104 consumers using regex ".*". And most of our
> > >> > clusters
> > >> > > have around 3000 topics, whose topic name are typically around 20
> > >> > > characters.
> > >> > >
> > >> > > I think the key issue for client side partition assignment logic
> is
> > to
> > >> > make
> > >> > > sure 1) all the clients run the same algorithm. 2) all the clients
> > >> make
> > >> > > decision on the same topic metadata. The second purpose can be
> done
> > by
> > >> > > simply letting coordinator provide the topic metadata and all then
> > >> member
> > >> > > information as source of truth. Is it necessary to pass topic
> > >> metadata of
> > >> > > each consumer around? Can we keep the protocol metadata field
> > >> completely
> > >> > > independent of topic metadata? I think In the JoinGroupResponse,
> we
> > >> > should
> > >> > > have only one copy of topic metadata provided by coordinator and
> is
> > >> > outside
> > >> > > of protocol metadata. If user decides to put some metadata in the
> > >> > > JoinGroupRequest and let coordinator pass around, they are
> > responsible
> > >> > for
> > >> > > understanding the risk.
> > >> > >
> > >> > > Thanks,
> > >> > >
> > >> > > Jiangjie (Becket) Qin
> > >> > >
> > >> > >
> > >> > > On Thu, Aug 13, 2015 at 12:41 PM, Jason Gustafson <
> > jason@confluent.io
> > >> >
> > >> > > wrote:
> > >> > >
> > >> > > > Hey Onur and Jiangjie,
> > >> > > >
> > >> > > > I've updated that wiki with a proposal to add regex
> subscriptions
> > to
> > >> > the
> > >> > > > consumer metadata. Can you have a look to see if it addresses
> your
> > >> > > concern?
> > >> > > > In general, I think we should be a little careful when we are
> > >> talking
> > >> > > about
> > >> > > > the scalability of the protocol. Regardless of whether
> assignment
> > is
> > >> > done
> > >> > > > on the server or the client, the protocol assumes a relatively
> > >> stable
> > >> > > > configuration. When the number of consumers increases beyond a
> > >> certain
> > >> > > > limit, then membership churn becomes a major concern. Similarly
> > >> there
> > >> > is
> > >> > > a
> > >> > > > notion of metadata churn when topics are added, deleted, or
> > >> resized. If
> > >> > > > either membership or metadata changes, then the protocol forces
> > all
> > >> > > > consumers to stop consumption and rejoin the group. If this
> > happens
> > >> > often
> > >> > > > enough, then it can severely impact the ability of the consumer
> to
> > >> make
> > >> > > > progress. The point is that the protocol may already be unsuited
> > to
> > >> > cases
> > >> > > > where there are either a large number of consumers or topics. I
> > >> wonder
> > >> > if
> > >> > > > you guys can share your thoughts about your scaling
> expectations?
> > >> > > >
> > >> > > > -Jason
> > >> > > >
> > >> > > >
> > >> > > >
> > >> > > >
> > >> > > > On Wed, Aug 12, 2015 at 12:28 PM, Jason Gustafson <
> > >> jason@confluent.io>
> > >> > > > wrote:
> > >> > > >
> > >> > > > > Hey Jiangjie,
> > >> > > > >
> > >> > > > > That's a great point. In the worst case (the mirror maker
> case I
> > >> > > guess),
> > >> > > > > the join group response can be massive. This would be
> especially
> > >> > deadly
> > >> > > > > when there is a lot of churn in the group (e.g. in a rolling
> > >> > upgrade).
> > >> > > > The
> > >> > > > > current protocol is not great for this case either, but it's
> > >> > > > significantly
> > >> > > > > better. Here are a couple ways to deal with the size:
> > >> > > > >
> > >> > > > > 1. First, we could have the coordinator compress the
> responses.
> > >> This
> > >> > > > would
> > >> > > > > probably be pretty effective if applied across the metadata
> from
> > >> all
> > >> > > > > members.
> > >> > > > >
> > >> > > > > 2. I think the regex case is the main problem. Is that right?
> We
> > >> > could
> > >> > > > > extend the metadata to allow the consumer to embed its regex
> > >> > > subscription
> > >> > > > > in the metadata directly (note this might be a good idea
> > >> regardless
> > >> > of
> > >> > > > the
> > >> > > > > rest of this proposal). To support regex on the consumer, we
> > must
> > >> > fetch
> > >> > > > > metadata for all topics. Rather than having all regex
> > subscribers
> > >> > embed
> > >> > > > all
> > >> > > > > of this metadata in their join group requests, they could
> > instead
> > >> > > embed a
> > >> > > > > hash of it. Then after the join group responses are received,
> > they
> > >> > just
> > >> > > > > need to check that the hashes are the same. If there is a
> > mismatch
> > >> > > (which
> > >> > > > > should only occur when topics are created, deleted, or
> resized),
> > >> then
> > >> > > the
> > >> > > > > group members must refetch the metadata and rejoin the group.
> > >> This is
> > >> > > > also
> > >> > > > > how the current protocol behaves when there is a change in the
> > >> topic
> > >> > > > > metadata affecting the group--someone (either the coordinator
> or
> > >> the
> > >> > > > > consumer) detects the change and forces the group to
> rebalance.
> > >> > > > >
> > >> > > > > What do you think?
> > >> > > > >
> > >> > > > > (Also I think adding groupId/generationId to fetch and produce
> > >> > requests
> > >> > > > > seems like an interesting line of thought.)
> > >> > > > >
> > >> > > > > -Jason
> > >> > > > >
> > >> > > > >
> > >> > > > >
> > >> > > > > On Wed, Aug 12, 2015 at 10:57 AM, Jiangjie Qin
> > >> > > <jqin@linkedin.com.invalid
> > >> > > > >
> > >> > > > > wrote:
> > >> > > > >
> > >> > > > >> Hey Ewen,
> > >> > > > >>
> > >> > > > >> Onur and I discussed this a little bit more. And we are still
> > >> > worrying
> > >> > > > >> about passing all the metadata of all consumers around.
> > >> > > > >>
> > >> > > > >> Let's say I have a cluster has 10,000 topics, the average
> topic
> > >> name
> > >> > > > >> length
> > >> > > > >> is 10 bytes. In this case, the opaque metadata will have 10 *
> > >> > 10,000 =
> > >> > > > >> 100KB for topic name, for each topic, there is a 4-byte
> integer
> > >> of
> > >> > > > number
> > >> > > > >> of partitions, that's another 40KB. So one global topic
> > metadata
> > >> > will
> > >> > > > have
> > >> > > > >> 140KB data. If I have 100 consumers who are using wildcard to
> > >> > consume
> > >> > > > from
> > >> > > > >> all the topics. That means the protocol metadata end up in
> the
> > >> > > > >> JoinGroupResponse will be 140KB * 100 = 14MB. And the
> > >> > > JoinGroupResponse
> > >> > > > >> will need to be sent to 100 different consumers, that means
> > 14MB
> > >> *
> > >> > > 100 =
> > >> > > > >> 1.4GB need to be sent by the consumer coordinator for one
> > >> rebalance.
> > >> > > How
> > >> > > > >> would that work?
> > >> > > > >>
> > >> > > > >> Also, having two consumers (old owner and new owner)
> consuming
> > >> from
> > >> > > the
> > >> > > > >> same partition might also be a problem. e.g. people are
> > updating
> > >> > > > database.
> > >> > > > >> One thing might worth doing is to add GroupId and Generation
> ID
> > >> to
> > >> > > > >> ProducerRequest and FetchRequest as well. This will also help
> > >> with
> > >> > the
> > >> > > > >> single producer use case. However, this is probably
> orthogonal
> > to
> > >> > this
> > >> > > > >> thread given the current new consumer also has this problem
> > and I
> > >> > > > believe
> > >> > > > >> we need to fix it.
> > >> > > > >>
> > >> > > > >> Thanks,
> > >> > > > >>
> > >> > > > >> Jiangjie (Becket) Qin
> > >> > > > >>
> > >> > > > >> On Tue, Aug 11, 2015 at 11:43 PM, Ewen Cheslack-Postava <
> > >> > > > >> ewen@confluent.io>
> > >> > > > >> wrote:
> > >> > > > >>
> > >> > > > >> > On Tue, Aug 11, 2015 at 11:29 PM, Jiangjie Qin
> > >> > > > >> <jq...@linkedin.com.invalid>
> > >> > > > >> > wrote:
> > >> > > > >> >
> > >> > > > >> > > Ewen,
> > >> > > > >> > >
> > >> > > > >> > > Thanks for the explanation.
> > >> > > > >> > >
> > >> > > > >> > > For (1), I am more concerned about the failure case
> instead
> > >> of
> > >> > > > normal
> > >> > > > >> > case.
> > >> > > > >> > > What if a consumer somehow was kick out of a group but is
> > >> still
> > >> > > > >> consuming
> > >> > > > >> > > and committing offsets? Does that mean the new owner and
> > old
> > >> > owner
> > >> > > > >> might
> > >> > > > >> > > potentially consuming from and committing offsets for the
> > >> same
> > >> > > > >> partition?
> > >> > > > >> > > In the old consumer, this won't happen because the new
> > >> consumer
> > >> > > will
> > >> > > > >> not
> > >> > > > >> > be
> > >> > > > >> > > able to start consumption unless the previous owner has
> > >> released
> > >> > > its
> > >> > > > >> > > ownership. Basically, without the ownership guarantee, I
> > >> don't
> > >> > see
> > >> > > > how
> > >> > > > >> > the
> > >> > > > >> > > communication among consumers themselves alone can solve
> > the
> > >> > > problem
> > >> > > > >> > here.
> > >> > > > >> > >
> > >> > > > >> >
> > >> > > > >> > The generation ID check still applies to offset commits. If
> > >> one of
> > >> > > the
> > >> > > > >> > consumers is kicked out and misbehaving, it can obviously
> > still
> > >> > > fetch
> > >> > > > >> and
> > >> > > > >> > process messages, but offset commits will not work since it
> > >> will
> > >> > not
> > >> > > > >> have
> > >> > > > >> > the current generation ID.
> > >> > > > >> >
> > >> > > > >> >
> > >> > > > >> > >
> > >> > > > >> > > For (2) and (3), now I understand how metadata are used.
> > But
> > >> I
> > >> > > still
> > >> > > > >> > don't
> > >> > > > >> > > see why should we let the consumers to pass the topic
> > >> > information
> > >> > > > >> across
> > >> > > > >> > > instead of letting coordinator give the information. The
> > >> single
> > >> > > > >> producer
> > >> > > > >> > > use case does not solve the ownership problem in abnormal
> > >> case
> > >> > > > either,
> > >> > > > >> > > which seems to be a little bit vulnerable.
> > >> > > > >> > >
> > >> > > > >> >
> > >> > > > >> > One of the goals here was to generalize group membership so
> > we
> > >> > can,
> > >> > > > for
> > >> > > > >> > example, use it for balancing Copycat tasks across workers.
> > >> > There's
> > >> > > no
> > >> > > > >> > topic subscription info in that case. The metadata for
> > copycat
> > >> > > workers
> > >> > > > >> > would instead need to somehow indicate the current set of
> > tasks
> > >> > that
> > >> > > > >> need
> > >> > > > >> > to be assigned to workers. By making the metadata
> completely
> > >> > opaque
> > >> > > to
> > >> > > > >> the
> > >> > > > >> > protocol, it becomes more generally useful since it focuses
> > >> > squarely
> > >> > > > on
> > >> > > > >> the
> > >> > > > >> > group membership problem, allowing for that additional bit
> of
> > >> > > metadata
> > >> > > > >> so
> > >> > > > >> > you don't just get a list of members, but also get a little
> > >> bit of
> > >> > > > info
> > >> > > > >> > about each of them.
> > >> > > > >> >
> > >> > > > >> > A different option that we explored is to use a sort of
> mixed
> > >> > model
> > >> > > --
> > >> > > > >> > still bake all the topic subscriptions directly into the
> > >> protocol
> > >> > > but
> > >> > > > >> also
> > >> > > > >> > include metadata. That would allow us to maintain the
> > existing
> > >> > > > >> > coordinator-driven approach to handling the metadata and
> > change
> > >> > > events
> > >> > > > >> like
> > >> > > > >> > the ones Onur pointed out. Then something like the Copycat
> > >> workers
> > >> > > > would
> > >> > > > >> > just not fill in any topic subscriptions and it would be
> > >> handled
> > >> > as
> > >> > > a
> > >> > > > >> > degenerate case. Based on the way I explained that we can
> > >> handle
> > >> > > those
> > >> > > > >> > types of events, I personally feel its cleaner and a nicer
> > >> > > > >> generalization
> > >> > > > >> > to not include the subscriptions in the join group
> protocol,
> > >> > making
> > >> > > it
> > >> > > > >> part
> > >> > > > >> > of the metadata instead.
> > >> > > > >> >
> > >> > > > >> > For the single producer case, are you saying it doesn't
> solve
> > >> > > > ownership
> > >> > > > >> in
> > >> > > > >> > the abnormal case because a producer that doesn't know it
> has
> > >> been
> > >> > > > >> kicked
> > >> > > > >> > out of the group yet can still produce data even though it
> > >> > shouldn't
> > >> > > > be
> > >> > > > >> > able to anymore? I definitely agree that that is a risk --
> > this
> > >> > > > >> provides a
> > >> > > > >> > way to get closer to a true single-writer, but there are
> > >> > definitely
> > >> > > > >> still
> > >> > > > >> > failure modes that this does not address.
> > >> > > > >> >
> > >> > > > >> > -Ewen
> > >> > > > >> >
> > >> > > > >> >
> > >> > > > >> > >
> > >> > > > >> > > Thanks,
> > >> > > > >> > >
> > >> > > > >> > > Jiangjie (Becket) Qin
> > >> > > > >> > >
> > >> > > > >> > >
> > >> > > > >> > > On Tue, Aug 11, 2015 at 11:06 PM, Ewen Cheslack-Postava <
> > >> > > > >> > ewen@confluent.io
> > >> > > > >> > > >
> > >> > > > >> > > wrote:
> > >> > > > >> > >
> > >> > > > >> > > > On Tue, Aug 11, 2015 at 10:15 PM, Jiangjie Qin
> > >> > > > >> > <jqin@linkedin.com.invalid
> > >> > > > >> > > >
> > >> > > > >> > > > wrote:
> > >> > > > >> > > >
> > >> > > > >> > > > > Hi Jason,
> > >> > > > >> > > > >
> > >> > > > >> > > > > Thanks for writing this up. It would be useful to
> > >> generalize
> > >> > > the
> > >> > > > >> > group
> > >> > > > >> > > > > concept. I have a few questions below.
> > >> > > > >> > > > >
> > >> > > > >> > > > > 1. In old consumer actually the partition assignment
> > are
> > >> > done
> > >> > > by
> > >> > > > >> > > > consumers
> > >> > > > >> > > > > themselves. We used zookeeper to guarantee that a
> > >> partition
> > >> > > will
> > >> > > > >> only
> > >> > > > >> > > be
> > >> > > > >> > > > > consumed by one consumer thread who successfully
> > claimed
> > >> its
> > >> > > > >> > ownership.
> > >> > > > >> > > > > Does the new protocol plan to provide the same
> > guarantee?
> > >> > > > >> > > > >
> > >> > > > >> > > >
> > >> > > > >> > > > Once you have all the metadata from all the consumers,
> > >> > > assignment
> > >> > > > >> > should
> > >> > > > >> > > > just be a simple function mapping that Map<ConsumerId,
> > >> > Metadata>
> > >> > > > to
> > >> > > > >> > > > Map<ConsumerId, List<TopicPartition>>. If everyone is
> > >> > consistent
> > >> > > > in
> > >> > > > >> > > > computing that, you don't need ZK involved at all.
> > >> > > > >> > > >
> > >> > > > >> > > > In practice, this shouldn't be that hard to ensure for
> > most
> > >> > > > >> assignment
> > >> > > > >> > > > strategies just by having decent unit testing on them.
> > You
> > >> > just
> > >> > > > >> have to
> > >> > > > >> > > do
> > >> > > > >> > > > things like ensure your assignment strategy sorts lists
> > >> into a
> > >> > > > >> > consistent
> > >> > > > >> > > > order.
> > >> > > > >> > > >
> > >> > > > >> > > > You do give up the ability to use some techniques (e.g.
> > any
> > >> > > > >> randomized
> > >> > > > >> > > > algorithm if you can't distribute the seed w/ the
> > metadata)
> > >> > and
> > >> > > > it's
> > >> > > > >> > true
> > >> > > > >> > > > that nothing validates the assignment, but if that
> > >> assignment
> > >> > > > >> algorithm
> > >> > > > >> > > > step is kept simple, small, and well tested, the risk
> is
> > >> very
> > >> > > > >> minimal.
> > >> > > > >> > > >
> > >> > > > >> > > >
> > >> > > > >> > > > >
> > >> > > > >> > > > > 2. It looks that both JoinGroupRequest and
> > >> JoinGroupResponse
> > >> > > has
> > >> > > > >> the
> > >> > > > >> > > > > ProtocolMetadata.AssignmentStrategyMetadata, what
> would
> > >> be
> > >> > the
> > >> > > > >> > metadata
> > >> > > > >> > > > be
> > >> > > > >> > > > > sent and returned by coordinator? How will the
> > >> coordinator
> > >> > > > handle
> > >> > > > >> the
> > >> > > > >> > > > > metadata?
> > >> > > > >> > > > >
> > >> > > > >> > > >
> > >> > > > >> > > > The coordinator is basically just blindly broadcasting
> > all
> > >> of
> > >> > it
> > >> > > > to
> > >> > > > >> > group
> > >> > > > >> > > > members so they have a consistent view.
> > >> > > > >> > > >
> > >> > > > >> > > > So from the coordinators perspective, it sees something
> > >> like:
> > >> > > > >> > > >
> > >> > > > >> > > > Consumer 1 -> JoinGroupRequest with GroupProtocols = [
> > >> > > "consumer"
> > >> > > > >> > > > <Consumer1 opaque byte[]>]
> > >> > > > >> > > > Consumer 2 -> JoinGroupRequest with GroupProtocols = [
> > >> > > "consumer"
> > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > >> > > > >> > > >
> > >> > > > >> > > > Then, in the responses would look like:
> > >> > > > >> > > >
> > >> > > > >> > > > Consumer 1 <- JoinGroupResponse with GroupProtocol =
> > >> > "consumer"
> > >> > > > and
> > >> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque byte[]>,
> > >> > Consumer
> > >> > > 2
> > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > >> > > > >> > > > Consumer 2 <- JoinGroupResponse with GroupProtocol =
> > >> > "consumer"
> > >> > > > and
> > >> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque byte[]>,
> > >> > Consumer
> > >> > > 2
> > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > >> > > > >> > > >
> > >> > > > >> > > > So all the responses include all the metadata for every
> > >> member
> > >> > > in
> > >> > > > >> the
> > >> > > > >> > > > group, and everyone can use that to consistently decide
> > on
> > >> > > > >> assignment.
> > >> > > > >> > > The
> > >> > > > >> > > > broker doesn't care and cannot even understand the
> > metadata
> > >> > > since
> > >> > > > >> the
> > >> > > > >> > > data
> > >> > > > >> > > > format for it is dependent on the assignment strategy
> > being
> > >> > > used.
> > >> > > > >> > > >
> > >> > > > >> > > > As another example that is *not* a consumer, let's say
> > you
> > >> > just
> > >> > > > >> want to
> > >> > > > >> > > > have a single writer in the group which everyone will
> > >> forward
> > >> > > > >> requests
> > >> > > > >> > > to.
> > >> > > > >> > > > To accomplish this, you could use a very dumb
> assignment
> > >> > > strategy:
> > >> > > > >> > there
> > >> > > > >> > > is
> > >> > > > >> > > > no metadata (empty byte[]) and all we care about is who
> > is
> > >> the
> > >> > > > first
> > >> > > > >> > > member
> > >> > > > >> > > > in the group (e.g. when IDs are sorted
> > lexicographically).
> > >> > That
> > >> > > > >> member
> > >> > > > >> > is
> > >> > > > >> > > > selected as the writer. In that case, we actually just
> > care
> > >> > > about
> > >> > > > >> the
> > >> > > > >> > > > membership list, there's no additional info about each
> > >> member
> > >> > > that
> > >> > > > >> is
> > >> > > > >> > > > required to determine who is the writer.
> > >> > > > >> > > >
> > >> > > > >> > > >
> > >> > > > >> > > > > 3. Do you mean that the number of partitions in
> > >> > > > JoinGroupResponse
> > >> > > > >> > will
> > >> > > > >> > > be
> > >> > > > >> > > > > the max partition number of a topic among all the
> > >> reported
> > >> > > > >> partition
> > >> > > > >> > > > number
> > >> > > > >> > > > > by consumers? Is there any reason not just let
> > >> Coordinator
> > >> > to
> > >> > > > >> return
> > >> > > > >> > > the
> > >> > > > >> > > > > number of partitions of a topic in its metadata
> cache?
> > >> > > > >> > > > >
> > >> > > > >> > > >
> > >> > > > >> > > > Nothing from the embedded protocol is touched by the
> > >> broker.
> > >> > The
> > >> > > > >> broker
> > >> > > > >> > > > just collects opaque bytes of metadata, does the
> > selection
> > >> of
> > >> > > the
> > >> > > > >> > > strategy
> > >> > > > >> > > > if multiple are supported by some consumers, and then
> > >> returns
> > >> > > that
> > >> > > > >> > opaque
> > >> > > > >> > > > metadata for all the members back to every member. In
> > that
> > >> way
> > >> > > > they
> > >> > > > >> all
> > >> > > > >> > > > have a consistent view of the group. For regular
> > consumers,
> > >> > that
> > >> > > > >> view
> > >> > > > >> > of
> > >> > > > >> > > > the group includes information about how many
> partitions
> > >> each
> > >> > > > >> consumer
> > >> > > > >> > > > currently thinks the topics it is subscribed to has.
> > These
> > >> > could
> > >> > > > be
> > >> > > > >> > > > inconsistent due to out of date metadata and it would
> be
> > >> up to
> > >> > > the
> > >> > > > >> > > > assignment strategy on the *client* to resolve that. As
> > you
> > >> > > point
> > >> > > > >> out,
> > >> > > > >> > in
> > >> > > > >> > > > that case they could just take the max value that any
> > >> consumer
> > >> > > > >> reported
> > >> > > > >> > > > seeing and use that. The consumers that notice that
> their
> > >> > > metadata
> > >> > > > >> had
> > >> > > > >> > a
> > >> > > > >> > > > smaller # of partitions should also trigger a metadata
> > >> update
> > >> > > when
> > >> > > > >> they
> > >> > > > >> > > see
> > >> > > > >> > > > someone else observing a larger # of partitions.
> > >> > > > >> > > >
> > >> > > > >> > > >
> > >> > > > >> > > > >
> > >> > > > >> > > > > Thanks,
> > >> > > > >> > > > >
> > >> > > > >> > > > > Jiangjie (Becket) Qin
> > >> > > > >> > > > >
> > >> > > > >> > > > >
> > >> > > > >> > > > >
> > >> > > > >> > > > >
> > >> > > > >> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <
> > >> > > > >> jason@confluent.io
> > >> > > > >> > >
> > >> > > > >> > > > > wrote:
> > >> > > > >> > > > >
> > >> > > > >> > > > > > Hi Kafka Devs,
> > >> > > > >> > > > > >
> > >> > > > >> > > > > > One of the nagging issues in the current design of
> > the
> > >> new
> > >> > > > >> consumer
> > >> > > > >> > > has
> > >> > > > >> > > > > > been the need to support a variety of assignment
> > >> > strategies.
> > >> > > > >> We've
> > >> > > > >> > > > > > encountered this in particular in the design of
> > copycat
> > >> > and
> > >> > > > the
> > >> > > > >> > > > > processing
> > >> > > > >> > > > > > framework (KIP-28). From what I understand, Samza
> > also
> > >> > has a
> > >> > > > >> number
> > >> > > > >> > > of
> > >> > > > >> > > > > use
> > >> > > > >> > > > > > cases with custom assignment needs. The new
> consumer
> > >> > > protocol
> > >> > > > >> > > supports
> > >> > > > >> > > > > new
> > >> > > > >> > > > > > assignment strategies by hooking them into the
> > broker.
> > >> For
> > >> > > > many
> > >> > > > >> > > > > > environments, this is a major pain and in some
> > cases, a
> > >> > > > >> > non-starter.
> > >> > > > >> > > It
> > >> > > > >> > > > > > also challenges the validation that the coordinator
> > can
> > >> > > > provide.
> > >> > > > >> > For
> > >> > > > >> > > > > > example, some assignment strategies call for
> > >> partitions to
> > >> > > be
> > >> > > > >> > > assigned
> > >> > > > >> > > > > > multiple times, which means that the coordinator
> can
> > >> only
> > >> > > > check
> > >> > > > >> > that
> > >> > > > >> > > > > > partitions have been assigned at least once.
> > >> > > > >> > > > > >
> > >> > > > >> > > > > > To solve these issues, we'd like to propose moving
> > >> > > assignment
> > >> > > > to
> > >> > > > >> > the
> > >> > > > >> > > > > > client. I've written a wiki which outlines some
> > >> protocol
> > >> > > > >> changes to
> > >> > > > >> > > > > achieve
> > >> > > > >> > > > > > this:
> > >> > > > >> > > > > >
> > >> > > > >> > > > > >
> > >> > > > >> > > > >
> > >> > > > >> > > >
> > >> > > > >> > >
> > >> > > > >> >
> > >> > > > >>
> > >> > > >
> > >> > >
> > >> >
> > >>
> >
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> > >> > > > >> > > > > > .
> > >> > > > >> > > > > > To summarize briefly, instead of the coordinator
> > >> assigning
> > >> > > the
> > >> > > > >> > > > partitions
> > >> > > > >> > > > > > itself, all subscriptions are forwarded to each
> > member
> > >> of
> > >> > > the
> > >> > > > >> group
> > >> > > > >> > > > which
> > >> > > > >> > > > > > then decides independently which partitions it
> should
> > >> > > consume.
> > >> > > > >> The
> > >> > > > >> > > > > protocol
> > >> > > > >> > > > > > provides a mechanism for the coordinator to
> validate
> > >> that
> > >> > > all
> > >> > > > >> > > consumers
> > >> > > > >> > > > > use
> > >> > > > >> > > > > > the same assignment strategy, but it does not
> ensure
> > >> that
> > >> > > the
> > >> > > > >> > > resulting
> > >> > > > >> > > > > > assignment is "correct." This provides a powerful
> > >> > capability
> > >> > > > for
> > >> > > > >> > > users
> > >> > > > >> > > > to
> > >> > > > >> > > > > > control the full data flow on the client side. They
> > >> > control
> > >> > > > how
> > >> > > > >> > data
> > >> > > > >> > > is
> > >> > > > >> > > > > > written to partitions through the Partitioner
> > interface
> > >> > and
> > >> > > > they
> > >> > > > >> > > > control
> > >> > > > >> > > > > > how data is consumed through the assignment
> strategy,
> > >> all
> > >> > > > >> without
> > >> > > > >> > > > > touching
> > >> > > > >> > > > > > the server.
> > >> > > > >> > > > > >
> > >> > > > >> > > > > > Of course nothing comes for free. In particular,
> this
> > >> > change
> > >> > > > >> > removes
> > >> > > > >> > > > the
> > >> > > > >> > > > > > ability of the coordinator to validate that commits
> > are
> > >> > made
> > >> > > > by
> > >> > > > >> > > > consumers
> > >> > > > >> > > > > > who were assigned the respective partition. This
> > might
> > >> not
> > >> > > be
> > >> > > > >> too
> > >> > > > >> > bad
> > >> > > > >> > > > > since
> > >> > > > >> > > > > > we retain the ability to validate the generation
> id,
> > >> but
> > >> > it
> > >> > > > is a
> > >> > > > >> > > > > potential
> > >> > > > >> > > > > > concern. We have considered alternative protocols
> > which
> > >> > add
> > >> > > a
> > >> > > > >> > second
> > >> > > > >> > > > > > round-trip to the protocol in order to give the
> > >> > coordinator
> > >> > > > the
> > >> > > > >> > > ability
> > >> > > > >> > > > > to
> > >> > > > >> > > > > > confirm the assignment. As mentioned above, the
> > >> > coordinator
> > >> > > is
> > >> > > > >> > > somewhat
> > >> > > > >> > > > > > limited in what it can actually validate, but this
> > >> would
> > >> > > > return
> > >> > > > >> its
> > >> > > > >> > > > > ability
> > >> > > > >> > > > > > to validate commits. The tradeoff is that it
> > increases
> > >> the
> > >> > > > >> > protocol's
> > >> > > > >> > > > > > complexity which means more ways for the protocol
> to
> > >> fail
> > >> > > and
> > >> > > > >> > > > > consequently
> > >> > > > >> > > > > > more edge cases in the code.
> > >> > > > >> > > > > >
> > >> > > > >> > > > > > It also misses an opportunity to generalize the
> group
> > >> > > > membership
> > >> > > > >> > > > protocol
> > >> > > > >> > > > > > for additional use cases. In fact, after you've
> gone
> > to
> > >> > the
> > >> > > > >> trouble
> > >> > > > >> > > of
> > >> > > > >> > > > > > moving assignment to the client, the main thing
> that
> > is
> > >> > left
> > >> > > > in
> > >> > > > >> > this
> > >> > > > >> > > > > > protocol is basically a general group management
> > >> > capability.
> > >> > > > >> This
> > >> > > > >> > is
> > >> > > > >> > > > > > exactly what is needed for a few cases that are
> > >> currently
> > >> > > > under
> > >> > > > >> > > > > discussion
> > >> > > > >> > > > > > (e.g. copycat or single-writer producer). We've
> taken
> > >> this
> > >> > > > >> further
> > >> > > > >> > > step
> > >> > > > >> > > > > in
> > >> > > > >> > > > > > the proposal and attempted to envision what that
> > >> general
> > >> > > > >> protocol
> > >> > > > >> > > might
> > >> > > > >> > > > > > look like and how it could be used both by the
> > consumer
> > >> > and
> > >> > > > for
> > >> > > > >> > some
> > >> > > > >> > > of
> > >> > > > >> > > > > > these other cases.
> > >> > > > >> > > > > >
> > >> > > > >> > > > > > Anyway, since time is running out on the new
> > consumer,
> > >> we
> > >> > > have
> > >> > > > >> > > perhaps
> > >> > > > >> > > > > one
> > >> > > > >> > > > > > last chance to consider a significant change in the
> > >> > protocol
> > >> > > > >> like
> > >> > > > >> > > this,
> > >> > > > >> > > > > so
> > >> > > > >> > > > > > have a look at the wiki and share your thoughts.
> I've
> > >> no
> > >> > > doubt
> > >> > > > >> that
> > >> > > > >> > > > some
> > >> > > > >> > > > > > ideas seem clearer in my mind than they do on
> paper,
> > so
> > >> > ask
> > >> > > > >> > questions
> > >> > > > >> > > > if
> > >> > > > >> > > > > > there is any confusion.
> > >> > > > >> > > > > >
> > >> > > > >> > > > > > Thanks!
> > >> > > > >> > > > > > Jason
> > >> > > > >> > > > > >
> > >> > > > >> > > > >
> > >> > > > >> > > >
> > >> > > > >> > > >
> > >> > > > >> > > >
> > >> > > > >> > > > --
> > >> > > > >> > > > Thanks,
> > >> > > > >> > > > Ewen
> > >> > > > >> > > >
> > >> > > > >> > >
> > >> > > > >> >
> > >> > > > >> >
> > >> > > > >> >
> > >> > > > >> > --
> > >> > > > >> > Thanks,
> > >> > > > >> > Ewen
> > >> > > > >> >
> > >> > > > >>
> > >> > > > >
> > >> > > > >
> > >> > > >
> > >> > >
> > >> >
> > >>
> > >
> > >
> > >
> > > --
> > > Thanks,
> > > Neha
> > >
> >
> >
> >
> > --
> > Thanks,
> > Neha
> >
>
>
>
> --
> Thanks,
> Ewen
>

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Jason Gustafson <ja...@confluent.io>.
Ewen, I have no problem with adding an explicit version. As you mentioned,
I was thinking that each protocol would manage that in its name field, but
the explicit field is probably clearer for implementors.

Becket, I was also a little concerned that the consumers would have some
difficulty agreeing on the metadata. That is why I brought up the point of
metadata churn. The protocol (current and proposed) just doesn't work well
when stuff changes frequently. Ewen's point is interesting though. Assuming
metadata changes are relatively rare, convergence should be fast.

-Jason

On Fri, Aug 14, 2015 at 2:03 AM, Ewen Cheslack-Postava <ew...@confluent.io>
wrote:

> On Thu, Aug 13, 2015 at 11:07 PM, Neha Narkhede <ne...@confluent.io> wrote:
>
> > Becket,
> >
> > As you say, the metadata hash addresses the concern you originally raised
> > about large topic subscriptions. Can you please list other problems you
> are
> > raising more clearly? It is more helpful to know problems that the
> proposal
> > does not address or addresses poorly.
> >
> > Regarding other things you said -
> >
> > it is required that each
> > > consumer refresh their metadata before sending a JoinGroupRequest
> > >
> >
> > This is required for wildcard topic subscriptions anyway. So this
> proposal
> > does not introduce a regression. We had agreed earlier that it does not
> > make sense for the server to deserialize regular expressions sent by the
> > consumer.
> >
>
> I don't think consumers need to do a metadata refresh before sending a
> JoinGroupRequest. Metadata changes that affect assignment are rare -- it
> requires changing the number of partitions in a topic. But you might send a
> JoinGroupRequest simply because a new member is trying to join the group.
> That case is presumably much more common.
>
> I think it's actually a good idea to have the first JoinGroup cycle fail in
> some cases, and has little impact. Lets say the metadata does change
> because partitions are added. Then we might fail in the first round, but
> then all members detect that issue *immediately*, refresh their metadata,
> and submit a new join group request. This second cycle does not require a
> full heartbeat cycle. It happens much more quickly because everyone
> detected the inconsistency based on the first JoinGroupResponse. The
> inconsistency should be resolved very quickly (barring other failures like
> a member leaving mid-rebalance).
>
>
> >
> >
> > > the metadata might still be inconsistent if there is a topic or
> partition
> > > change because the
> > > UpdateMetadataRequest from controller might be handled at different
> time.
> > >
> >
> > Topic metadata does not change frequently and even if it did, a couple
> > rebalance attempts will be needed whether the coordinator drives the
> > assignments or the consumer. Because guess how the coordinator knows
> about
> > the topic metadata changes -- indirectly through either a zk callback or
> > UpdateMetadataRequest, so it is completely possible the coordinator sees
> > the topic metadata changes in batches, not all at once.
> >
>
> > On Thu, Aug 13, 2015 at 10:50 PM, Neha Narkhede <ne...@confluent.io>
> wrote:
> >
> > > Ewen/Jason,
> > >
> > > The metadata hash is a clever approach and certainly addresses the
> > problem
> > > of large metadata for consumers like mirror maker. Few comments -
> > >
> > >
> > >    1. In the interest of simplifying the format of the consumer's
> > >    metadata - Why not just always include only the topic names in the
> > metadata
> > >    followed by the metadata hash? If the metadata hash check succeeds,
> > each
> > >    consumer uses the # of partitions it had fetched. If it fails, a
> > rebalance
> > >    happens and the metadata is not used anyway.
> >
>
> Doing this requires that every consumer always fetch the full metadata. The
> most common use case is consumers that just want to consume one or a couple
> of topics, in which case grabbing all metadata for the entire cluster is
> wasteful. If I subscribe only to topic A, why make all consumers grab
> metadata for the entire topic (and need to rebalance every time it
> changes!). Including the # of partitions for each topic lets you avoid
> having to grab the global set of metadata.
>
> So if you're just subscribing to one or a couple of topics, why not just
> compute the hash by filtering out everything but the topics you are
> subscribed to? The problem there is if you ever add/remove subscriptions
> and want to support rolling upgrades. If the group was subscribed to topic
> A, but later changes require subscribing to A + B, then to achieve a
> seamless rolling upgrade would require one (old) consumer to be subscribing
> to A and one (new) consumer to be subscribing to A+B. If we computed
> metadata hashes based on filtered metadata, those two would disagree and we
> could not perform assignment while the upgrade was in progress.
>
> The solution is to differentiate between the cases when a very small amount
> of the metadata is needed (one or a couple of topic subscriptions;
> communicate and share this via metadata in the JoinGroup protocol) vs when
> *all* the metadata is needed (regex subscription; verify agreement via
> hash).
>
>
>
> > >    2. Do you need a topic list and topic regex to be separate? A single
> > >    topic or list of topics can be expressed as a regex.
> >
>
> See above note about collecting all metadata when you really only need it
> for 1 or 2 topics. There's probably some debate to be had about whether
> this cost would be too high -- every consumer would need to request the
> metadata for all topics, and they'd need to request that all every time
> they might be out of date.
>
>
> > >    3. Let's include a version explicitly at the beginning of the
> > >    ProtocolMetadata. The version dictates how to deserialize the
> > >    ProtocolMetadata blob and is consistent with the rest of Kafka.
> >
>
> If I'm understanding correctly, in JoinGroupRequest I would change
>
> GroupProtocols          => [Protocol ProtocolMetadata]
>
> to
>
> GroupProtocols          => [Protocol ProtocolVersion ProtocolMetadata]
>
> We had been talking about just baking the version into the Protocol field,
> but making it separate seems perfectly reasonable to me. Jason, any issue
> with splitting the version out into a separate field like this?
>
> >
> > > That can simplify the metadata format to the following:
> > >
> > > GroupType => "consumer"
> > >>
> > >> Protocol => AssignmentStrategy
> > >>   AssignmentStrategy   => String
> > >>
> > >> ProtocolMetadata => Version Subscription AssignmentStrategyMetadata
> > >
> > >     Version                    => String
> > >
> > >   Subscription                 => TopicRegex MetadataHash
> > >>     TopicRegex                 => String
> > >>     MetadataHash               => String
> > >>   AssignmentStrategyMetadata   => bytes
> >
> >
> > >
> > > On Thu, Aug 13, 2015 at 6:28 PM, Jiangjie Qin
> <jqin@linkedin.com.invalid
> > >
> > > wrote:
> > >
> > >> Ewen and Jason,
> > >>
> > >> Thanks for the reply. Sorry I missed the metadata hash. Yes, that is a
> > >> clever approach and would solve my concern about the data passing
> > around.
> > >> I
> > >> can see both pros and cons from doing this, though. The advantage is
> we
> > >> don't need the topic metadata in JoinGroupResponse anymore. The
> downside
> > >> is
> > >> that now rebalance have extra dependency on the consensus of metadata
> of
> > >> all consumers, which is obtained separately. So it is required that
> each
> > >> consumer refresh their metadata before sending a JoinGroupRequest,
> > >> otherwise in some cases (e.g. wildcard consumers) will almost
> certainly
> > >> fail for the first rebalance attempt. Even if we do that, since the
> > >> consumers are getting metadata from different brokers, the metadata
> > might
> > >> still be inconsistent if there is a topic or partition change because
> > the
> > >> UpdateMetadataRequest from controller might be handled at different
> > time.
> > >> Just want to make sure we think through the cases so the protocol does
> > not
> > >> cause us unexpected issues.
> > >>
> > >> About the number of consumers, I think with the current liveliness
> > >> definition, we can tolerate churns by bumping up the session timeout.
> > Also
> > >> I guess we will see an increasing number of consumers for new
> consumer,
> > >> because every the old consumer thread will probably become a consumer.
> > >>
> > >> It is a valid concern for consumers that have large subscription set.
> > This
> > >> might not be avoided though for client side assignment approach. One
> > >> solution is having topic names associate with a topic ID. And only use
> > >> topic ID in JoinGroupRequest and JoinGroupResponse, There is a
> > discussion
> > >> thread about this to solve the topic renaming case but this is a
> > >> completely
> > >> different discussion.
> > >>
> > >> Thanks,
> > >>
> > >> Jiangjie (Becket) Qin
> > >>
> > >>
> > >>
> > >> On Thu, Aug 13, 2015 at 2:14 PM, Jason Gustafson <ja...@confluent.io>
> > >> wrote:
> > >>
> > >> > Thanks Jiangjie, that information helps. I agree the protocol must
> > >> consider
> > >> > scalability. My point was that the synchronization barrier in the
> > >> current
> > >> > protocol already effectively limits the number of consumers since it
> > >> > provides no way to gracefully handle churn. It wouldn't be worth
> > >> worrying
> > >> > about scaling up to 100,000 members, for example, because there's no
> > way
> > >> > the group would be stable. So we just need to set some clear
> > >> expectations
> > >> > on the size we can scale to, and that can help inform the discussion
> > on
> > >> the
> > >> > size of messages in this protocol.
> > >> >
> > >> > Ewen and I were discussing this morning along similar lines to what
> > >> you're
> > >> > suggesting. However, even if the coordinator decides on the metadata
> > for
> > >> > the group, each member still needs to communicate its subscriptions
> to
> > >> the
> > >> > rest of the group. This is nice for the regex case since the regex
> is
> > >> > probably small, but if the members have a large topic list, then we
> > have
> > >> > the same problem. One thing I was thinking about was whether we
> really
> > >> need
> > >> > to handle different subscriptions for every member. If the
> coordinator
> > >> > could guarantee that all members had the same subscription, then
> there
> > >> > would be no need for the coordinator to return the subscriptions for
> > >> each
> > >> > member. However, this would prevent graceful upgrades. We might be
> > able
> > >> to
> > >> > fix that problem by allowing the consumer to provide two
> subscriptions
> > >> to
> > >> > allowing rolling updates, but that starts to sound pretty nasty.
> > >> >
> > >> > -Jason
> > >> >
> > >> > On Thu, Aug 13, 2015 at 1:41 PM, Jiangjie Qin
> > <jqin@linkedin.com.invalid
> > >> >
> > >> > wrote:
> > >> >
> > >> > > Jason,
> > >> > >
> > >> > > The protocol has to consider the scalability. The protocol in the
> > wiki
> > >> > > means the JoinGroupResoponse size would be:
> > >> > > NumberOfTopics * (AvgTopicNameLength + 4) * (NumberOfConsumers)^2
> > >> > >
> > >> > > To give some real number, we have 26-node Mirror Maker cluster,
> each
> > >> > with 4
> > >> > > consumers. That is 104 consumers using regex ".*". And most of our
> > >> > clusters
> > >> > > have around 3000 topics, whose topic name are typically around 20
> > >> > > characters.
> > >> > >
> > >> > > I think the key issue for client side partition assignment logic
> is
> > to
> > >> > make
> > >> > > sure 1) all the clients run the same algorithm. 2) all the clients
> > >> make
> > >> > > decision on the same topic metadata. The second purpose can be
> done
> > by
> > >> > > simply letting coordinator provide the topic metadata and all then
> > >> member
> > >> > > information as source of truth. Is it necessary to pass topic
> > >> metadata of
> > >> > > each consumer around? Can we keep the protocol metadata field
> > >> completely
> > >> > > independent of topic metadata? I think In the JoinGroupResponse,
> we
> > >> > should
> > >> > > have only one copy of topic metadata provided by coordinator and
> is
> > >> > outside
> > >> > > of protocol metadata. If user decides to put some metadata in the
> > >> > > JoinGroupRequest and let coordinator pass around, they are
> > responsible
> > >> > for
> > >> > > understanding the risk.
> > >> > >
> > >> > > Thanks,
> > >> > >
> > >> > > Jiangjie (Becket) Qin
> > >> > >
> > >> > >
> > >> > > On Thu, Aug 13, 2015 at 12:41 PM, Jason Gustafson <
> > jason@confluent.io
> > >> >
> > >> > > wrote:
> > >> > >
> > >> > > > Hey Onur and Jiangjie,
> > >> > > >
> > >> > > > I've updated that wiki with a proposal to add regex
> subscriptions
> > to
> > >> > the
> > >> > > > consumer metadata. Can you have a look to see if it addresses
> your
> > >> > > concern?
> > >> > > > In general, I think we should be a little careful when we are
> > >> talking
> > >> > > about
> > >> > > > the scalability of the protocol. Regardless of whether
> assignment
> > is
> > >> > done
> > >> > > > on the server or the client, the protocol assumes a relatively
> > >> stable
> > >> > > > configuration. When the number of consumers increases beyond a
> > >> certain
> > >> > > > limit, then membership churn becomes a major concern. Similarly
> > >> there
> > >> > is
> > >> > > a
> > >> > > > notion of metadata churn when topics are added, deleted, or
> > >> resized. If
> > >> > > > either membership or metadata changes, then the protocol forces
> > all
> > >> > > > consumers to stop consumption and rejoin the group. If this
> > happens
> > >> > often
> > >> > > > enough, then it can severely impact the ability of the consumer
> to
> > >> make
> > >> > > > progress. The point is that the protocol may already be unsuited
> > to
> > >> > cases
> > >> > > > where there are either a large number of consumers or topics. I
> > >> wonder
> > >> > if
> > >> > > > you guys can share your thoughts about your scaling
> expectations?
> > >> > > >
> > >> > > > -Jason
> > >> > > >
> > >> > > >
> > >> > > >
> > >> > > >
> > >> > > > On Wed, Aug 12, 2015 at 12:28 PM, Jason Gustafson <
> > >> jason@confluent.io>
> > >> > > > wrote:
> > >> > > >
> > >> > > > > Hey Jiangjie,
> > >> > > > >
> > >> > > > > That's a great point. In the worst case (the mirror maker
> case I
> > >> > > guess),
> > >> > > > > the join group response can be massive. This would be
> especially
> > >> > deadly
> > >> > > > > when there is a lot of churn in the group (e.g. in a rolling
> > >> > upgrade).
> > >> > > > The
> > >> > > > > current protocol is not great for this case either, but it's
> > >> > > > significantly
> > >> > > > > better. Here are a couple ways to deal with the size:
> > >> > > > >
> > >> > > > > 1. First, we could have the coordinator compress the
> responses.
> > >> This
> > >> > > > would
> > >> > > > > probably be pretty effective if applied across the metadata
> from
> > >> all
> > >> > > > > members.
> > >> > > > >
> > >> > > > > 2. I think the regex case is the main problem. Is that right?
> We
> > >> > could
> > >> > > > > extend the metadata to allow the consumer to embed its regex
> > >> > > subscription
> > >> > > > > in the metadata directly (note this might be a good idea
> > >> regardless
> > >> > of
> > >> > > > the
> > >> > > > > rest of this proposal). To support regex on the consumer, we
> > must
> > >> > fetch
> > >> > > > > metadata for all topics. Rather than having all regex
> > subscribers
> > >> > embed
> > >> > > > all
> > >> > > > > of this metadata in their join group requests, they could
> > instead
> > >> > > embed a
> > >> > > > > hash of it. Then after the join group responses are received,
> > they
> > >> > just
> > >> > > > > need to check that the hashes are the same. If there is a
> > mismatch
> > >> > > (which
> > >> > > > > should only occur when topics are created, deleted, or
> resized),
> > >> then
> > >> > > the
> > >> > > > > group members must refetch the metadata and rejoin the group.
> > >> This is
> > >> > > > also
> > >> > > > > how the current protocol behaves when there is a change in the
> > >> topic
> > >> > > > > metadata affecting the group--someone (either the coordinator
> or
> > >> the
> > >> > > > > consumer) detects the change and forces the group to
> rebalance.
> > >> > > > >
> > >> > > > > What do you think?
> > >> > > > >
> > >> > > > > (Also I think adding groupId/generationId to fetch and produce
> > >> > requests
> > >> > > > > seems like an interesting line of thought.)
> > >> > > > >
> > >> > > > > -Jason
> > >> > > > >
> > >> > > > >
> > >> > > > >
> > >> > > > > On Wed, Aug 12, 2015 at 10:57 AM, Jiangjie Qin
> > >> > > <jqin@linkedin.com.invalid
> > >> > > > >
> > >> > > > > wrote:
> > >> > > > >
> > >> > > > >> Hey Ewen,
> > >> > > > >>
> > >> > > > >> Onur and I discussed this a little bit more. And we are still
> > >> > worrying
> > >> > > > >> about passing all the metadata of all consumers around.
> > >> > > > >>
> > >> > > > >> Let's say I have a cluster has 10,000 topics, the average
> topic
> > >> name
> > >> > > > >> length
> > >> > > > >> is 10 bytes. In this case, the opaque metadata will have 10 *
> > >> > 10,000 =
> > >> > > > >> 100KB for topic name, for each topic, there is a 4-byte
> integer
> > >> of
> > >> > > > number
> > >> > > > >> of partitions, that's another 40KB. So one global topic
> > metadata
> > >> > will
> > >> > > > have
> > >> > > > >> 140KB data. If I have 100 consumers who are using wildcard to
> > >> > consume
> > >> > > > from
> > >> > > > >> all the topics. That means the protocol metadata end up in
> the
> > >> > > > >> JoinGroupResponse will be 140KB * 100 = 14MB. And the
> > >> > > JoinGroupResponse
> > >> > > > >> will need to be sent to 100 different consumers, that means
> > 14MB
> > >> *
> > >> > > 100 =
> > >> > > > >> 1.4GB need to be sent by the consumer coordinator for one
> > >> rebalance.
> > >> > > How
> > >> > > > >> would that work?
> > >> > > > >>
> > >> > > > >> Also, having two consumers (old owner and new owner)
> consuming
> > >> from
> > >> > > the
> > >> > > > >> same partition might also be a problem. e.g. people are
> > updating
> > >> > > > database.
> > >> > > > >> One thing might worth doing is to add GroupId and Generation
> ID
> > >> to
> > >> > > > >> ProducerRequest and FetchRequest as well. This will also help
> > >> with
> > >> > the
> > >> > > > >> single producer use case. However, this is probably
> orthogonal
> > to
> > >> > this
> > >> > > > >> thread given the current new consumer also has this problem
> > and I
> > >> > > > believe
> > >> > > > >> we need to fix it.
> > >> > > > >>
> > >> > > > >> Thanks,
> > >> > > > >>
> > >> > > > >> Jiangjie (Becket) Qin
> > >> > > > >>
> > >> > > > >> On Tue, Aug 11, 2015 at 11:43 PM, Ewen Cheslack-Postava <
> > >> > > > >> ewen@confluent.io>
> > >> > > > >> wrote:
> > >> > > > >>
> > >> > > > >> > On Tue, Aug 11, 2015 at 11:29 PM, Jiangjie Qin
> > >> > > > >> <jq...@linkedin.com.invalid>
> > >> > > > >> > wrote:
> > >> > > > >> >
> > >> > > > >> > > Ewen,
> > >> > > > >> > >
> > >> > > > >> > > Thanks for the explanation.
> > >> > > > >> > >
> > >> > > > >> > > For (1), I am more concerned about the failure case
> instead
> > >> of
> > >> > > > normal
> > >> > > > >> > case.
> > >> > > > >> > > What if a consumer somehow was kick out of a group but is
> > >> still
> > >> > > > >> consuming
> > >> > > > >> > > and committing offsets? Does that mean the new owner and
> > old
> > >> > owner
> > >> > > > >> might
> > >> > > > >> > > potentially consuming from and committing offsets for the
> > >> same
> > >> > > > >> partition?
> > >> > > > >> > > In the old consumer, this won't happen because the new
> > >> consumer
> > >> > > will
> > >> > > > >> not
> > >> > > > >> > be
> > >> > > > >> > > able to start consumption unless the previous owner has
> > >> released
> > >> > > its
> > >> > > > >> > > ownership. Basically, without the ownership guarantee, I
> > >> don't
> > >> > see
> > >> > > > how
> > >> > > > >> > the
> > >> > > > >> > > communication among consumers themselves alone can solve
> > the
> > >> > > problem
> > >> > > > >> > here.
> > >> > > > >> > >
> > >> > > > >> >
> > >> > > > >> > The generation ID check still applies to offset commits. If
> > >> one of
> > >> > > the
> > >> > > > >> > consumers is kicked out and misbehaving, it can obviously
> > still
> > >> > > fetch
> > >> > > > >> and
> > >> > > > >> > process messages, but offset commits will not work since it
> > >> will
> > >> > not
> > >> > > > >> have
> > >> > > > >> > the current generation ID.
> > >> > > > >> >
> > >> > > > >> >
> > >> > > > >> > >
> > >> > > > >> > > For (2) and (3), now I understand how metadata are used.
> > But
> > >> I
> > >> > > still
> > >> > > > >> > don't
> > >> > > > >> > > see why should we let the consumers to pass the topic
> > >> > information
> > >> > > > >> across
> > >> > > > >> > > instead of letting coordinator give the information. The
> > >> single
> > >> > > > >> producer
> > >> > > > >> > > use case does not solve the ownership problem in abnormal
> > >> case
> > >> > > > either,
> > >> > > > >> > > which seems to be a little bit vulnerable.
> > >> > > > >> > >
> > >> > > > >> >
> > >> > > > >> > One of the goals here was to generalize group membership so
> > we
> > >> > can,
> > >> > > > for
> > >> > > > >> > example, use it for balancing Copycat tasks across workers.
> > >> > There's
> > >> > > no
> > >> > > > >> > topic subscription info in that case. The metadata for
> > copycat
> > >> > > workers
> > >> > > > >> > would instead need to somehow indicate the current set of
> > tasks
> > >> > that
> > >> > > > >> need
> > >> > > > >> > to be assigned to workers. By making the metadata
> completely
> > >> > opaque
> > >> > > to
> > >> > > > >> the
> > >> > > > >> > protocol, it becomes more generally useful since it focuses
> > >> > squarely
> > >> > > > on
> > >> > > > >> the
> > >> > > > >> > group membership problem, allowing for that additional bit
> of
> > >> > > metadata
> > >> > > > >> so
> > >> > > > >> > you don't just get a list of members, but also get a little
> > >> bit of
> > >> > > > info
> > >> > > > >> > about each of them.
> > >> > > > >> >
> > >> > > > >> > A different option that we explored is to use a sort of
> mixed
> > >> > model
> > >> > > --
> > >> > > > >> > still bake all the topic subscriptions directly into the
> > >> protocol
> > >> > > but
> > >> > > > >> also
> > >> > > > >> > include metadata. That would allow us to maintain the
> > existing
> > >> > > > >> > coordinator-driven approach to handling the metadata and
> > change
> > >> > > events
> > >> > > > >> like
> > >> > > > >> > the ones Onur pointed out. Then something like the Copycat
> > >> workers
> > >> > > > would
> > >> > > > >> > just not fill in any topic subscriptions and it would be
> > >> handled
> > >> > as
> > >> > > a
> > >> > > > >> > degenerate case. Based on the way I explained that we can
> > >> handle
> > >> > > those
> > >> > > > >> > types of events, I personally feel its cleaner and a nicer
> > >> > > > >> generalization
> > >> > > > >> > to not include the subscriptions in the join group
> protocol,
> > >> > making
> > >> > > it
> > >> > > > >> part
> > >> > > > >> > of the metadata instead.
> > >> > > > >> >
> > >> > > > >> > For the single producer case, are you saying it doesn't
> solve
> > >> > > > ownership
> > >> > > > >> in
> > >> > > > >> > the abnormal case because a producer that doesn't know it
> has
> > >> been
> > >> > > > >> kicked
> > >> > > > >> > out of the group yet can still produce data even though it
> > >> > shouldn't
> > >> > > > be
> > >> > > > >> > able to anymore? I definitely agree that that is a risk --
> > this
> > >> > > > >> provides a
> > >> > > > >> > way to get closer to a true single-writer, but there are
> > >> > definitely
> > >> > > > >> still
> > >> > > > >> > failure modes that this does not address.
> > >> > > > >> >
> > >> > > > >> > -Ewen
> > >> > > > >> >
> > >> > > > >> >
> > >> > > > >> > >
> > >> > > > >> > > Thanks,
> > >> > > > >> > >
> > >> > > > >> > > Jiangjie (Becket) Qin
> > >> > > > >> > >
> > >> > > > >> > >
> > >> > > > >> > > On Tue, Aug 11, 2015 at 11:06 PM, Ewen Cheslack-Postava <
> > >> > > > >> > ewen@confluent.io
> > >> > > > >> > > >
> > >> > > > >> > > wrote:
> > >> > > > >> > >
> > >> > > > >> > > > On Tue, Aug 11, 2015 at 10:15 PM, Jiangjie Qin
> > >> > > > >> > <jqin@linkedin.com.invalid
> > >> > > > >> > > >
> > >> > > > >> > > > wrote:
> > >> > > > >> > > >
> > >> > > > >> > > > > Hi Jason,
> > >> > > > >> > > > >
> > >> > > > >> > > > > Thanks for writing this up. It would be useful to
> > >> generalize
> > >> > > the
> > >> > > > >> > group
> > >> > > > >> > > > > concept. I have a few questions below.
> > >> > > > >> > > > >
> > >> > > > >> > > > > 1. In old consumer actually the partition assignment
> > are
> > >> > done
> > >> > > by
> > >> > > > >> > > > consumers
> > >> > > > >> > > > > themselves. We used zookeeper to guarantee that a
> > >> partition
> > >> > > will
> > >> > > > >> only
> > >> > > > >> > > be
> > >> > > > >> > > > > consumed by one consumer thread who successfully
> > claimed
> > >> its
> > >> > > > >> > ownership.
> > >> > > > >> > > > > Does the new protocol plan to provide the same
> > guarantee?
> > >> > > > >> > > > >
> > >> > > > >> > > >
> > >> > > > >> > > > Once you have all the metadata from all the consumers,
> > >> > > assignment
> > >> > > > >> > should
> > >> > > > >> > > > just be a simple function mapping that Map<ConsumerId,
> > >> > Metadata>
> > >> > > > to
> > >> > > > >> > > > Map<ConsumerId, List<TopicPartition>>. If everyone is
> > >> > consistent
> > >> > > > in
> > >> > > > >> > > > computing that, you don't need ZK involved at all.
> > >> > > > >> > > >
> > >> > > > >> > > > In practice, this shouldn't be that hard to ensure for
> > most
> > >> > > > >> assignment
> > >> > > > >> > > > strategies just by having decent unit testing on them.
> > You
> > >> > just
> > >> > > > >> have to
> > >> > > > >> > > do
> > >> > > > >> > > > things like ensure your assignment strategy sorts lists
> > >> into a
> > >> > > > >> > consistent
> > >> > > > >> > > > order.
> > >> > > > >> > > >
> > >> > > > >> > > > You do give up the ability to use some techniques (e.g.
> > any
> > >> > > > >> randomized
> > >> > > > >> > > > algorithm if you can't distribute the seed w/ the
> > metadata)
> > >> > and
> > >> > > > it's
> > >> > > > >> > true
> > >> > > > >> > > > that nothing validates the assignment, but if that
> > >> assignment
> > >> > > > >> algorithm
> > >> > > > >> > > > step is kept simple, small, and well tested, the risk
> is
> > >> very
> > >> > > > >> minimal.
> > >> > > > >> > > >
> > >> > > > >> > > >
> > >> > > > >> > > > >
> > >> > > > >> > > > > 2. It looks that both JoinGroupRequest and
> > >> JoinGroupResponse
> > >> > > has
> > >> > > > >> the
> > >> > > > >> > > > > ProtocolMetadata.AssignmentStrategyMetadata, what
> would
> > >> be
> > >> > the
> > >> > > > >> > metadata
> > >> > > > >> > > > be
> > >> > > > >> > > > > sent and returned by coordinator? How will the
> > >> coordinator
> > >> > > > handle
> > >> > > > >> the
> > >> > > > >> > > > > metadata?
> > >> > > > >> > > > >
> > >> > > > >> > > >
> > >> > > > >> > > > The coordinator is basically just blindly broadcasting
> > all
> > >> of
> > >> > it
> > >> > > > to
> > >> > > > >> > group
> > >> > > > >> > > > members so they have a consistent view.
> > >> > > > >> > > >
> > >> > > > >> > > > So from the coordinators perspective, it sees something
> > >> like:
> > >> > > > >> > > >
> > >> > > > >> > > > Consumer 1 -> JoinGroupRequest with GroupProtocols = [
> > >> > > "consumer"
> > >> > > > >> > > > <Consumer1 opaque byte[]>]
> > >> > > > >> > > > Consumer 2 -> JoinGroupRequest with GroupProtocols = [
> > >> > > "consumer"
> > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > >> > > > >> > > >
> > >> > > > >> > > > Then, in the responses would look like:
> > >> > > > >> > > >
> > >> > > > >> > > > Consumer 1 <- JoinGroupResponse with GroupProtocol =
> > >> > "consumer"
> > >> > > > and
> > >> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque byte[]>,
> > >> > Consumer
> > >> > > 2
> > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > >> > > > >> > > > Consumer 2 <- JoinGroupResponse with GroupProtocol =
> > >> > "consumer"
> > >> > > > and
> > >> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque byte[]>,
> > >> > Consumer
> > >> > > 2
> > >> > > > >> > > > <Consumer2 opaque byte[]>]
> > >> > > > >> > > >
> > >> > > > >> > > > So all the responses include all the metadata for every
> > >> member
> > >> > > in
> > >> > > > >> the
> > >> > > > >> > > > group, and everyone can use that to consistently decide
> > on
> > >> > > > >> assignment.
> > >> > > > >> > > The
> > >> > > > >> > > > broker doesn't care and cannot even understand the
> > metadata
> > >> > > since
> > >> > > > >> the
> > >> > > > >> > > data
> > >> > > > >> > > > format for it is dependent on the assignment strategy
> > being
> > >> > > used.
> > >> > > > >> > > >
> > >> > > > >> > > > As another example that is *not* a consumer, let's say
> > you
> > >> > just
> > >> > > > >> want to
> > >> > > > >> > > > have a single writer in the group which everyone will
> > >> forward
> > >> > > > >> requests
> > >> > > > >> > > to.
> > >> > > > >> > > > To accomplish this, you could use a very dumb
> assignment
> > >> > > strategy:
> > >> > > > >> > there
> > >> > > > >> > > is
> > >> > > > >> > > > no metadata (empty byte[]) and all we care about is who
> > is
> > >> the
> > >> > > > first
> > >> > > > >> > > member
> > >> > > > >> > > > in the group (e.g. when IDs are sorted
> > lexicographically).
> > >> > That
> > >> > > > >> member
> > >> > > > >> > is
> > >> > > > >> > > > selected as the writer. In that case, we actually just
> > care
> > >> > > about
> > >> > > > >> the
> > >> > > > >> > > > membership list, there's no additional info about each
> > >> member
> > >> > > that
> > >> > > > >> is
> > >> > > > >> > > > required to determine who is the writer.
> > >> > > > >> > > >
> > >> > > > >> > > >
> > >> > > > >> > > > > 3. Do you mean that the number of partitions in
> > >> > > > JoinGroupResponse
> > >> > > > >> > will
> > >> > > > >> > > be
> > >> > > > >> > > > > the max partition number of a topic among all the
> > >> reported
> > >> > > > >> partition
> > >> > > > >> > > > number
> > >> > > > >> > > > > by consumers? Is there any reason not just let
> > >> Coordinator
> > >> > to
> > >> > > > >> return
> > >> > > > >> > > the
> > >> > > > >> > > > > number of partitions of a topic in its metadata
> cache?
> > >> > > > >> > > > >
> > >> > > > >> > > >
> > >> > > > >> > > > Nothing from the embedded protocol is touched by the
> > >> broker.
> > >> > The
> > >> > > > >> broker
> > >> > > > >> > > > just collects opaque bytes of metadata, does the
> > selection
> > >> of
> > >> > > the
> > >> > > > >> > > strategy
> > >> > > > >> > > > if multiple are supported by some consumers, and then
> > >> returns
> > >> > > that
> > >> > > > >> > opaque
> > >> > > > >> > > > metadata for all the members back to every member. In
> > that
> > >> way
> > >> > > > they
> > >> > > > >> all
> > >> > > > >> > > > have a consistent view of the group. For regular
> > consumers,
> > >> > that
> > >> > > > >> view
> > >> > > > >> > of
> > >> > > > >> > > > the group includes information about how many
> partitions
> > >> each
> > >> > > > >> consumer
> > >> > > > >> > > > currently thinks the topics it is subscribed to has.
> > These
> > >> > could
> > >> > > > be
> > >> > > > >> > > > inconsistent due to out of date metadata and it would
> be
> > >> up to
> > >> > > the
> > >> > > > >> > > > assignment strategy on the *client* to resolve that. As
> > you
> > >> > > point
> > >> > > > >> out,
> > >> > > > >> > in
> > >> > > > >> > > > that case they could just take the max value that any
> > >> consumer
> > >> > > > >> reported
> > >> > > > >> > > > seeing and use that. The consumers that notice that
> their
> > >> > > metadata
> > >> > > > >> had
> > >> > > > >> > a
> > >> > > > >> > > > smaller # of partitions should also trigger a metadata
> > >> update
> > >> > > when
> > >> > > > >> they
> > >> > > > >> > > see
> > >> > > > >> > > > someone else observing a larger # of partitions.
> > >> > > > >> > > >
> > >> > > > >> > > >
> > >> > > > >> > > > >
> > >> > > > >> > > > > Thanks,
> > >> > > > >> > > > >
> > >> > > > >> > > > > Jiangjie (Becket) Qin
> > >> > > > >> > > > >
> > >> > > > >> > > > >
> > >> > > > >> > > > >
> > >> > > > >> > > > >
> > >> > > > >> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <
> > >> > > > >> jason@confluent.io
> > >> > > > >> > >
> > >> > > > >> > > > > wrote:
> > >> > > > >> > > > >
> > >> > > > >> > > > > > Hi Kafka Devs,
> > >> > > > >> > > > > >
> > >> > > > >> > > > > > One of the nagging issues in the current design of
> > the
> > >> new
> > >> > > > >> consumer
> > >> > > > >> > > has
> > >> > > > >> > > > > > been the need to support a variety of assignment
> > >> > strategies.
> > >> > > > >> We've
> > >> > > > >> > > > > > encountered this in particular in the design of
> > copycat
> > >> > and
> > >> > > > the
> > >> > > > >> > > > > processing
> > >> > > > >> > > > > > framework (KIP-28). From what I understand, Samza
> > also
> > >> > has a
> > >> > > > >> number
> > >> > > > >> > > of
> > >> > > > >> > > > > use
> > >> > > > >> > > > > > cases with custom assignment needs. The new
> consumer
> > >> > > protocol
> > >> > > > >> > > supports
> > >> > > > >> > > > > new
> > >> > > > >> > > > > > assignment strategies by hooking them into the
> > broker.
> > >> For
> > >> > > > many
> > >> > > > >> > > > > > environments, this is a major pain and in some
> > cases, a
> > >> > > > >> > non-starter.
> > >> > > > >> > > It
> > >> > > > >> > > > > > also challenges the validation that the coordinator
> > can
> > >> > > > provide.
> > >> > > > >> > For
> > >> > > > >> > > > > > example, some assignment strategies call for
> > >> partitions to
> > >> > > be
> > >> > > > >> > > assigned
> > >> > > > >> > > > > > multiple times, which means that the coordinator
> can
> > >> only
> > >> > > > check
> > >> > > > >> > that
> > >> > > > >> > > > > > partitions have been assigned at least once.
> > >> > > > >> > > > > >
> > >> > > > >> > > > > > To solve these issues, we'd like to propose moving
> > >> > > assignment
> > >> > > > to
> > >> > > > >> > the
> > >> > > > >> > > > > > client. I've written a wiki which outlines some
> > >> protocol
> > >> > > > >> changes to
> > >> > > > >> > > > > achieve
> > >> > > > >> > > > > > this:
> > >> > > > >> > > > > >
> > >> > > > >> > > > > >
> > >> > > > >> > > > >
> > >> > > > >> > > >
> > >> > > > >> > >
> > >> > > > >> >
> > >> > > > >>
> > >> > > >
> > >> > >
> > >> >
> > >>
> >
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> > >> > > > >> > > > > > .
> > >> > > > >> > > > > > To summarize briefly, instead of the coordinator
> > >> assigning
> > >> > > the
> > >> > > > >> > > > partitions
> > >> > > > >> > > > > > itself, all subscriptions are forwarded to each
> > member
> > >> of
> > >> > > the
> > >> > > > >> group
> > >> > > > >> > > > which
> > >> > > > >> > > > > > then decides independently which partitions it
> should
> > >> > > consume.
> > >> > > > >> The
> > >> > > > >> > > > > protocol
> > >> > > > >> > > > > > provides a mechanism for the coordinator to
> validate
> > >> that
> > >> > > all
> > >> > > > >> > > consumers
> > >> > > > >> > > > > use
> > >> > > > >> > > > > > the same assignment strategy, but it does not
> ensure
> > >> that
> > >> > > the
> > >> > > > >> > > resulting
> > >> > > > >> > > > > > assignment is "correct." This provides a powerful
> > >> > capability
> > >> > > > for
> > >> > > > >> > > users
> > >> > > > >> > > > to
> > >> > > > >> > > > > > control the full data flow on the client side. They
> > >> > control
> > >> > > > how
> > >> > > > >> > data
> > >> > > > >> > > is
> > >> > > > >> > > > > > written to partitions through the Partitioner
> > interface
> > >> > and
> > >> > > > they
> > >> > > > >> > > > control
> > >> > > > >> > > > > > how data is consumed through the assignment
> strategy,
> > >> all
> > >> > > > >> without
> > >> > > > >> > > > > touching
> > >> > > > >> > > > > > the server.
> > >> > > > >> > > > > >
> > >> > > > >> > > > > > Of course nothing comes for free. In particular,
> this
> > >> > change
> > >> > > > >> > removes
> > >> > > > >> > > > the
> > >> > > > >> > > > > > ability of the coordinator to validate that commits
> > are
> > >> > made
> > >> > > > by
> > >> > > > >> > > > consumers
> > >> > > > >> > > > > > who were assigned the respective partition. This
> > might
> > >> not
> > >> > > be
> > >> > > > >> too
> > >> > > > >> > bad
> > >> > > > >> > > > > since
> > >> > > > >> > > > > > we retain the ability to validate the generation
> id,
> > >> but
> > >> > it
> > >> > > > is a
> > >> > > > >> > > > > potential
> > >> > > > >> > > > > > concern. We have considered alternative protocols
> > which
> > >> > add
> > >> > > a
> > >> > > > >> > second
> > >> > > > >> > > > > > round-trip to the protocol in order to give the
> > >> > coordinator
> > >> > > > the
> > >> > > > >> > > ability
> > >> > > > >> > > > > to
> > >> > > > >> > > > > > confirm the assignment. As mentioned above, the
> > >> > coordinator
> > >> > > is
> > >> > > > >> > > somewhat
> > >> > > > >> > > > > > limited in what it can actually validate, but this
> > >> would
> > >> > > > return
> > >> > > > >> its
> > >> > > > >> > > > > ability
> > >> > > > >> > > > > > to validate commits. The tradeoff is that it
> > increases
> > >> the
> > >> > > > >> > protocol's
> > >> > > > >> > > > > > complexity which means more ways for the protocol
> to
> > >> fail
> > >> > > and
> > >> > > > >> > > > > consequently
> > >> > > > >> > > > > > more edge cases in the code.
> > >> > > > >> > > > > >
> > >> > > > >> > > > > > It also misses an opportunity to generalize the
> group
> > >> > > > membership
> > >> > > > >> > > > protocol
> > >> > > > >> > > > > > for additional use cases. In fact, after you've
> gone
> > to
> > >> > the
> > >> > > > >> trouble
> > >> > > > >> > > of
> > >> > > > >> > > > > > moving assignment to the client, the main thing
> that
> > is
> > >> > left
> > >> > > > in
> > >> > > > >> > this
> > >> > > > >> > > > > > protocol is basically a general group management
> > >> > capability.
> > >> > > > >> This
> > >> > > > >> > is
> > >> > > > >> > > > > > exactly what is needed for a few cases that are
> > >> currently
> > >> > > > under
> > >> > > > >> > > > > discussion
> > >> > > > >> > > > > > (e.g. copycat or single-writer producer). We've
> taken
> > >> this
> > >> > > > >> further
> > >> > > > >> > > step
> > >> > > > >> > > > > in
> > >> > > > >> > > > > > the proposal and attempted to envision what that
> > >> general
> > >> > > > >> protocol
> > >> > > > >> > > might
> > >> > > > >> > > > > > look like and how it could be used both by the
> > consumer
> > >> > and
> > >> > > > for
> > >> > > > >> > some
> > >> > > > >> > > of
> > >> > > > >> > > > > > these other cases.
> > >> > > > >> > > > > >
> > >> > > > >> > > > > > Anyway, since time is running out on the new
> > consumer,
> > >> we
> > >> > > have
> > >> > > > >> > > perhaps
> > >> > > > >> > > > > one
> > >> > > > >> > > > > > last chance to consider a significant change in the
> > >> > protocol
> > >> > > > >> like
> > >> > > > >> > > this,
> > >> > > > >> > > > > so
> > >> > > > >> > > > > > have a look at the wiki and share your thoughts.
> I've
> > >> no
> > >> > > doubt
> > >> > > > >> that
> > >> > > > >> > > > some
> > >> > > > >> > > > > > ideas seem clearer in my mind than they do on
> paper,
> > so
> > >> > ask
> > >> > > > >> > questions
> > >> > > > >> > > > if
> > >> > > > >> > > > > > there is any confusion.
> > >> > > > >> > > > > >
> > >> > > > >> > > > > > Thanks!
> > >> > > > >> > > > > > Jason
> > >> > > > >> > > > > >
> > >> > > > >> > > > >
> > >> > > > >> > > >
> > >> > > > >> > > >
> > >> > > > >> > > >
> > >> > > > >> > > > --
> > >> > > > >> > > > Thanks,
> > >> > > > >> > > > Ewen
> > >> > > > >> > > >
> > >> > > > >> > >
> > >> > > > >> >
> > >> > > > >> >
> > >> > > > >> >
> > >> > > > >> > --
> > >> > > > >> > Thanks,
> > >> > > > >> > Ewen
> > >> > > > >> >
> > >> > > > >>
> > >> > > > >
> > >> > > > >
> > >> > > >
> > >> > >
> > >> >
> > >>
> > >
> > >
> > >
> > > --
> > > Thanks,
> > > Neha
> > >
> >
> >
> >
> > --
> > Thanks,
> > Neha
> >
>
>
>
> --
> Thanks,
> Ewen
>

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Ewen Cheslack-Postava <ew...@confluent.io>.
On Thu, Aug 13, 2015 at 11:07 PM, Neha Narkhede <ne...@confluent.io> wrote:

> Becket,
>
> As you say, the metadata hash addresses the concern you originally raised
> about large topic subscriptions. Can you please list other problems you are
> raising more clearly? It is more helpful to know problems that the proposal
> does not address or addresses poorly.
>
> Regarding other things you said -
>
> it is required that each
> > consumer refresh their metadata before sending a JoinGroupRequest
> >
>
> This is required for wildcard topic subscriptions anyway. So this proposal
> does not introduce a regression. We had agreed earlier that it does not
> make sense for the server to deserialize regular expressions sent by the
> consumer.
>

I don't think consumers need to do a metadata refresh before sending a
JoinGroupRequest. Metadata changes that affect assignment are rare -- it
requires changing the number of partitions in a topic. But you might send a
JoinGroupRequest simply because a new member is trying to join the group.
That case is presumably much more common.

I think it's actually a good idea to have the first JoinGroup cycle fail in
some cases, and has little impact. Lets say the metadata does change
because partitions are added. Then we might fail in the first round, but
then all members detect that issue *immediately*, refresh their metadata,
and submit a new join group request. This second cycle does not require a
full heartbeat cycle. It happens much more quickly because everyone
detected the inconsistency based on the first JoinGroupResponse. The
inconsistency should be resolved very quickly (barring other failures like
a member leaving mid-rebalance).


>
>
> > the metadata might still be inconsistent if there is a topic or partition
> > change because the
> > UpdateMetadataRequest from controller might be handled at different time.
> >
>
> Topic metadata does not change frequently and even if it did, a couple
> rebalance attempts will be needed whether the coordinator drives the
> assignments or the consumer. Because guess how the coordinator knows about
> the topic metadata changes -- indirectly through either a zk callback or
> UpdateMetadataRequest, so it is completely possible the coordinator sees
> the topic metadata changes in batches, not all at once.
>

> On Thu, Aug 13, 2015 at 10:50 PM, Neha Narkhede <ne...@confluent.io> wrote:
>
> > Ewen/Jason,
> >
> > The metadata hash is a clever approach and certainly addresses the
> problem
> > of large metadata for consumers like mirror maker. Few comments -
> >
> >
> >    1. In the interest of simplifying the format of the consumer's
> >    metadata - Why not just always include only the topic names in the
> metadata
> >    followed by the metadata hash? If the metadata hash check succeeds,
> each
> >    consumer uses the # of partitions it had fetched. If it fails, a
> rebalance
> >    happens and the metadata is not used anyway.
>

Doing this requires that every consumer always fetch the full metadata. The
most common use case is consumers that just want to consume one or a couple
of topics, in which case grabbing all metadata for the entire cluster is
wasteful. If I subscribe only to topic A, why make all consumers grab
metadata for the entire topic (and need to rebalance every time it
changes!). Including the # of partitions for each topic lets you avoid
having to grab the global set of metadata.

So if you're just subscribing to one or a couple of topics, why not just
compute the hash by filtering out everything but the topics you are
subscribed to? The problem there is if you ever add/remove subscriptions
and want to support rolling upgrades. If the group was subscribed to topic
A, but later changes require subscribing to A + B, then to achieve a
seamless rolling upgrade would require one (old) consumer to be subscribing
to A and one (new) consumer to be subscribing to A+B. If we computed
metadata hashes based on filtered metadata, those two would disagree and we
could not perform assignment while the upgrade was in progress.

The solution is to differentiate between the cases when a very small amount
of the metadata is needed (one or a couple of topic subscriptions;
communicate and share this via metadata in the JoinGroup protocol) vs when
*all* the metadata is needed (regex subscription; verify agreement via
hash).



> >    2. Do you need a topic list and topic regex to be separate? A single
> >    topic or list of topics can be expressed as a regex.
>

See above note about collecting all metadata when you really only need it
for 1 or 2 topics. There's probably some debate to be had about whether
this cost would be too high -- every consumer would need to request the
metadata for all topics, and they'd need to request that all every time
they might be out of date.


> >    3. Let's include a version explicitly at the beginning of the
> >    ProtocolMetadata. The version dictates how to deserialize the
> >    ProtocolMetadata blob and is consistent with the rest of Kafka.
>

If I'm understanding correctly, in JoinGroupRequest I would change

GroupProtocols          => [Protocol ProtocolMetadata]

to

GroupProtocols          => [Protocol ProtocolVersion ProtocolMetadata]

We had been talking about just baking the version into the Protocol field,
but making it separate seems perfectly reasonable to me. Jason, any issue
with splitting the version out into a separate field like this?

>
> > That can simplify the metadata format to the following:
> >
> > GroupType => "consumer"
> >>
> >> Protocol => AssignmentStrategy
> >>   AssignmentStrategy   => String
> >>
> >> ProtocolMetadata => Version Subscription AssignmentStrategyMetadata
> >
> >     Version                    => String
> >
> >   Subscription                 => TopicRegex MetadataHash
> >>     TopicRegex                 => String
> >>     MetadataHash               => String
> >>   AssignmentStrategyMetadata   => bytes
>
>
> >
> > On Thu, Aug 13, 2015 at 6:28 PM, Jiangjie Qin <jqin@linkedin.com.invalid
> >
> > wrote:
> >
> >> Ewen and Jason,
> >>
> >> Thanks for the reply. Sorry I missed the metadata hash. Yes, that is a
> >> clever approach and would solve my concern about the data passing
> around.
> >> I
> >> can see both pros and cons from doing this, though. The advantage is we
> >> don't need the topic metadata in JoinGroupResponse anymore. The downside
> >> is
> >> that now rebalance have extra dependency on the consensus of metadata of
> >> all consumers, which is obtained separately. So it is required that each
> >> consumer refresh their metadata before sending a JoinGroupRequest,
> >> otherwise in some cases (e.g. wildcard consumers) will almost certainly
> >> fail for the first rebalance attempt. Even if we do that, since the
> >> consumers are getting metadata from different brokers, the metadata
> might
> >> still be inconsistent if there is a topic or partition change because
> the
> >> UpdateMetadataRequest from controller might be handled at different
> time.
> >> Just want to make sure we think through the cases so the protocol does
> not
> >> cause us unexpected issues.
> >>
> >> About the number of consumers, I think with the current liveliness
> >> definition, we can tolerate churns by bumping up the session timeout.
> Also
> >> I guess we will see an increasing number of consumers for new consumer,
> >> because every the old consumer thread will probably become a consumer.
> >>
> >> It is a valid concern for consumers that have large subscription set.
> This
> >> might not be avoided though for client side assignment approach. One
> >> solution is having topic names associate with a topic ID. And only use
> >> topic ID in JoinGroupRequest and JoinGroupResponse, There is a
> discussion
> >> thread about this to solve the topic renaming case but this is a
> >> completely
> >> different discussion.
> >>
> >> Thanks,
> >>
> >> Jiangjie (Becket) Qin
> >>
> >>
> >>
> >> On Thu, Aug 13, 2015 at 2:14 PM, Jason Gustafson <ja...@confluent.io>
> >> wrote:
> >>
> >> > Thanks Jiangjie, that information helps. I agree the protocol must
> >> consider
> >> > scalability. My point was that the synchronization barrier in the
> >> current
> >> > protocol already effectively limits the number of consumers since it
> >> > provides no way to gracefully handle churn. It wouldn't be worth
> >> worrying
> >> > about scaling up to 100,000 members, for example, because there's no
> way
> >> > the group would be stable. So we just need to set some clear
> >> expectations
> >> > on the size we can scale to, and that can help inform the discussion
> on
> >> the
> >> > size of messages in this protocol.
> >> >
> >> > Ewen and I were discussing this morning along similar lines to what
> >> you're
> >> > suggesting. However, even if the coordinator decides on the metadata
> for
> >> > the group, each member still needs to communicate its subscriptions to
> >> the
> >> > rest of the group. This is nice for the regex case since the regex is
> >> > probably small, but if the members have a large topic list, then we
> have
> >> > the same problem. One thing I was thinking about was whether we really
> >> need
> >> > to handle different subscriptions for every member. If the coordinator
> >> > could guarantee that all members had the same subscription, then there
> >> > would be no need for the coordinator to return the subscriptions for
> >> each
> >> > member. However, this would prevent graceful upgrades. We might be
> able
> >> to
> >> > fix that problem by allowing the consumer to provide two subscriptions
> >> to
> >> > allowing rolling updates, but that starts to sound pretty nasty.
> >> >
> >> > -Jason
> >> >
> >> > On Thu, Aug 13, 2015 at 1:41 PM, Jiangjie Qin
> <jqin@linkedin.com.invalid
> >> >
> >> > wrote:
> >> >
> >> > > Jason,
> >> > >
> >> > > The protocol has to consider the scalability. The protocol in the
> wiki
> >> > > means the JoinGroupResoponse size would be:
> >> > > NumberOfTopics * (AvgTopicNameLength + 4) * (NumberOfConsumers)^2
> >> > >
> >> > > To give some real number, we have 26-node Mirror Maker cluster, each
> >> > with 4
> >> > > consumers. That is 104 consumers using regex ".*". And most of our
> >> > clusters
> >> > > have around 3000 topics, whose topic name are typically around 20
> >> > > characters.
> >> > >
> >> > > I think the key issue for client side partition assignment logic is
> to
> >> > make
> >> > > sure 1) all the clients run the same algorithm. 2) all the clients
> >> make
> >> > > decision on the same topic metadata. The second purpose can be done
> by
> >> > > simply letting coordinator provide the topic metadata and all then
> >> member
> >> > > information as source of truth. Is it necessary to pass topic
> >> metadata of
> >> > > each consumer around? Can we keep the protocol metadata field
> >> completely
> >> > > independent of topic metadata? I think In the JoinGroupResponse, we
> >> > should
> >> > > have only one copy of topic metadata provided by coordinator and is
> >> > outside
> >> > > of protocol metadata. If user decides to put some metadata in the
> >> > > JoinGroupRequest and let coordinator pass around, they are
> responsible
> >> > for
> >> > > understanding the risk.
> >> > >
> >> > > Thanks,
> >> > >
> >> > > Jiangjie (Becket) Qin
> >> > >
> >> > >
> >> > > On Thu, Aug 13, 2015 at 12:41 PM, Jason Gustafson <
> jason@confluent.io
> >> >
> >> > > wrote:
> >> > >
> >> > > > Hey Onur and Jiangjie,
> >> > > >
> >> > > > I've updated that wiki with a proposal to add regex subscriptions
> to
> >> > the
> >> > > > consumer metadata. Can you have a look to see if it addresses your
> >> > > concern?
> >> > > > In general, I think we should be a little careful when we are
> >> talking
> >> > > about
> >> > > > the scalability of the protocol. Regardless of whether assignment
> is
> >> > done
> >> > > > on the server or the client, the protocol assumes a relatively
> >> stable
> >> > > > configuration. When the number of consumers increases beyond a
> >> certain
> >> > > > limit, then membership churn becomes a major concern. Similarly
> >> there
> >> > is
> >> > > a
> >> > > > notion of metadata churn when topics are added, deleted, or
> >> resized. If
> >> > > > either membership or metadata changes, then the protocol forces
> all
> >> > > > consumers to stop consumption and rejoin the group. If this
> happens
> >> > often
> >> > > > enough, then it can severely impact the ability of the consumer to
> >> make
> >> > > > progress. The point is that the protocol may already be unsuited
> to
> >> > cases
> >> > > > where there are either a large number of consumers or topics. I
> >> wonder
> >> > if
> >> > > > you guys can share your thoughts about your scaling expectations?
> >> > > >
> >> > > > -Jason
> >> > > >
> >> > > >
> >> > > >
> >> > > >
> >> > > > On Wed, Aug 12, 2015 at 12:28 PM, Jason Gustafson <
> >> jason@confluent.io>
> >> > > > wrote:
> >> > > >
> >> > > > > Hey Jiangjie,
> >> > > > >
> >> > > > > That's a great point. In the worst case (the mirror maker case I
> >> > > guess),
> >> > > > > the join group response can be massive. This would be especially
> >> > deadly
> >> > > > > when there is a lot of churn in the group (e.g. in a rolling
> >> > upgrade).
> >> > > > The
> >> > > > > current protocol is not great for this case either, but it's
> >> > > > significantly
> >> > > > > better. Here are a couple ways to deal with the size:
> >> > > > >
> >> > > > > 1. First, we could have the coordinator compress the responses.
> >> This
> >> > > > would
> >> > > > > probably be pretty effective if applied across the metadata from
> >> all
> >> > > > > members.
> >> > > > >
> >> > > > > 2. I think the regex case is the main problem. Is that right? We
> >> > could
> >> > > > > extend the metadata to allow the consumer to embed its regex
> >> > > subscription
> >> > > > > in the metadata directly (note this might be a good idea
> >> regardless
> >> > of
> >> > > > the
> >> > > > > rest of this proposal). To support regex on the consumer, we
> must
> >> > fetch
> >> > > > > metadata for all topics. Rather than having all regex
> subscribers
> >> > embed
> >> > > > all
> >> > > > > of this metadata in their join group requests, they could
> instead
> >> > > embed a
> >> > > > > hash of it. Then after the join group responses are received,
> they
> >> > just
> >> > > > > need to check that the hashes are the same. If there is a
> mismatch
> >> > > (which
> >> > > > > should only occur when topics are created, deleted, or resized),
> >> then
> >> > > the
> >> > > > > group members must refetch the metadata and rejoin the group.
> >> This is
> >> > > > also
> >> > > > > how the current protocol behaves when there is a change in the
> >> topic
> >> > > > > metadata affecting the group--someone (either the coordinator or
> >> the
> >> > > > > consumer) detects the change and forces the group to rebalance.
> >> > > > >
> >> > > > > What do you think?
> >> > > > >
> >> > > > > (Also I think adding groupId/generationId to fetch and produce
> >> > requests
> >> > > > > seems like an interesting line of thought.)
> >> > > > >
> >> > > > > -Jason
> >> > > > >
> >> > > > >
> >> > > > >
> >> > > > > On Wed, Aug 12, 2015 at 10:57 AM, Jiangjie Qin
> >> > > <jqin@linkedin.com.invalid
> >> > > > >
> >> > > > > wrote:
> >> > > > >
> >> > > > >> Hey Ewen,
> >> > > > >>
> >> > > > >> Onur and I discussed this a little bit more. And we are still
> >> > worrying
> >> > > > >> about passing all the metadata of all consumers around.
> >> > > > >>
> >> > > > >> Let's say I have a cluster has 10,000 topics, the average topic
> >> name
> >> > > > >> length
> >> > > > >> is 10 bytes. In this case, the opaque metadata will have 10 *
> >> > 10,000 =
> >> > > > >> 100KB for topic name, for each topic, there is a 4-byte integer
> >> of
> >> > > > number
> >> > > > >> of partitions, that's another 40KB. So one global topic
> metadata
> >> > will
> >> > > > have
> >> > > > >> 140KB data. If I have 100 consumers who are using wildcard to
> >> > consume
> >> > > > from
> >> > > > >> all the topics. That means the protocol metadata end up in the
> >> > > > >> JoinGroupResponse will be 140KB * 100 = 14MB. And the
> >> > > JoinGroupResponse
> >> > > > >> will need to be sent to 100 different consumers, that means
> 14MB
> >> *
> >> > > 100 =
> >> > > > >> 1.4GB need to be sent by the consumer coordinator for one
> >> rebalance.
> >> > > How
> >> > > > >> would that work?
> >> > > > >>
> >> > > > >> Also, having two consumers (old owner and new owner) consuming
> >> from
> >> > > the
> >> > > > >> same partition might also be a problem. e.g. people are
> updating
> >> > > > database.
> >> > > > >> One thing might worth doing is to add GroupId and Generation ID
> >> to
> >> > > > >> ProducerRequest and FetchRequest as well. This will also help
> >> with
> >> > the
> >> > > > >> single producer use case. However, this is probably orthogonal
> to
> >> > this
> >> > > > >> thread given the current new consumer also has this problem
> and I
> >> > > > believe
> >> > > > >> we need to fix it.
> >> > > > >>
> >> > > > >> Thanks,
> >> > > > >>
> >> > > > >> Jiangjie (Becket) Qin
> >> > > > >>
> >> > > > >> On Tue, Aug 11, 2015 at 11:43 PM, Ewen Cheslack-Postava <
> >> > > > >> ewen@confluent.io>
> >> > > > >> wrote:
> >> > > > >>
> >> > > > >> > On Tue, Aug 11, 2015 at 11:29 PM, Jiangjie Qin
> >> > > > >> <jq...@linkedin.com.invalid>
> >> > > > >> > wrote:
> >> > > > >> >
> >> > > > >> > > Ewen,
> >> > > > >> > >
> >> > > > >> > > Thanks for the explanation.
> >> > > > >> > >
> >> > > > >> > > For (1), I am more concerned about the failure case instead
> >> of
> >> > > > normal
> >> > > > >> > case.
> >> > > > >> > > What if a consumer somehow was kick out of a group but is
> >> still
> >> > > > >> consuming
> >> > > > >> > > and committing offsets? Does that mean the new owner and
> old
> >> > owner
> >> > > > >> might
> >> > > > >> > > potentially consuming from and committing offsets for the
> >> same
> >> > > > >> partition?
> >> > > > >> > > In the old consumer, this won't happen because the new
> >> consumer
> >> > > will
> >> > > > >> not
> >> > > > >> > be
> >> > > > >> > > able to start consumption unless the previous owner has
> >> released
> >> > > its
> >> > > > >> > > ownership. Basically, without the ownership guarantee, I
> >> don't
> >> > see
> >> > > > how
> >> > > > >> > the
> >> > > > >> > > communication among consumers themselves alone can solve
> the
> >> > > problem
> >> > > > >> > here.
> >> > > > >> > >
> >> > > > >> >
> >> > > > >> > The generation ID check still applies to offset commits. If
> >> one of
> >> > > the
> >> > > > >> > consumers is kicked out and misbehaving, it can obviously
> still
> >> > > fetch
> >> > > > >> and
> >> > > > >> > process messages, but offset commits will not work since it
> >> will
> >> > not
> >> > > > >> have
> >> > > > >> > the current generation ID.
> >> > > > >> >
> >> > > > >> >
> >> > > > >> > >
> >> > > > >> > > For (2) and (3), now I understand how metadata are used.
> But
> >> I
> >> > > still
> >> > > > >> > don't
> >> > > > >> > > see why should we let the consumers to pass the topic
> >> > information
> >> > > > >> across
> >> > > > >> > > instead of letting coordinator give the information. The
> >> single
> >> > > > >> producer
> >> > > > >> > > use case does not solve the ownership problem in abnormal
> >> case
> >> > > > either,
> >> > > > >> > > which seems to be a little bit vulnerable.
> >> > > > >> > >
> >> > > > >> >
> >> > > > >> > One of the goals here was to generalize group membership so
> we
> >> > can,
> >> > > > for
> >> > > > >> > example, use it for balancing Copycat tasks across workers.
> >> > There's
> >> > > no
> >> > > > >> > topic subscription info in that case. The metadata for
> copycat
> >> > > workers
> >> > > > >> > would instead need to somehow indicate the current set of
> tasks
> >> > that
> >> > > > >> need
> >> > > > >> > to be assigned to workers. By making the metadata completely
> >> > opaque
> >> > > to
> >> > > > >> the
> >> > > > >> > protocol, it becomes more generally useful since it focuses
> >> > squarely
> >> > > > on
> >> > > > >> the
> >> > > > >> > group membership problem, allowing for that additional bit of
> >> > > metadata
> >> > > > >> so
> >> > > > >> > you don't just get a list of members, but also get a little
> >> bit of
> >> > > > info
> >> > > > >> > about each of them.
> >> > > > >> >
> >> > > > >> > A different option that we explored is to use a sort of mixed
> >> > model
> >> > > --
> >> > > > >> > still bake all the topic subscriptions directly into the
> >> protocol
> >> > > but
> >> > > > >> also
> >> > > > >> > include metadata. That would allow us to maintain the
> existing
> >> > > > >> > coordinator-driven approach to handling the metadata and
> change
> >> > > events
> >> > > > >> like
> >> > > > >> > the ones Onur pointed out. Then something like the Copycat
> >> workers
> >> > > > would
> >> > > > >> > just not fill in any topic subscriptions and it would be
> >> handled
> >> > as
> >> > > a
> >> > > > >> > degenerate case. Based on the way I explained that we can
> >> handle
> >> > > those
> >> > > > >> > types of events, I personally feel its cleaner and a nicer
> >> > > > >> generalization
> >> > > > >> > to not include the subscriptions in the join group protocol,
> >> > making
> >> > > it
> >> > > > >> part
> >> > > > >> > of the metadata instead.
> >> > > > >> >
> >> > > > >> > For the single producer case, are you saying it doesn't solve
> >> > > > ownership
> >> > > > >> in
> >> > > > >> > the abnormal case because a producer that doesn't know it has
> >> been
> >> > > > >> kicked
> >> > > > >> > out of the group yet can still produce data even though it
> >> > shouldn't
> >> > > > be
> >> > > > >> > able to anymore? I definitely agree that that is a risk --
> this
> >> > > > >> provides a
> >> > > > >> > way to get closer to a true single-writer, but there are
> >> > definitely
> >> > > > >> still
> >> > > > >> > failure modes that this does not address.
> >> > > > >> >
> >> > > > >> > -Ewen
> >> > > > >> >
> >> > > > >> >
> >> > > > >> > >
> >> > > > >> > > Thanks,
> >> > > > >> > >
> >> > > > >> > > Jiangjie (Becket) Qin
> >> > > > >> > >
> >> > > > >> > >
> >> > > > >> > > On Tue, Aug 11, 2015 at 11:06 PM, Ewen Cheslack-Postava <
> >> > > > >> > ewen@confluent.io
> >> > > > >> > > >
> >> > > > >> > > wrote:
> >> > > > >> > >
> >> > > > >> > > > On Tue, Aug 11, 2015 at 10:15 PM, Jiangjie Qin
> >> > > > >> > <jqin@linkedin.com.invalid
> >> > > > >> > > >
> >> > > > >> > > > wrote:
> >> > > > >> > > >
> >> > > > >> > > > > Hi Jason,
> >> > > > >> > > > >
> >> > > > >> > > > > Thanks for writing this up. It would be useful to
> >> generalize
> >> > > the
> >> > > > >> > group
> >> > > > >> > > > > concept. I have a few questions below.
> >> > > > >> > > > >
> >> > > > >> > > > > 1. In old consumer actually the partition assignment
> are
> >> > done
> >> > > by
> >> > > > >> > > > consumers
> >> > > > >> > > > > themselves. We used zookeeper to guarantee that a
> >> partition
> >> > > will
> >> > > > >> only
> >> > > > >> > > be
> >> > > > >> > > > > consumed by one consumer thread who successfully
> claimed
> >> its
> >> > > > >> > ownership.
> >> > > > >> > > > > Does the new protocol plan to provide the same
> guarantee?
> >> > > > >> > > > >
> >> > > > >> > > >
> >> > > > >> > > > Once you have all the metadata from all the consumers,
> >> > > assignment
> >> > > > >> > should
> >> > > > >> > > > just be a simple function mapping that Map<ConsumerId,
> >> > Metadata>
> >> > > > to
> >> > > > >> > > > Map<ConsumerId, List<TopicPartition>>. If everyone is
> >> > consistent
> >> > > > in
> >> > > > >> > > > computing that, you don't need ZK involved at all.
> >> > > > >> > > >
> >> > > > >> > > > In practice, this shouldn't be that hard to ensure for
> most
> >> > > > >> assignment
> >> > > > >> > > > strategies just by having decent unit testing on them.
> You
> >> > just
> >> > > > >> have to
> >> > > > >> > > do
> >> > > > >> > > > things like ensure your assignment strategy sorts lists
> >> into a
> >> > > > >> > consistent
> >> > > > >> > > > order.
> >> > > > >> > > >
> >> > > > >> > > > You do give up the ability to use some techniques (e.g.
> any
> >> > > > >> randomized
> >> > > > >> > > > algorithm if you can't distribute the seed w/ the
> metadata)
> >> > and
> >> > > > it's
> >> > > > >> > true
> >> > > > >> > > > that nothing validates the assignment, but if that
> >> assignment
> >> > > > >> algorithm
> >> > > > >> > > > step is kept simple, small, and well tested, the risk is
> >> very
> >> > > > >> minimal.
> >> > > > >> > > >
> >> > > > >> > > >
> >> > > > >> > > > >
> >> > > > >> > > > > 2. It looks that both JoinGroupRequest and
> >> JoinGroupResponse
> >> > > has
> >> > > > >> the
> >> > > > >> > > > > ProtocolMetadata.AssignmentStrategyMetadata, what would
> >> be
> >> > the
> >> > > > >> > metadata
> >> > > > >> > > > be
> >> > > > >> > > > > sent and returned by coordinator? How will the
> >> coordinator
> >> > > > handle
> >> > > > >> the
> >> > > > >> > > > > metadata?
> >> > > > >> > > > >
> >> > > > >> > > >
> >> > > > >> > > > The coordinator is basically just blindly broadcasting
> all
> >> of
> >> > it
> >> > > > to
> >> > > > >> > group
> >> > > > >> > > > members so they have a consistent view.
> >> > > > >> > > >
> >> > > > >> > > > So from the coordinators perspective, it sees something
> >> like:
> >> > > > >> > > >
> >> > > > >> > > > Consumer 1 -> JoinGroupRequest with GroupProtocols = [
> >> > > "consumer"
> >> > > > >> > > > <Consumer1 opaque byte[]>]
> >> > > > >> > > > Consumer 2 -> JoinGroupRequest with GroupProtocols = [
> >> > > "consumer"
> >> > > > >> > > > <Consumer2 opaque byte[]>]
> >> > > > >> > > >
> >> > > > >> > > > Then, in the responses would look like:
> >> > > > >> > > >
> >> > > > >> > > > Consumer 1 <- JoinGroupResponse with GroupProtocol =
> >> > "consumer"
> >> > > > and
> >> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque byte[]>,
> >> > Consumer
> >> > > 2
> >> > > > >> > > > <Consumer2 opaque byte[]>]
> >> > > > >> > > > Consumer 2 <- JoinGroupResponse with GroupProtocol =
> >> > "consumer"
> >> > > > and
> >> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque byte[]>,
> >> > Consumer
> >> > > 2
> >> > > > >> > > > <Consumer2 opaque byte[]>]
> >> > > > >> > > >
> >> > > > >> > > > So all the responses include all the metadata for every
> >> member
> >> > > in
> >> > > > >> the
> >> > > > >> > > > group, and everyone can use that to consistently decide
> on
> >> > > > >> assignment.
> >> > > > >> > > The
> >> > > > >> > > > broker doesn't care and cannot even understand the
> metadata
> >> > > since
> >> > > > >> the
> >> > > > >> > > data
> >> > > > >> > > > format for it is dependent on the assignment strategy
> being
> >> > > used.
> >> > > > >> > > >
> >> > > > >> > > > As another example that is *not* a consumer, let's say
> you
> >> > just
> >> > > > >> want to
> >> > > > >> > > > have a single writer in the group which everyone will
> >> forward
> >> > > > >> requests
> >> > > > >> > > to.
> >> > > > >> > > > To accomplish this, you could use a very dumb assignment
> >> > > strategy:
> >> > > > >> > there
> >> > > > >> > > is
> >> > > > >> > > > no metadata (empty byte[]) and all we care about is who
> is
> >> the
> >> > > > first
> >> > > > >> > > member
> >> > > > >> > > > in the group (e.g. when IDs are sorted
> lexicographically).
> >> > That
> >> > > > >> member
> >> > > > >> > is
> >> > > > >> > > > selected as the writer. In that case, we actually just
> care
> >> > > about
> >> > > > >> the
> >> > > > >> > > > membership list, there's no additional info about each
> >> member
> >> > > that
> >> > > > >> is
> >> > > > >> > > > required to determine who is the writer.
> >> > > > >> > > >
> >> > > > >> > > >
> >> > > > >> > > > > 3. Do you mean that the number of partitions in
> >> > > > JoinGroupResponse
> >> > > > >> > will
> >> > > > >> > > be
> >> > > > >> > > > > the max partition number of a topic among all the
> >> reported
> >> > > > >> partition
> >> > > > >> > > > number
> >> > > > >> > > > > by consumers? Is there any reason not just let
> >> Coordinator
> >> > to
> >> > > > >> return
> >> > > > >> > > the
> >> > > > >> > > > > number of partitions of a topic in its metadata cache?
> >> > > > >> > > > >
> >> > > > >> > > >
> >> > > > >> > > > Nothing from the embedded protocol is touched by the
> >> broker.
> >> > The
> >> > > > >> broker
> >> > > > >> > > > just collects opaque bytes of metadata, does the
> selection
> >> of
> >> > > the
> >> > > > >> > > strategy
> >> > > > >> > > > if multiple are supported by some consumers, and then
> >> returns
> >> > > that
> >> > > > >> > opaque
> >> > > > >> > > > metadata for all the members back to every member. In
> that
> >> way
> >> > > > they
> >> > > > >> all
> >> > > > >> > > > have a consistent view of the group. For regular
> consumers,
> >> > that
> >> > > > >> view
> >> > > > >> > of
> >> > > > >> > > > the group includes information about how many partitions
> >> each
> >> > > > >> consumer
> >> > > > >> > > > currently thinks the topics it is subscribed to has.
> These
> >> > could
> >> > > > be
> >> > > > >> > > > inconsistent due to out of date metadata and it would be
> >> up to
> >> > > the
> >> > > > >> > > > assignment strategy on the *client* to resolve that. As
> you
> >> > > point
> >> > > > >> out,
> >> > > > >> > in
> >> > > > >> > > > that case they could just take the max value that any
> >> consumer
> >> > > > >> reported
> >> > > > >> > > > seeing and use that. The consumers that notice that their
> >> > > metadata
> >> > > > >> had
> >> > > > >> > a
> >> > > > >> > > > smaller # of partitions should also trigger a metadata
> >> update
> >> > > when
> >> > > > >> they
> >> > > > >> > > see
> >> > > > >> > > > someone else observing a larger # of partitions.
> >> > > > >> > > >
> >> > > > >> > > >
> >> > > > >> > > > >
> >> > > > >> > > > > Thanks,
> >> > > > >> > > > >
> >> > > > >> > > > > Jiangjie (Becket) Qin
> >> > > > >> > > > >
> >> > > > >> > > > >
> >> > > > >> > > > >
> >> > > > >> > > > >
> >> > > > >> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <
> >> > > > >> jason@confluent.io
> >> > > > >> > >
> >> > > > >> > > > > wrote:
> >> > > > >> > > > >
> >> > > > >> > > > > > Hi Kafka Devs,
> >> > > > >> > > > > >
> >> > > > >> > > > > > One of the nagging issues in the current design of
> the
> >> new
> >> > > > >> consumer
> >> > > > >> > > has
> >> > > > >> > > > > > been the need to support a variety of assignment
> >> > strategies.
> >> > > > >> We've
> >> > > > >> > > > > > encountered this in particular in the design of
> copycat
> >> > and
> >> > > > the
> >> > > > >> > > > > processing
> >> > > > >> > > > > > framework (KIP-28). From what I understand, Samza
> also
> >> > has a
> >> > > > >> number
> >> > > > >> > > of
> >> > > > >> > > > > use
> >> > > > >> > > > > > cases with custom assignment needs. The new consumer
> >> > > protocol
> >> > > > >> > > supports
> >> > > > >> > > > > new
> >> > > > >> > > > > > assignment strategies by hooking them into the
> broker.
> >> For
> >> > > > many
> >> > > > >> > > > > > environments, this is a major pain and in some
> cases, a
> >> > > > >> > non-starter.
> >> > > > >> > > It
> >> > > > >> > > > > > also challenges the validation that the coordinator
> can
> >> > > > provide.
> >> > > > >> > For
> >> > > > >> > > > > > example, some assignment strategies call for
> >> partitions to
> >> > > be
> >> > > > >> > > assigned
> >> > > > >> > > > > > multiple times, which means that the coordinator can
> >> only
> >> > > > check
> >> > > > >> > that
> >> > > > >> > > > > > partitions have been assigned at least once.
> >> > > > >> > > > > >
> >> > > > >> > > > > > To solve these issues, we'd like to propose moving
> >> > > assignment
> >> > > > to
> >> > > > >> > the
> >> > > > >> > > > > > client. I've written a wiki which outlines some
> >> protocol
> >> > > > >> changes to
> >> > > > >> > > > > achieve
> >> > > > >> > > > > > this:
> >> > > > >> > > > > >
> >> > > > >> > > > > >
> >> > > > >> > > > >
> >> > > > >> > > >
> >> > > > >> > >
> >> > > > >> >
> >> > > > >>
> >> > > >
> >> > >
> >> >
> >>
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> >> > > > >> > > > > > .
> >> > > > >> > > > > > To summarize briefly, instead of the coordinator
> >> assigning
> >> > > the
> >> > > > >> > > > partitions
> >> > > > >> > > > > > itself, all subscriptions are forwarded to each
> member
> >> of
> >> > > the
> >> > > > >> group
> >> > > > >> > > > which
> >> > > > >> > > > > > then decides independently which partitions it should
> >> > > consume.
> >> > > > >> The
> >> > > > >> > > > > protocol
> >> > > > >> > > > > > provides a mechanism for the coordinator to validate
> >> that
> >> > > all
> >> > > > >> > > consumers
> >> > > > >> > > > > use
> >> > > > >> > > > > > the same assignment strategy, but it does not ensure
> >> that
> >> > > the
> >> > > > >> > > resulting
> >> > > > >> > > > > > assignment is "correct." This provides a powerful
> >> > capability
> >> > > > for
> >> > > > >> > > users
> >> > > > >> > > > to
> >> > > > >> > > > > > control the full data flow on the client side. They
> >> > control
> >> > > > how
> >> > > > >> > data
> >> > > > >> > > is
> >> > > > >> > > > > > written to partitions through the Partitioner
> interface
> >> > and
> >> > > > they
> >> > > > >> > > > control
> >> > > > >> > > > > > how data is consumed through the assignment strategy,
> >> all
> >> > > > >> without
> >> > > > >> > > > > touching
> >> > > > >> > > > > > the server.
> >> > > > >> > > > > >
> >> > > > >> > > > > > Of course nothing comes for free. In particular, this
> >> > change
> >> > > > >> > removes
> >> > > > >> > > > the
> >> > > > >> > > > > > ability of the coordinator to validate that commits
> are
> >> > made
> >> > > > by
> >> > > > >> > > > consumers
> >> > > > >> > > > > > who were assigned the respective partition. This
> might
> >> not
> >> > > be
> >> > > > >> too
> >> > > > >> > bad
> >> > > > >> > > > > since
> >> > > > >> > > > > > we retain the ability to validate the generation id,
> >> but
> >> > it
> >> > > > is a
> >> > > > >> > > > > potential
> >> > > > >> > > > > > concern. We have considered alternative protocols
> which
> >> > add
> >> > > a
> >> > > > >> > second
> >> > > > >> > > > > > round-trip to the protocol in order to give the
> >> > coordinator
> >> > > > the
> >> > > > >> > > ability
> >> > > > >> > > > > to
> >> > > > >> > > > > > confirm the assignment. As mentioned above, the
> >> > coordinator
> >> > > is
> >> > > > >> > > somewhat
> >> > > > >> > > > > > limited in what it can actually validate, but this
> >> would
> >> > > > return
> >> > > > >> its
> >> > > > >> > > > > ability
> >> > > > >> > > > > > to validate commits. The tradeoff is that it
> increases
> >> the
> >> > > > >> > protocol's
> >> > > > >> > > > > > complexity which means more ways for the protocol to
> >> fail
> >> > > and
> >> > > > >> > > > > consequently
> >> > > > >> > > > > > more edge cases in the code.
> >> > > > >> > > > > >
> >> > > > >> > > > > > It also misses an opportunity to generalize the group
> >> > > > membership
> >> > > > >> > > > protocol
> >> > > > >> > > > > > for additional use cases. In fact, after you've gone
> to
> >> > the
> >> > > > >> trouble
> >> > > > >> > > of
> >> > > > >> > > > > > moving assignment to the client, the main thing that
> is
> >> > left
> >> > > > in
> >> > > > >> > this
> >> > > > >> > > > > > protocol is basically a general group management
> >> > capability.
> >> > > > >> This
> >> > > > >> > is
> >> > > > >> > > > > > exactly what is needed for a few cases that are
> >> currently
> >> > > > under
> >> > > > >> > > > > discussion
> >> > > > >> > > > > > (e.g. copycat or single-writer producer). We've taken
> >> this
> >> > > > >> further
> >> > > > >> > > step
> >> > > > >> > > > > in
> >> > > > >> > > > > > the proposal and attempted to envision what that
> >> general
> >> > > > >> protocol
> >> > > > >> > > might
> >> > > > >> > > > > > look like and how it could be used both by the
> consumer
> >> > and
> >> > > > for
> >> > > > >> > some
> >> > > > >> > > of
> >> > > > >> > > > > > these other cases.
> >> > > > >> > > > > >
> >> > > > >> > > > > > Anyway, since time is running out on the new
> consumer,
> >> we
> >> > > have
> >> > > > >> > > perhaps
> >> > > > >> > > > > one
> >> > > > >> > > > > > last chance to consider a significant change in the
> >> > protocol
> >> > > > >> like
> >> > > > >> > > this,
> >> > > > >> > > > > so
> >> > > > >> > > > > > have a look at the wiki and share your thoughts. I've
> >> no
> >> > > doubt
> >> > > > >> that
> >> > > > >> > > > some
> >> > > > >> > > > > > ideas seem clearer in my mind than they do on paper,
> so
> >> > ask
> >> > > > >> > questions
> >> > > > >> > > > if
> >> > > > >> > > > > > there is any confusion.
> >> > > > >> > > > > >
> >> > > > >> > > > > > Thanks!
> >> > > > >> > > > > > Jason
> >> > > > >> > > > > >
> >> > > > >> > > > >
> >> > > > >> > > >
> >> > > > >> > > >
> >> > > > >> > > >
> >> > > > >> > > > --
> >> > > > >> > > > Thanks,
> >> > > > >> > > > Ewen
> >> > > > >> > > >
> >> > > > >> > >
> >> > > > >> >
> >> > > > >> >
> >> > > > >> >
> >> > > > >> > --
> >> > > > >> > Thanks,
> >> > > > >> > Ewen
> >> > > > >> >
> >> > > > >>
> >> > > > >
> >> > > > >
> >> > > >
> >> > >
> >> >
> >>
> >
> >
> >
> > --
> > Thanks,
> > Neha
> >
>
>
>
> --
> Thanks,
> Neha
>



-- 
Thanks,
Ewen

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Neha Narkhede <ne...@confluent.io>.
Becket,

As you say, the metadata hash addresses the concern you originally raised
about large topic subscriptions. Can you please list other problems you are
raising more clearly? It is more helpful to know problems that the proposal
does not address or addresses poorly.

Regarding other things you said -

it is required that each
> consumer refresh their metadata before sending a JoinGroupRequest
>

This is required for wildcard topic subscriptions anyway. So this proposal
does not introduce a regression. We had agreed earlier that it does not
make sense for the server to deserialize regular expressions sent by the
consumer.


> the metadata might still be inconsistent if there is a topic or partition
> change because the
> UpdateMetadataRequest from controller might be handled at different time.
>

Topic metadata does not change frequently and even if it did, a couple
rebalance attempts will be needed whether the coordinator drives the
assignments or the consumer. Because guess how the coordinator knows about
the topic metadata changes -- indirectly through either a zk callback or
UpdateMetadataRequest, so it is completely possible the coordinator sees
the topic metadata changes in batches, not all at once.

On Thu, Aug 13, 2015 at 10:50 PM, Neha Narkhede <ne...@confluent.io> wrote:

> Ewen/Jason,
>
> The metadata hash is a clever approach and certainly addresses the problem
> of large metadata for consumers like mirror maker. Few comments -
>
>
>    1. In the interest of simplifying the format of the consumer's
>    metadata - Why not just always include only the topic names in the metadata
>    followed by the metadata hash? If the metadata hash check succeeds, each
>    consumer uses the # of partitions it had fetched. If it fails, a rebalance
>    happens and the metadata is not used anyway.
>    2. Do you need a topic list and topic regex to be separate? A single
>    topic or list of topics can be expressed as a regex.
>    3. Let's include a version explicitly at the beginning of the
>    ProtocolMetadata. The version dictates how to deserialize the
>    ProtocolMetadata blob and is consistent with the rest of Kafka.
>
> That can simplify the metadata format to the following:
>
> GroupType => "consumer"
>>
>> Protocol => AssignmentStrategy
>>   AssignmentStrategy   => String
>>
>> ProtocolMetadata => Version Subscription AssignmentStrategyMetadata
>
>     Version                    => String
>
>   Subscription                 => TopicRegex MetadataHash
>>     TopicRegex                 => String
>>     MetadataHash               => String
>>   AssignmentStrategyMetadata   => bytes
>
>
> On Thu, Aug 13, 2015 at 6:28 PM, Jiangjie Qin <jq...@linkedin.com.invalid>
> wrote:
>
>> Ewen and Jason,
>>
>> Thanks for the reply. Sorry I missed the metadata hash. Yes, that is a
>> clever approach and would solve my concern about the data passing around.
>> I
>> can see both pros and cons from doing this, though. The advantage is we
>> don't need the topic metadata in JoinGroupResponse anymore. The downside
>> is
>> that now rebalance have extra dependency on the consensus of metadata of
>> all consumers, which is obtained separately. So it is required that each
>> consumer refresh their metadata before sending a JoinGroupRequest,
>> otherwise in some cases (e.g. wildcard consumers) will almost certainly
>> fail for the first rebalance attempt. Even if we do that, since the
>> consumers are getting metadata from different brokers, the metadata might
>> still be inconsistent if there is a topic or partition change because the
>> UpdateMetadataRequest from controller might be handled at different time.
>> Just want to make sure we think through the cases so the protocol does not
>> cause us unexpected issues.
>>
>> About the number of consumers, I think with the current liveliness
>> definition, we can tolerate churns by bumping up the session timeout. Also
>> I guess we will see an increasing number of consumers for new consumer,
>> because every the old consumer thread will probably become a consumer.
>>
>> It is a valid concern for consumers that have large subscription set. This
>> might not be avoided though for client side assignment approach. One
>> solution is having topic names associate with a topic ID. And only use
>> topic ID in JoinGroupRequest and JoinGroupResponse, There is a discussion
>> thread about this to solve the topic renaming case but this is a
>> completely
>> different discussion.
>>
>> Thanks,
>>
>> Jiangjie (Becket) Qin
>>
>>
>>
>> On Thu, Aug 13, 2015 at 2:14 PM, Jason Gustafson <ja...@confluent.io>
>> wrote:
>>
>> > Thanks Jiangjie, that information helps. I agree the protocol must
>> consider
>> > scalability. My point was that the synchronization barrier in the
>> current
>> > protocol already effectively limits the number of consumers since it
>> > provides no way to gracefully handle churn. It wouldn't be worth
>> worrying
>> > about scaling up to 100,000 members, for example, because there's no way
>> > the group would be stable. So we just need to set some clear
>> expectations
>> > on the size we can scale to, and that can help inform the discussion on
>> the
>> > size of messages in this protocol.
>> >
>> > Ewen and I were discussing this morning along similar lines to what
>> you're
>> > suggesting. However, even if the coordinator decides on the metadata for
>> > the group, each member still needs to communicate its subscriptions to
>> the
>> > rest of the group. This is nice for the regex case since the regex is
>> > probably small, but if the members have a large topic list, then we have
>> > the same problem. One thing I was thinking about was whether we really
>> need
>> > to handle different subscriptions for every member. If the coordinator
>> > could guarantee that all members had the same subscription, then there
>> > would be no need for the coordinator to return the subscriptions for
>> each
>> > member. However, this would prevent graceful upgrades. We might be able
>> to
>> > fix that problem by allowing the consumer to provide two subscriptions
>> to
>> > allowing rolling updates, but that starts to sound pretty nasty.
>> >
>> > -Jason
>> >
>> > On Thu, Aug 13, 2015 at 1:41 PM, Jiangjie Qin <jqin@linkedin.com.invalid
>> >
>> > wrote:
>> >
>> > > Jason,
>> > >
>> > > The protocol has to consider the scalability. The protocol in the wiki
>> > > means the JoinGroupResoponse size would be:
>> > > NumberOfTopics * (AvgTopicNameLength + 4) * (NumberOfConsumers)^2
>> > >
>> > > To give some real number, we have 26-node Mirror Maker cluster, each
>> > with 4
>> > > consumers. That is 104 consumers using regex ".*". And most of our
>> > clusters
>> > > have around 3000 topics, whose topic name are typically around 20
>> > > characters.
>> > >
>> > > I think the key issue for client side partition assignment logic is to
>> > make
>> > > sure 1) all the clients run the same algorithm. 2) all the clients
>> make
>> > > decision on the same topic metadata. The second purpose can be done by
>> > > simply letting coordinator provide the topic metadata and all then
>> member
>> > > information as source of truth. Is it necessary to pass topic
>> metadata of
>> > > each consumer around? Can we keep the protocol metadata field
>> completely
>> > > independent of topic metadata? I think In the JoinGroupResponse, we
>> > should
>> > > have only one copy of topic metadata provided by coordinator and is
>> > outside
>> > > of protocol metadata. If user decides to put some metadata in the
>> > > JoinGroupRequest and let coordinator pass around, they are responsible
>> > for
>> > > understanding the risk.
>> > >
>> > > Thanks,
>> > >
>> > > Jiangjie (Becket) Qin
>> > >
>> > >
>> > > On Thu, Aug 13, 2015 at 12:41 PM, Jason Gustafson <jason@confluent.io
>> >
>> > > wrote:
>> > >
>> > > > Hey Onur and Jiangjie,
>> > > >
>> > > > I've updated that wiki with a proposal to add regex subscriptions to
>> > the
>> > > > consumer metadata. Can you have a look to see if it addresses your
>> > > concern?
>> > > > In general, I think we should be a little careful when we are
>> talking
>> > > about
>> > > > the scalability of the protocol. Regardless of whether assignment is
>> > done
>> > > > on the server or the client, the protocol assumes a relatively
>> stable
>> > > > configuration. When the number of consumers increases beyond a
>> certain
>> > > > limit, then membership churn becomes a major concern. Similarly
>> there
>> > is
>> > > a
>> > > > notion of metadata churn when topics are added, deleted, or
>> resized. If
>> > > > either membership or metadata changes, then the protocol forces all
>> > > > consumers to stop consumption and rejoin the group. If this happens
>> > often
>> > > > enough, then it can severely impact the ability of the consumer to
>> make
>> > > > progress. The point is that the protocol may already be unsuited to
>> > cases
>> > > > where there are either a large number of consumers or topics. I
>> wonder
>> > if
>> > > > you guys can share your thoughts about your scaling expectations?
>> > > >
>> > > > -Jason
>> > > >
>> > > >
>> > > >
>> > > >
>> > > > On Wed, Aug 12, 2015 at 12:28 PM, Jason Gustafson <
>> jason@confluent.io>
>> > > > wrote:
>> > > >
>> > > > > Hey Jiangjie,
>> > > > >
>> > > > > That's a great point. In the worst case (the mirror maker case I
>> > > guess),
>> > > > > the join group response can be massive. This would be especially
>> > deadly
>> > > > > when there is a lot of churn in the group (e.g. in a rolling
>> > upgrade).
>> > > > The
>> > > > > current protocol is not great for this case either, but it's
>> > > > significantly
>> > > > > better. Here are a couple ways to deal with the size:
>> > > > >
>> > > > > 1. First, we could have the coordinator compress the responses.
>> This
>> > > > would
>> > > > > probably be pretty effective if applied across the metadata from
>> all
>> > > > > members.
>> > > > >
>> > > > > 2. I think the regex case is the main problem. Is that right? We
>> > could
>> > > > > extend the metadata to allow the consumer to embed its regex
>> > > subscription
>> > > > > in the metadata directly (note this might be a good idea
>> regardless
>> > of
>> > > > the
>> > > > > rest of this proposal). To support regex on the consumer, we must
>> > fetch
>> > > > > metadata for all topics. Rather than having all regex subscribers
>> > embed
>> > > > all
>> > > > > of this metadata in their join group requests, they could instead
>> > > embed a
>> > > > > hash of it. Then after the join group responses are received, they
>> > just
>> > > > > need to check that the hashes are the same. If there is a mismatch
>> > > (which
>> > > > > should only occur when topics are created, deleted, or resized),
>> then
>> > > the
>> > > > > group members must refetch the metadata and rejoin the group.
>> This is
>> > > > also
>> > > > > how the current protocol behaves when there is a change in the
>> topic
>> > > > > metadata affecting the group--someone (either the coordinator or
>> the
>> > > > > consumer) detects the change and forces the group to rebalance.
>> > > > >
>> > > > > What do you think?
>> > > > >
>> > > > > (Also I think adding groupId/generationId to fetch and produce
>> > requests
>> > > > > seems like an interesting line of thought.)
>> > > > >
>> > > > > -Jason
>> > > > >
>> > > > >
>> > > > >
>> > > > > On Wed, Aug 12, 2015 at 10:57 AM, Jiangjie Qin
>> > > <jqin@linkedin.com.invalid
>> > > > >
>> > > > > wrote:
>> > > > >
>> > > > >> Hey Ewen,
>> > > > >>
>> > > > >> Onur and I discussed this a little bit more. And we are still
>> > worrying
>> > > > >> about passing all the metadata of all consumers around.
>> > > > >>
>> > > > >> Let's say I have a cluster has 10,000 topics, the average topic
>> name
>> > > > >> length
>> > > > >> is 10 bytes. In this case, the opaque metadata will have 10 *
>> > 10,000 =
>> > > > >> 100KB for topic name, for each topic, there is a 4-byte integer
>> of
>> > > > number
>> > > > >> of partitions, that's another 40KB. So one global topic metadata
>> > will
>> > > > have
>> > > > >> 140KB data. If I have 100 consumers who are using wildcard to
>> > consume
>> > > > from
>> > > > >> all the topics. That means the protocol metadata end up in the
>> > > > >> JoinGroupResponse will be 140KB * 100 = 14MB. And the
>> > > JoinGroupResponse
>> > > > >> will need to be sent to 100 different consumers, that means 14MB
>> *
>> > > 100 =
>> > > > >> 1.4GB need to be sent by the consumer coordinator for one
>> rebalance.
>> > > How
>> > > > >> would that work?
>> > > > >>
>> > > > >> Also, having two consumers (old owner and new owner) consuming
>> from
>> > > the
>> > > > >> same partition might also be a problem. e.g. people are updating
>> > > > database.
>> > > > >> One thing might worth doing is to add GroupId and Generation ID
>> to
>> > > > >> ProducerRequest and FetchRequest as well. This will also help
>> with
>> > the
>> > > > >> single producer use case. However, this is probably orthogonal to
>> > this
>> > > > >> thread given the current new consumer also has this problem and I
>> > > > believe
>> > > > >> we need to fix it.
>> > > > >>
>> > > > >> Thanks,
>> > > > >>
>> > > > >> Jiangjie (Becket) Qin
>> > > > >>
>> > > > >> On Tue, Aug 11, 2015 at 11:43 PM, Ewen Cheslack-Postava <
>> > > > >> ewen@confluent.io>
>> > > > >> wrote:
>> > > > >>
>> > > > >> > On Tue, Aug 11, 2015 at 11:29 PM, Jiangjie Qin
>> > > > >> <jq...@linkedin.com.invalid>
>> > > > >> > wrote:
>> > > > >> >
>> > > > >> > > Ewen,
>> > > > >> > >
>> > > > >> > > Thanks for the explanation.
>> > > > >> > >
>> > > > >> > > For (1), I am more concerned about the failure case instead
>> of
>> > > > normal
>> > > > >> > case.
>> > > > >> > > What if a consumer somehow was kick out of a group but is
>> still
>> > > > >> consuming
>> > > > >> > > and committing offsets? Does that mean the new owner and old
>> > owner
>> > > > >> might
>> > > > >> > > potentially consuming from and committing offsets for the
>> same
>> > > > >> partition?
>> > > > >> > > In the old consumer, this won't happen because the new
>> consumer
>> > > will
>> > > > >> not
>> > > > >> > be
>> > > > >> > > able to start consumption unless the previous owner has
>> released
>> > > its
>> > > > >> > > ownership. Basically, without the ownership guarantee, I
>> don't
>> > see
>> > > > how
>> > > > >> > the
>> > > > >> > > communication among consumers themselves alone can solve the
>> > > problem
>> > > > >> > here.
>> > > > >> > >
>> > > > >> >
>> > > > >> > The generation ID check still applies to offset commits. If
>> one of
>> > > the
>> > > > >> > consumers is kicked out and misbehaving, it can obviously still
>> > > fetch
>> > > > >> and
>> > > > >> > process messages, but offset commits will not work since it
>> will
>> > not
>> > > > >> have
>> > > > >> > the current generation ID.
>> > > > >> >
>> > > > >> >
>> > > > >> > >
>> > > > >> > > For (2) and (3), now I understand how metadata are used. But
>> I
>> > > still
>> > > > >> > don't
>> > > > >> > > see why should we let the consumers to pass the topic
>> > information
>> > > > >> across
>> > > > >> > > instead of letting coordinator give the information. The
>> single
>> > > > >> producer
>> > > > >> > > use case does not solve the ownership problem in abnormal
>> case
>> > > > either,
>> > > > >> > > which seems to be a little bit vulnerable.
>> > > > >> > >
>> > > > >> >
>> > > > >> > One of the goals here was to generalize group membership so we
>> > can,
>> > > > for
>> > > > >> > example, use it for balancing Copycat tasks across workers.
>> > There's
>> > > no
>> > > > >> > topic subscription info in that case. The metadata for copycat
>> > > workers
>> > > > >> > would instead need to somehow indicate the current set of tasks
>> > that
>> > > > >> need
>> > > > >> > to be assigned to workers. By making the metadata completely
>> > opaque
>> > > to
>> > > > >> the
>> > > > >> > protocol, it becomes more generally useful since it focuses
>> > squarely
>> > > > on
>> > > > >> the
>> > > > >> > group membership problem, allowing for that additional bit of
>> > > metadata
>> > > > >> so
>> > > > >> > you don't just get a list of members, but also get a little
>> bit of
>> > > > info
>> > > > >> > about each of them.
>> > > > >> >
>> > > > >> > A different option that we explored is to use a sort of mixed
>> > model
>> > > --
>> > > > >> > still bake all the topic subscriptions directly into the
>> protocol
>> > > but
>> > > > >> also
>> > > > >> > include metadata. That would allow us to maintain the existing
>> > > > >> > coordinator-driven approach to handling the metadata and change
>> > > events
>> > > > >> like
>> > > > >> > the ones Onur pointed out. Then something like the Copycat
>> workers
>> > > > would
>> > > > >> > just not fill in any topic subscriptions and it would be
>> handled
>> > as
>> > > a
>> > > > >> > degenerate case. Based on the way I explained that we can
>> handle
>> > > those
>> > > > >> > types of events, I personally feel its cleaner and a nicer
>> > > > >> generalization
>> > > > >> > to not include the subscriptions in the join group protocol,
>> > making
>> > > it
>> > > > >> part
>> > > > >> > of the metadata instead.
>> > > > >> >
>> > > > >> > For the single producer case, are you saying it doesn't solve
>> > > > ownership
>> > > > >> in
>> > > > >> > the abnormal case because a producer that doesn't know it has
>> been
>> > > > >> kicked
>> > > > >> > out of the group yet can still produce data even though it
>> > shouldn't
>> > > > be
>> > > > >> > able to anymore? I definitely agree that that is a risk -- this
>> > > > >> provides a
>> > > > >> > way to get closer to a true single-writer, but there are
>> > definitely
>> > > > >> still
>> > > > >> > failure modes that this does not address.
>> > > > >> >
>> > > > >> > -Ewen
>> > > > >> >
>> > > > >> >
>> > > > >> > >
>> > > > >> > > Thanks,
>> > > > >> > >
>> > > > >> > > Jiangjie (Becket) Qin
>> > > > >> > >
>> > > > >> > >
>> > > > >> > > On Tue, Aug 11, 2015 at 11:06 PM, Ewen Cheslack-Postava <
>> > > > >> > ewen@confluent.io
>> > > > >> > > >
>> > > > >> > > wrote:
>> > > > >> > >
>> > > > >> > > > On Tue, Aug 11, 2015 at 10:15 PM, Jiangjie Qin
>> > > > >> > <jqin@linkedin.com.invalid
>> > > > >> > > >
>> > > > >> > > > wrote:
>> > > > >> > > >
>> > > > >> > > > > Hi Jason,
>> > > > >> > > > >
>> > > > >> > > > > Thanks for writing this up. It would be useful to
>> generalize
>> > > the
>> > > > >> > group
>> > > > >> > > > > concept. I have a few questions below.
>> > > > >> > > > >
>> > > > >> > > > > 1. In old consumer actually the partition assignment are
>> > done
>> > > by
>> > > > >> > > > consumers
>> > > > >> > > > > themselves. We used zookeeper to guarantee that a
>> partition
>> > > will
>> > > > >> only
>> > > > >> > > be
>> > > > >> > > > > consumed by one consumer thread who successfully claimed
>> its
>> > > > >> > ownership.
>> > > > >> > > > > Does the new protocol plan to provide the same guarantee?
>> > > > >> > > > >
>> > > > >> > > >
>> > > > >> > > > Once you have all the metadata from all the consumers,
>> > > assignment
>> > > > >> > should
>> > > > >> > > > just be a simple function mapping that Map<ConsumerId,
>> > Metadata>
>> > > > to
>> > > > >> > > > Map<ConsumerId, List<TopicPartition>>. If everyone is
>> > consistent
>> > > > in
>> > > > >> > > > computing that, you don't need ZK involved at all.
>> > > > >> > > >
>> > > > >> > > > In practice, this shouldn't be that hard to ensure for most
>> > > > >> assignment
>> > > > >> > > > strategies just by having decent unit testing on them. You
>> > just
>> > > > >> have to
>> > > > >> > > do
>> > > > >> > > > things like ensure your assignment strategy sorts lists
>> into a
>> > > > >> > consistent
>> > > > >> > > > order.
>> > > > >> > > >
>> > > > >> > > > You do give up the ability to use some techniques (e.g. any
>> > > > >> randomized
>> > > > >> > > > algorithm if you can't distribute the seed w/ the metadata)
>> > and
>> > > > it's
>> > > > >> > true
>> > > > >> > > > that nothing validates the assignment, but if that
>> assignment
>> > > > >> algorithm
>> > > > >> > > > step is kept simple, small, and well tested, the risk is
>> very
>> > > > >> minimal.
>> > > > >> > > >
>> > > > >> > > >
>> > > > >> > > > >
>> > > > >> > > > > 2. It looks that both JoinGroupRequest and
>> JoinGroupResponse
>> > > has
>> > > > >> the
>> > > > >> > > > > ProtocolMetadata.AssignmentStrategyMetadata, what would
>> be
>> > the
>> > > > >> > metadata
>> > > > >> > > > be
>> > > > >> > > > > sent and returned by coordinator? How will the
>> coordinator
>> > > > handle
>> > > > >> the
>> > > > >> > > > > metadata?
>> > > > >> > > > >
>> > > > >> > > >
>> > > > >> > > > The coordinator is basically just blindly broadcasting all
>> of
>> > it
>> > > > to
>> > > > >> > group
>> > > > >> > > > members so they have a consistent view.
>> > > > >> > > >
>> > > > >> > > > So from the coordinators perspective, it sees something
>> like:
>> > > > >> > > >
>> > > > >> > > > Consumer 1 -> JoinGroupRequest with GroupProtocols = [
>> > > "consumer"
>> > > > >> > > > <Consumer1 opaque byte[]>]
>> > > > >> > > > Consumer 2 -> JoinGroupRequest with GroupProtocols = [
>> > > "consumer"
>> > > > >> > > > <Consumer2 opaque byte[]>]
>> > > > >> > > >
>> > > > >> > > > Then, in the responses would look like:
>> > > > >> > > >
>> > > > >> > > > Consumer 1 <- JoinGroupResponse with GroupProtocol =
>> > "consumer"
>> > > > and
>> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque byte[]>,
>> > Consumer
>> > > 2
>> > > > >> > > > <Consumer2 opaque byte[]>]
>> > > > >> > > > Consumer 2 <- JoinGroupResponse with GroupProtocol =
>> > "consumer"
>> > > > and
>> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque byte[]>,
>> > Consumer
>> > > 2
>> > > > >> > > > <Consumer2 opaque byte[]>]
>> > > > >> > > >
>> > > > >> > > > So all the responses include all the metadata for every
>> member
>> > > in
>> > > > >> the
>> > > > >> > > > group, and everyone can use that to consistently decide on
>> > > > >> assignment.
>> > > > >> > > The
>> > > > >> > > > broker doesn't care and cannot even understand the metadata
>> > > since
>> > > > >> the
>> > > > >> > > data
>> > > > >> > > > format for it is dependent on the assignment strategy being
>> > > used.
>> > > > >> > > >
>> > > > >> > > > As another example that is *not* a consumer, let's say you
>> > just
>> > > > >> want to
>> > > > >> > > > have a single writer in the group which everyone will
>> forward
>> > > > >> requests
>> > > > >> > > to.
>> > > > >> > > > To accomplish this, you could use a very dumb assignment
>> > > strategy:
>> > > > >> > there
>> > > > >> > > is
>> > > > >> > > > no metadata (empty byte[]) and all we care about is who is
>> the
>> > > > first
>> > > > >> > > member
>> > > > >> > > > in the group (e.g. when IDs are sorted lexicographically).
>> > That
>> > > > >> member
>> > > > >> > is
>> > > > >> > > > selected as the writer. In that case, we actually just care
>> > > about
>> > > > >> the
>> > > > >> > > > membership list, there's no additional info about each
>> member
>> > > that
>> > > > >> is
>> > > > >> > > > required to determine who is the writer.
>> > > > >> > > >
>> > > > >> > > >
>> > > > >> > > > > 3. Do you mean that the number of partitions in
>> > > > JoinGroupResponse
>> > > > >> > will
>> > > > >> > > be
>> > > > >> > > > > the max partition number of a topic among all the
>> reported
>> > > > >> partition
>> > > > >> > > > number
>> > > > >> > > > > by consumers? Is there any reason not just let
>> Coordinator
>> > to
>> > > > >> return
>> > > > >> > > the
>> > > > >> > > > > number of partitions of a topic in its metadata cache?
>> > > > >> > > > >
>> > > > >> > > >
>> > > > >> > > > Nothing from the embedded protocol is touched by the
>> broker.
>> > The
>> > > > >> broker
>> > > > >> > > > just collects opaque bytes of metadata, does the selection
>> of
>> > > the
>> > > > >> > > strategy
>> > > > >> > > > if multiple are supported by some consumers, and then
>> returns
>> > > that
>> > > > >> > opaque
>> > > > >> > > > metadata for all the members back to every member. In that
>> way
>> > > > they
>> > > > >> all
>> > > > >> > > > have a consistent view of the group. For regular consumers,
>> > that
>> > > > >> view
>> > > > >> > of
>> > > > >> > > > the group includes information about how many partitions
>> each
>> > > > >> consumer
>> > > > >> > > > currently thinks the topics it is subscribed to has. These
>> > could
>> > > > be
>> > > > >> > > > inconsistent due to out of date metadata and it would be
>> up to
>> > > the
>> > > > >> > > > assignment strategy on the *client* to resolve that. As you
>> > > point
>> > > > >> out,
>> > > > >> > in
>> > > > >> > > > that case they could just take the max value that any
>> consumer
>> > > > >> reported
>> > > > >> > > > seeing and use that. The consumers that notice that their
>> > > metadata
>> > > > >> had
>> > > > >> > a
>> > > > >> > > > smaller # of partitions should also trigger a metadata
>> update
>> > > when
>> > > > >> they
>> > > > >> > > see
>> > > > >> > > > someone else observing a larger # of partitions.
>> > > > >> > > >
>> > > > >> > > >
>> > > > >> > > > >
>> > > > >> > > > > Thanks,
>> > > > >> > > > >
>> > > > >> > > > > Jiangjie (Becket) Qin
>> > > > >> > > > >
>> > > > >> > > > >
>> > > > >> > > > >
>> > > > >> > > > >
>> > > > >> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <
>> > > > >> jason@confluent.io
>> > > > >> > >
>> > > > >> > > > > wrote:
>> > > > >> > > > >
>> > > > >> > > > > > Hi Kafka Devs,
>> > > > >> > > > > >
>> > > > >> > > > > > One of the nagging issues in the current design of the
>> new
>> > > > >> consumer
>> > > > >> > > has
>> > > > >> > > > > > been the need to support a variety of assignment
>> > strategies.
>> > > > >> We've
>> > > > >> > > > > > encountered this in particular in the design of copycat
>> > and
>> > > > the
>> > > > >> > > > > processing
>> > > > >> > > > > > framework (KIP-28). From what I understand, Samza also
>> > has a
>> > > > >> number
>> > > > >> > > of
>> > > > >> > > > > use
>> > > > >> > > > > > cases with custom assignment needs. The new consumer
>> > > protocol
>> > > > >> > > supports
>> > > > >> > > > > new
>> > > > >> > > > > > assignment strategies by hooking them into the broker.
>> For
>> > > > many
>> > > > >> > > > > > environments, this is a major pain and in some cases, a
>> > > > >> > non-starter.
>> > > > >> > > It
>> > > > >> > > > > > also challenges the validation that the coordinator can
>> > > > provide.
>> > > > >> > For
>> > > > >> > > > > > example, some assignment strategies call for
>> partitions to
>> > > be
>> > > > >> > > assigned
>> > > > >> > > > > > multiple times, which means that the coordinator can
>> only
>> > > > check
>> > > > >> > that
>> > > > >> > > > > > partitions have been assigned at least once.
>> > > > >> > > > > >
>> > > > >> > > > > > To solve these issues, we'd like to propose moving
>> > > assignment
>> > > > to
>> > > > >> > the
>> > > > >> > > > > > client. I've written a wiki which outlines some
>> protocol
>> > > > >> changes to
>> > > > >> > > > > achieve
>> > > > >> > > > > > this:
>> > > > >> > > > > >
>> > > > >> > > > > >
>> > > > >> > > > >
>> > > > >> > > >
>> > > > >> > >
>> > > > >> >
>> > > > >>
>> > > >
>> > >
>> >
>> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
>> > > > >> > > > > > .
>> > > > >> > > > > > To summarize briefly, instead of the coordinator
>> assigning
>> > > the
>> > > > >> > > > partitions
>> > > > >> > > > > > itself, all subscriptions are forwarded to each member
>> of
>> > > the
>> > > > >> group
>> > > > >> > > > which
>> > > > >> > > > > > then decides independently which partitions it should
>> > > consume.
>> > > > >> The
>> > > > >> > > > > protocol
>> > > > >> > > > > > provides a mechanism for the coordinator to validate
>> that
>> > > all
>> > > > >> > > consumers
>> > > > >> > > > > use
>> > > > >> > > > > > the same assignment strategy, but it does not ensure
>> that
>> > > the
>> > > > >> > > resulting
>> > > > >> > > > > > assignment is "correct." This provides a powerful
>> > capability
>> > > > for
>> > > > >> > > users
>> > > > >> > > > to
>> > > > >> > > > > > control the full data flow on the client side. They
>> > control
>> > > > how
>> > > > >> > data
>> > > > >> > > is
>> > > > >> > > > > > written to partitions through the Partitioner interface
>> > and
>> > > > they
>> > > > >> > > > control
>> > > > >> > > > > > how data is consumed through the assignment strategy,
>> all
>> > > > >> without
>> > > > >> > > > > touching
>> > > > >> > > > > > the server.
>> > > > >> > > > > >
>> > > > >> > > > > > Of course nothing comes for free. In particular, this
>> > change
>> > > > >> > removes
>> > > > >> > > > the
>> > > > >> > > > > > ability of the coordinator to validate that commits are
>> > made
>> > > > by
>> > > > >> > > > consumers
>> > > > >> > > > > > who were assigned the respective partition. This might
>> not
>> > > be
>> > > > >> too
>> > > > >> > bad
>> > > > >> > > > > since
>> > > > >> > > > > > we retain the ability to validate the generation id,
>> but
>> > it
>> > > > is a
>> > > > >> > > > > potential
>> > > > >> > > > > > concern. We have considered alternative protocols which
>> > add
>> > > a
>> > > > >> > second
>> > > > >> > > > > > round-trip to the protocol in order to give the
>> > coordinator
>> > > > the
>> > > > >> > > ability
>> > > > >> > > > > to
>> > > > >> > > > > > confirm the assignment. As mentioned above, the
>> > coordinator
>> > > is
>> > > > >> > > somewhat
>> > > > >> > > > > > limited in what it can actually validate, but this
>> would
>> > > > return
>> > > > >> its
>> > > > >> > > > > ability
>> > > > >> > > > > > to validate commits. The tradeoff is that it increases
>> the
>> > > > >> > protocol's
>> > > > >> > > > > > complexity which means more ways for the protocol to
>> fail
>> > > and
>> > > > >> > > > > consequently
>> > > > >> > > > > > more edge cases in the code.
>> > > > >> > > > > >
>> > > > >> > > > > > It also misses an opportunity to generalize the group
>> > > > membership
>> > > > >> > > > protocol
>> > > > >> > > > > > for additional use cases. In fact, after you've gone to
>> > the
>> > > > >> trouble
>> > > > >> > > of
>> > > > >> > > > > > moving assignment to the client, the main thing that is
>> > left
>> > > > in
>> > > > >> > this
>> > > > >> > > > > > protocol is basically a general group management
>> > capability.
>> > > > >> This
>> > > > >> > is
>> > > > >> > > > > > exactly what is needed for a few cases that are
>> currently
>> > > > under
>> > > > >> > > > > discussion
>> > > > >> > > > > > (e.g. copycat or single-writer producer). We've taken
>> this
>> > > > >> further
>> > > > >> > > step
>> > > > >> > > > > in
>> > > > >> > > > > > the proposal and attempted to envision what that
>> general
>> > > > >> protocol
>> > > > >> > > might
>> > > > >> > > > > > look like and how it could be used both by the consumer
>> > and
>> > > > for
>> > > > >> > some
>> > > > >> > > of
>> > > > >> > > > > > these other cases.
>> > > > >> > > > > >
>> > > > >> > > > > > Anyway, since time is running out on the new consumer,
>> we
>> > > have
>> > > > >> > > perhaps
>> > > > >> > > > > one
>> > > > >> > > > > > last chance to consider a significant change in the
>> > protocol
>> > > > >> like
>> > > > >> > > this,
>> > > > >> > > > > so
>> > > > >> > > > > > have a look at the wiki and share your thoughts. I've
>> no
>> > > doubt
>> > > > >> that
>> > > > >> > > > some
>> > > > >> > > > > > ideas seem clearer in my mind than they do on paper, so
>> > ask
>> > > > >> > questions
>> > > > >> > > > if
>> > > > >> > > > > > there is any confusion.
>> > > > >> > > > > >
>> > > > >> > > > > > Thanks!
>> > > > >> > > > > > Jason
>> > > > >> > > > > >
>> > > > >> > > > >
>> > > > >> > > >
>> > > > >> > > >
>> > > > >> > > >
>> > > > >> > > > --
>> > > > >> > > > Thanks,
>> > > > >> > > > Ewen
>> > > > >> > > >
>> > > > >> > >
>> > > > >> >
>> > > > >> >
>> > > > >> >
>> > > > >> > --
>> > > > >> > Thanks,
>> > > > >> > Ewen
>> > > > >> >
>> > > > >>
>> > > > >
>> > > > >
>> > > >
>> > >
>> >
>>
>
>
>
> --
> Thanks,
> Neha
>



-- 
Thanks,
Neha

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Neha Narkhede <ne...@confluent.io>.
Ewen/Jason,

The metadata hash is a clever approach and certainly addresses the problem
of large metadata for consumers like mirror maker. Few comments -


   1. In the interest of simplifying the format of the consumer's metadata
   - Why not just always include only the topic names in the metadata followed
   by the metadata hash? If the metadata hash check succeeds, each consumer
   uses the # of partitions it had fetched. If it fails, a rebalance happens
   and the metadata is not used anyway.
   2. Do you need a topic list and topic regex to be separate? A single
   topic or list of topics can be expressed as a regex.
   3. Let's include a version explicitly at the beginning of the
   ProtocolMetadata. The version dictates how to deserialize the
   ProtocolMetadata blob and is consistent with the rest of Kafka.

That can simplify the metadata format to the following:

GroupType => "consumer"
>
> Protocol => AssignmentStrategy
>   AssignmentStrategy   => String
>
> ProtocolMetadata => Version Subscription AssignmentStrategyMetadata

    Version                    => String

  Subscription                 => TopicRegex MetadataHash
>     TopicRegex                 => String
>     MetadataHash               => String
>   AssignmentStrategyMetadata   => bytes


On Thu, Aug 13, 2015 at 6:28 PM, Jiangjie Qin <jq...@linkedin.com.invalid>
wrote:

> Ewen and Jason,
>
> Thanks for the reply. Sorry I missed the metadata hash. Yes, that is a
> clever approach and would solve my concern about the data passing around. I
> can see both pros and cons from doing this, though. The advantage is we
> don't need the topic metadata in JoinGroupResponse anymore. The downside is
> that now rebalance have extra dependency on the consensus of metadata of
> all consumers, which is obtained separately. So it is required that each
> consumer refresh their metadata before sending a JoinGroupRequest,
> otherwise in some cases (e.g. wildcard consumers) will almost certainly
> fail for the first rebalance attempt. Even if we do that, since the
> consumers are getting metadata from different brokers, the metadata might
> still be inconsistent if there is a topic or partition change because the
> UpdateMetadataRequest from controller might be handled at different time.
> Just want to make sure we think through the cases so the protocol does not
> cause us unexpected issues.
>
> About the number of consumers, I think with the current liveliness
> definition, we can tolerate churns by bumping up the session timeout. Also
> I guess we will see an increasing number of consumers for new consumer,
> because every the old consumer thread will probably become a consumer.
>
> It is a valid concern for consumers that have large subscription set. This
> might not be avoided though for client side assignment approach. One
> solution is having topic names associate with a topic ID. And only use
> topic ID in JoinGroupRequest and JoinGroupResponse, There is a discussion
> thread about this to solve the topic renaming case but this is a completely
> different discussion.
>
> Thanks,
>
> Jiangjie (Becket) Qin
>
>
>
> On Thu, Aug 13, 2015 at 2:14 PM, Jason Gustafson <ja...@confluent.io>
> wrote:
>
> > Thanks Jiangjie, that information helps. I agree the protocol must
> consider
> > scalability. My point was that the synchronization barrier in the current
> > protocol already effectively limits the number of consumers since it
> > provides no way to gracefully handle churn. It wouldn't be worth worrying
> > about scaling up to 100,000 members, for example, because there's no way
> > the group would be stable. So we just need to set some clear expectations
> > on the size we can scale to, and that can help inform the discussion on
> the
> > size of messages in this protocol.
> >
> > Ewen and I were discussing this morning along similar lines to what
> you're
> > suggesting. However, even if the coordinator decides on the metadata for
> > the group, each member still needs to communicate its subscriptions to
> the
> > rest of the group. This is nice for the regex case since the regex is
> > probably small, but if the members have a large topic list, then we have
> > the same problem. One thing I was thinking about was whether we really
> need
> > to handle different subscriptions for every member. If the coordinator
> > could guarantee that all members had the same subscription, then there
> > would be no need for the coordinator to return the subscriptions for each
> > member. However, this would prevent graceful upgrades. We might be able
> to
> > fix that problem by allowing the consumer to provide two subscriptions to
> > allowing rolling updates, but that starts to sound pretty nasty.
> >
> > -Jason
> >
> > On Thu, Aug 13, 2015 at 1:41 PM, Jiangjie Qin <jqin@linkedin.com.invalid
> >
> > wrote:
> >
> > > Jason,
> > >
> > > The protocol has to consider the scalability. The protocol in the wiki
> > > means the JoinGroupResoponse size would be:
> > > NumberOfTopics * (AvgTopicNameLength + 4) * (NumberOfConsumers)^2
> > >
> > > To give some real number, we have 26-node Mirror Maker cluster, each
> > with 4
> > > consumers. That is 104 consumers using regex ".*". And most of our
> > clusters
> > > have around 3000 topics, whose topic name are typically around 20
> > > characters.
> > >
> > > I think the key issue for client side partition assignment logic is to
> > make
> > > sure 1) all the clients run the same algorithm. 2) all the clients make
> > > decision on the same topic metadata. The second purpose can be done by
> > > simply letting coordinator provide the topic metadata and all then
> member
> > > information as source of truth. Is it necessary to pass topic metadata
> of
> > > each consumer around? Can we keep the protocol metadata field
> completely
> > > independent of topic metadata? I think In the JoinGroupResponse, we
> > should
> > > have only one copy of topic metadata provided by coordinator and is
> > outside
> > > of protocol metadata. If user decides to put some metadata in the
> > > JoinGroupRequest and let coordinator pass around, they are responsible
> > for
> > > understanding the risk.
> > >
> > > Thanks,
> > >
> > > Jiangjie (Becket) Qin
> > >
> > >
> > > On Thu, Aug 13, 2015 at 12:41 PM, Jason Gustafson <ja...@confluent.io>
> > > wrote:
> > >
> > > > Hey Onur and Jiangjie,
> > > >
> > > > I've updated that wiki with a proposal to add regex subscriptions to
> > the
> > > > consumer metadata. Can you have a look to see if it addresses your
> > > concern?
> > > > In general, I think we should be a little careful when we are talking
> > > about
> > > > the scalability of the protocol. Regardless of whether assignment is
> > done
> > > > on the server or the client, the protocol assumes a relatively stable
> > > > configuration. When the number of consumers increases beyond a
> certain
> > > > limit, then membership churn becomes a major concern. Similarly there
> > is
> > > a
> > > > notion of metadata churn when topics are added, deleted, or resized.
> If
> > > > either membership or metadata changes, then the protocol forces all
> > > > consumers to stop consumption and rejoin the group. If this happens
> > often
> > > > enough, then it can severely impact the ability of the consumer to
> make
> > > > progress. The point is that the protocol may already be unsuited to
> > cases
> > > > where there are either a large number of consumers or topics. I
> wonder
> > if
> > > > you guys can share your thoughts about your scaling expectations?
> > > >
> > > > -Jason
> > > >
> > > >
> > > >
> > > >
> > > > On Wed, Aug 12, 2015 at 12:28 PM, Jason Gustafson <
> jason@confluent.io>
> > > > wrote:
> > > >
> > > > > Hey Jiangjie,
> > > > >
> > > > > That's a great point. In the worst case (the mirror maker case I
> > > guess),
> > > > > the join group response can be massive. This would be especially
> > deadly
> > > > > when there is a lot of churn in the group (e.g. in a rolling
> > upgrade).
> > > > The
> > > > > current protocol is not great for this case either, but it's
> > > > significantly
> > > > > better. Here are a couple ways to deal with the size:
> > > > >
> > > > > 1. First, we could have the coordinator compress the responses.
> This
> > > > would
> > > > > probably be pretty effective if applied across the metadata from
> all
> > > > > members.
> > > > >
> > > > > 2. I think the regex case is the main problem. Is that right? We
> > could
> > > > > extend the metadata to allow the consumer to embed its regex
> > > subscription
> > > > > in the metadata directly (note this might be a good idea regardless
> > of
> > > > the
> > > > > rest of this proposal). To support regex on the consumer, we must
> > fetch
> > > > > metadata for all topics. Rather than having all regex subscribers
> > embed
> > > > all
> > > > > of this metadata in their join group requests, they could instead
> > > embed a
> > > > > hash of it. Then after the join group responses are received, they
> > just
> > > > > need to check that the hashes are the same. If there is a mismatch
> > > (which
> > > > > should only occur when topics are created, deleted, or resized),
> then
> > > the
> > > > > group members must refetch the metadata and rejoin the group. This
> is
> > > > also
> > > > > how the current protocol behaves when there is a change in the
> topic
> > > > > metadata affecting the group--someone (either the coordinator or
> the
> > > > > consumer) detects the change and forces the group to rebalance.
> > > > >
> > > > > What do you think?
> > > > >
> > > > > (Also I think adding groupId/generationId to fetch and produce
> > requests
> > > > > seems like an interesting line of thought.)
> > > > >
> > > > > -Jason
> > > > >
> > > > >
> > > > >
> > > > > On Wed, Aug 12, 2015 at 10:57 AM, Jiangjie Qin
> > > <jqin@linkedin.com.invalid
> > > > >
> > > > > wrote:
> > > > >
> > > > >> Hey Ewen,
> > > > >>
> > > > >> Onur and I discussed this a little bit more. And we are still
> > worrying
> > > > >> about passing all the metadata of all consumers around.
> > > > >>
> > > > >> Let's say I have a cluster has 10,000 topics, the average topic
> name
> > > > >> length
> > > > >> is 10 bytes. In this case, the opaque metadata will have 10 *
> > 10,000 =
> > > > >> 100KB for topic name, for each topic, there is a 4-byte integer of
> > > > number
> > > > >> of partitions, that's another 40KB. So one global topic metadata
> > will
> > > > have
> > > > >> 140KB data. If I have 100 consumers who are using wildcard to
> > consume
> > > > from
> > > > >> all the topics. That means the protocol metadata end up in the
> > > > >> JoinGroupResponse will be 140KB * 100 = 14MB. And the
> > > JoinGroupResponse
> > > > >> will need to be sent to 100 different consumers, that means 14MB *
> > > 100 =
> > > > >> 1.4GB need to be sent by the consumer coordinator for one
> rebalance.
> > > How
> > > > >> would that work?
> > > > >>
> > > > >> Also, having two consumers (old owner and new owner) consuming
> from
> > > the
> > > > >> same partition might also be a problem. e.g. people are updating
> > > > database.
> > > > >> One thing might worth doing is to add GroupId and Generation ID to
> > > > >> ProducerRequest and FetchRequest as well. This will also help with
> > the
> > > > >> single producer use case. However, this is probably orthogonal to
> > this
> > > > >> thread given the current new consumer also has this problem and I
> > > > believe
> > > > >> we need to fix it.
> > > > >>
> > > > >> Thanks,
> > > > >>
> > > > >> Jiangjie (Becket) Qin
> > > > >>
> > > > >> On Tue, Aug 11, 2015 at 11:43 PM, Ewen Cheslack-Postava <
> > > > >> ewen@confluent.io>
> > > > >> wrote:
> > > > >>
> > > > >> > On Tue, Aug 11, 2015 at 11:29 PM, Jiangjie Qin
> > > > >> <jq...@linkedin.com.invalid>
> > > > >> > wrote:
> > > > >> >
> > > > >> > > Ewen,
> > > > >> > >
> > > > >> > > Thanks for the explanation.
> > > > >> > >
> > > > >> > > For (1), I am more concerned about the failure case instead of
> > > > normal
> > > > >> > case.
> > > > >> > > What if a consumer somehow was kick out of a group but is
> still
> > > > >> consuming
> > > > >> > > and committing offsets? Does that mean the new owner and old
> > owner
> > > > >> might
> > > > >> > > potentially consuming from and committing offsets for the same
> > > > >> partition?
> > > > >> > > In the old consumer, this won't happen because the new
> consumer
> > > will
> > > > >> not
> > > > >> > be
> > > > >> > > able to start consumption unless the previous owner has
> released
> > > its
> > > > >> > > ownership. Basically, without the ownership guarantee, I don't
> > see
> > > > how
> > > > >> > the
> > > > >> > > communication among consumers themselves alone can solve the
> > > problem
> > > > >> > here.
> > > > >> > >
> > > > >> >
> > > > >> > The generation ID check still applies to offset commits. If one
> of
> > > the
> > > > >> > consumers is kicked out and misbehaving, it can obviously still
> > > fetch
> > > > >> and
> > > > >> > process messages, but offset commits will not work since it will
> > not
> > > > >> have
> > > > >> > the current generation ID.
> > > > >> >
> > > > >> >
> > > > >> > >
> > > > >> > > For (2) and (3), now I understand how metadata are used. But I
> > > still
> > > > >> > don't
> > > > >> > > see why should we let the consumers to pass the topic
> > information
> > > > >> across
> > > > >> > > instead of letting coordinator give the information. The
> single
> > > > >> producer
> > > > >> > > use case does not solve the ownership problem in abnormal case
> > > > either,
> > > > >> > > which seems to be a little bit vulnerable.
> > > > >> > >
> > > > >> >
> > > > >> > One of the goals here was to generalize group membership so we
> > can,
> > > > for
> > > > >> > example, use it for balancing Copycat tasks across workers.
> > There's
> > > no
> > > > >> > topic subscription info in that case. The metadata for copycat
> > > workers
> > > > >> > would instead need to somehow indicate the current set of tasks
> > that
> > > > >> need
> > > > >> > to be assigned to workers. By making the metadata completely
> > opaque
> > > to
> > > > >> the
> > > > >> > protocol, it becomes more generally useful since it focuses
> > squarely
> > > > on
> > > > >> the
> > > > >> > group membership problem, allowing for that additional bit of
> > > metadata
> > > > >> so
> > > > >> > you don't just get a list of members, but also get a little bit
> of
> > > > info
> > > > >> > about each of them.
> > > > >> >
> > > > >> > A different option that we explored is to use a sort of mixed
> > model
> > > --
> > > > >> > still bake all the topic subscriptions directly into the
> protocol
> > > but
> > > > >> also
> > > > >> > include metadata. That would allow us to maintain the existing
> > > > >> > coordinator-driven approach to handling the metadata and change
> > > events
> > > > >> like
> > > > >> > the ones Onur pointed out. Then something like the Copycat
> workers
> > > > would
> > > > >> > just not fill in any topic subscriptions and it would be handled
> > as
> > > a
> > > > >> > degenerate case. Based on the way I explained that we can handle
> > > those
> > > > >> > types of events, I personally feel its cleaner and a nicer
> > > > >> generalization
> > > > >> > to not include the subscriptions in the join group protocol,
> > making
> > > it
> > > > >> part
> > > > >> > of the metadata instead.
> > > > >> >
> > > > >> > For the single producer case, are you saying it doesn't solve
> > > > ownership
> > > > >> in
> > > > >> > the abnormal case because a producer that doesn't know it has
> been
> > > > >> kicked
> > > > >> > out of the group yet can still produce data even though it
> > shouldn't
> > > > be
> > > > >> > able to anymore? I definitely agree that that is a risk -- this
> > > > >> provides a
> > > > >> > way to get closer to a true single-writer, but there are
> > definitely
> > > > >> still
> > > > >> > failure modes that this does not address.
> > > > >> >
> > > > >> > -Ewen
> > > > >> >
> > > > >> >
> > > > >> > >
> > > > >> > > Thanks,
> > > > >> > >
> > > > >> > > Jiangjie (Becket) Qin
> > > > >> > >
> > > > >> > >
> > > > >> > > On Tue, Aug 11, 2015 at 11:06 PM, Ewen Cheslack-Postava <
> > > > >> > ewen@confluent.io
> > > > >> > > >
> > > > >> > > wrote:
> > > > >> > >
> > > > >> > > > On Tue, Aug 11, 2015 at 10:15 PM, Jiangjie Qin
> > > > >> > <jqin@linkedin.com.invalid
> > > > >> > > >
> > > > >> > > > wrote:
> > > > >> > > >
> > > > >> > > > > Hi Jason,
> > > > >> > > > >
> > > > >> > > > > Thanks for writing this up. It would be useful to
> generalize
> > > the
> > > > >> > group
> > > > >> > > > > concept. I have a few questions below.
> > > > >> > > > >
> > > > >> > > > > 1. In old consumer actually the partition assignment are
> > done
> > > by
> > > > >> > > > consumers
> > > > >> > > > > themselves. We used zookeeper to guarantee that a
> partition
> > > will
> > > > >> only
> > > > >> > > be
> > > > >> > > > > consumed by one consumer thread who successfully claimed
> its
> > > > >> > ownership.
> > > > >> > > > > Does the new protocol plan to provide the same guarantee?
> > > > >> > > > >
> > > > >> > > >
> > > > >> > > > Once you have all the metadata from all the consumers,
> > > assignment
> > > > >> > should
> > > > >> > > > just be a simple function mapping that Map<ConsumerId,
> > Metadata>
> > > > to
> > > > >> > > > Map<ConsumerId, List<TopicPartition>>. If everyone is
> > consistent
> > > > in
> > > > >> > > > computing that, you don't need ZK involved at all.
> > > > >> > > >
> > > > >> > > > In practice, this shouldn't be that hard to ensure for most
> > > > >> assignment
> > > > >> > > > strategies just by having decent unit testing on them. You
> > just
> > > > >> have to
> > > > >> > > do
> > > > >> > > > things like ensure your assignment strategy sorts lists
> into a
> > > > >> > consistent
> > > > >> > > > order.
> > > > >> > > >
> > > > >> > > > You do give up the ability to use some techniques (e.g. any
> > > > >> randomized
> > > > >> > > > algorithm if you can't distribute the seed w/ the metadata)
> > and
> > > > it's
> > > > >> > true
> > > > >> > > > that nothing validates the assignment, but if that
> assignment
> > > > >> algorithm
> > > > >> > > > step is kept simple, small, and well tested, the risk is
> very
> > > > >> minimal.
> > > > >> > > >
> > > > >> > > >
> > > > >> > > > >
> > > > >> > > > > 2. It looks that both JoinGroupRequest and
> JoinGroupResponse
> > > has
> > > > >> the
> > > > >> > > > > ProtocolMetadata.AssignmentStrategyMetadata, what would be
> > the
> > > > >> > metadata
> > > > >> > > > be
> > > > >> > > > > sent and returned by coordinator? How will the coordinator
> > > > handle
> > > > >> the
> > > > >> > > > > metadata?
> > > > >> > > > >
> > > > >> > > >
> > > > >> > > > The coordinator is basically just blindly broadcasting all
> of
> > it
> > > > to
> > > > >> > group
> > > > >> > > > members so they have a consistent view.
> > > > >> > > >
> > > > >> > > > So from the coordinators perspective, it sees something
> like:
> > > > >> > > >
> > > > >> > > > Consumer 1 -> JoinGroupRequest with GroupProtocols = [
> > > "consumer"
> > > > >> > > > <Consumer1 opaque byte[]>]
> > > > >> > > > Consumer 2 -> JoinGroupRequest with GroupProtocols = [
> > > "consumer"
> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > >> > > >
> > > > >> > > > Then, in the responses would look like:
> > > > >> > > >
> > > > >> > > > Consumer 1 <- JoinGroupResponse with GroupProtocol =
> > "consumer"
> > > > and
> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque byte[]>,
> > Consumer
> > > 2
> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > >> > > > Consumer 2 <- JoinGroupResponse with GroupProtocol =
> > "consumer"
> > > > and
> > > > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque byte[]>,
> > Consumer
> > > 2
> > > > >> > > > <Consumer2 opaque byte[]>]
> > > > >> > > >
> > > > >> > > > So all the responses include all the metadata for every
> member
> > > in
> > > > >> the
> > > > >> > > > group, and everyone can use that to consistently decide on
> > > > >> assignment.
> > > > >> > > The
> > > > >> > > > broker doesn't care and cannot even understand the metadata
> > > since
> > > > >> the
> > > > >> > > data
> > > > >> > > > format for it is dependent on the assignment strategy being
> > > used.
> > > > >> > > >
> > > > >> > > > As another example that is *not* a consumer, let's say you
> > just
> > > > >> want to
> > > > >> > > > have a single writer in the group which everyone will
> forward
> > > > >> requests
> > > > >> > > to.
> > > > >> > > > To accomplish this, you could use a very dumb assignment
> > > strategy:
> > > > >> > there
> > > > >> > > is
> > > > >> > > > no metadata (empty byte[]) and all we care about is who is
> the
> > > > first
> > > > >> > > member
> > > > >> > > > in the group (e.g. when IDs are sorted lexicographically).
> > That
> > > > >> member
> > > > >> > is
> > > > >> > > > selected as the writer. In that case, we actually just care
> > > about
> > > > >> the
> > > > >> > > > membership list, there's no additional info about each
> member
> > > that
> > > > >> is
> > > > >> > > > required to determine who is the writer.
> > > > >> > > >
> > > > >> > > >
> > > > >> > > > > 3. Do you mean that the number of partitions in
> > > > JoinGroupResponse
> > > > >> > will
> > > > >> > > be
> > > > >> > > > > the max partition number of a topic among all the reported
> > > > >> partition
> > > > >> > > > number
> > > > >> > > > > by consumers? Is there any reason not just let Coordinator
> > to
> > > > >> return
> > > > >> > > the
> > > > >> > > > > number of partitions of a topic in its metadata cache?
> > > > >> > > > >
> > > > >> > > >
> > > > >> > > > Nothing from the embedded protocol is touched by the broker.
> > The
> > > > >> broker
> > > > >> > > > just collects opaque bytes of metadata, does the selection
> of
> > > the
> > > > >> > > strategy
> > > > >> > > > if multiple are supported by some consumers, and then
> returns
> > > that
> > > > >> > opaque
> > > > >> > > > metadata for all the members back to every member. In that
> way
> > > > they
> > > > >> all
> > > > >> > > > have a consistent view of the group. For regular consumers,
> > that
> > > > >> view
> > > > >> > of
> > > > >> > > > the group includes information about how many partitions
> each
> > > > >> consumer
> > > > >> > > > currently thinks the topics it is subscribed to has. These
> > could
> > > > be
> > > > >> > > > inconsistent due to out of date metadata and it would be up
> to
> > > the
> > > > >> > > > assignment strategy on the *client* to resolve that. As you
> > > point
> > > > >> out,
> > > > >> > in
> > > > >> > > > that case they could just take the max value that any
> consumer
> > > > >> reported
> > > > >> > > > seeing and use that. The consumers that notice that their
> > > metadata
> > > > >> had
> > > > >> > a
> > > > >> > > > smaller # of partitions should also trigger a metadata
> update
> > > when
> > > > >> they
> > > > >> > > see
> > > > >> > > > someone else observing a larger # of partitions.
> > > > >> > > >
> > > > >> > > >
> > > > >> > > > >
> > > > >> > > > > Thanks,
> > > > >> > > > >
> > > > >> > > > > Jiangjie (Becket) Qin
> > > > >> > > > >
> > > > >> > > > >
> > > > >> > > > >
> > > > >> > > > >
> > > > >> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <
> > > > >> jason@confluent.io
> > > > >> > >
> > > > >> > > > > wrote:
> > > > >> > > > >
> > > > >> > > > > > Hi Kafka Devs,
> > > > >> > > > > >
> > > > >> > > > > > One of the nagging issues in the current design of the
> new
> > > > >> consumer
> > > > >> > > has
> > > > >> > > > > > been the need to support a variety of assignment
> > strategies.
> > > > >> We've
> > > > >> > > > > > encountered this in particular in the design of copycat
> > and
> > > > the
> > > > >> > > > > processing
> > > > >> > > > > > framework (KIP-28). From what I understand, Samza also
> > has a
> > > > >> number
> > > > >> > > of
> > > > >> > > > > use
> > > > >> > > > > > cases with custom assignment needs. The new consumer
> > > protocol
> > > > >> > > supports
> > > > >> > > > > new
> > > > >> > > > > > assignment strategies by hooking them into the broker.
> For
> > > > many
> > > > >> > > > > > environments, this is a major pain and in some cases, a
> > > > >> > non-starter.
> > > > >> > > It
> > > > >> > > > > > also challenges the validation that the coordinator can
> > > > provide.
> > > > >> > For
> > > > >> > > > > > example, some assignment strategies call for partitions
> to
> > > be
> > > > >> > > assigned
> > > > >> > > > > > multiple times, which means that the coordinator can
> only
> > > > check
> > > > >> > that
> > > > >> > > > > > partitions have been assigned at least once.
> > > > >> > > > > >
> > > > >> > > > > > To solve these issues, we'd like to propose moving
> > > assignment
> > > > to
> > > > >> > the
> > > > >> > > > > > client. I've written a wiki which outlines some protocol
> > > > >> changes to
> > > > >> > > > > achieve
> > > > >> > > > > > this:
> > > > >> > > > > >
> > > > >> > > > > >
> > > > >> > > > >
> > > > >> > > >
> > > > >> > >
> > > > >> >
> > > > >>
> > > >
> > >
> >
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> > > > >> > > > > > .
> > > > >> > > > > > To summarize briefly, instead of the coordinator
> assigning
> > > the
> > > > >> > > > partitions
> > > > >> > > > > > itself, all subscriptions are forwarded to each member
> of
> > > the
> > > > >> group
> > > > >> > > > which
> > > > >> > > > > > then decides independently which partitions it should
> > > consume.
> > > > >> The
> > > > >> > > > > protocol
> > > > >> > > > > > provides a mechanism for the coordinator to validate
> that
> > > all
> > > > >> > > consumers
> > > > >> > > > > use
> > > > >> > > > > > the same assignment strategy, but it does not ensure
> that
> > > the
> > > > >> > > resulting
> > > > >> > > > > > assignment is "correct." This provides a powerful
> > capability
> > > > for
> > > > >> > > users
> > > > >> > > > to
> > > > >> > > > > > control the full data flow on the client side. They
> > control
> > > > how
> > > > >> > data
> > > > >> > > is
> > > > >> > > > > > written to partitions through the Partitioner interface
> > and
> > > > they
> > > > >> > > > control
> > > > >> > > > > > how data is consumed through the assignment strategy,
> all
> > > > >> without
> > > > >> > > > > touching
> > > > >> > > > > > the server.
> > > > >> > > > > >
> > > > >> > > > > > Of course nothing comes for free. In particular, this
> > change
> > > > >> > removes
> > > > >> > > > the
> > > > >> > > > > > ability of the coordinator to validate that commits are
> > made
> > > > by
> > > > >> > > > consumers
> > > > >> > > > > > who were assigned the respective partition. This might
> not
> > > be
> > > > >> too
> > > > >> > bad
> > > > >> > > > > since
> > > > >> > > > > > we retain the ability to validate the generation id, but
> > it
> > > > is a
> > > > >> > > > > potential
> > > > >> > > > > > concern. We have considered alternative protocols which
> > add
> > > a
> > > > >> > second
> > > > >> > > > > > round-trip to the protocol in order to give the
> > coordinator
> > > > the
> > > > >> > > ability
> > > > >> > > > > to
> > > > >> > > > > > confirm the assignment. As mentioned above, the
> > coordinator
> > > is
> > > > >> > > somewhat
> > > > >> > > > > > limited in what it can actually validate, but this would
> > > > return
> > > > >> its
> > > > >> > > > > ability
> > > > >> > > > > > to validate commits. The tradeoff is that it increases
> the
> > > > >> > protocol's
> > > > >> > > > > > complexity which means more ways for the protocol to
> fail
> > > and
> > > > >> > > > > consequently
> > > > >> > > > > > more edge cases in the code.
> > > > >> > > > > >
> > > > >> > > > > > It also misses an opportunity to generalize the group
> > > > membership
> > > > >> > > > protocol
> > > > >> > > > > > for additional use cases. In fact, after you've gone to
> > the
> > > > >> trouble
> > > > >> > > of
> > > > >> > > > > > moving assignment to the client, the main thing that is
> > left
> > > > in
> > > > >> > this
> > > > >> > > > > > protocol is basically a general group management
> > capability.
> > > > >> This
> > > > >> > is
> > > > >> > > > > > exactly what is needed for a few cases that are
> currently
> > > > under
> > > > >> > > > > discussion
> > > > >> > > > > > (e.g. copycat or single-writer producer). We've taken
> this
> > > > >> further
> > > > >> > > step
> > > > >> > > > > in
> > > > >> > > > > > the proposal and attempted to envision what that general
> > > > >> protocol
> > > > >> > > might
> > > > >> > > > > > look like and how it could be used both by the consumer
> > and
> > > > for
> > > > >> > some
> > > > >> > > of
> > > > >> > > > > > these other cases.
> > > > >> > > > > >
> > > > >> > > > > > Anyway, since time is running out on the new consumer,
> we
> > > have
> > > > >> > > perhaps
> > > > >> > > > > one
> > > > >> > > > > > last chance to consider a significant change in the
> > protocol
> > > > >> like
> > > > >> > > this,
> > > > >> > > > > so
> > > > >> > > > > > have a look at the wiki and share your thoughts. I've no
> > > doubt
> > > > >> that
> > > > >> > > > some
> > > > >> > > > > > ideas seem clearer in my mind than they do on paper, so
> > ask
> > > > >> > questions
> > > > >> > > > if
> > > > >> > > > > > there is any confusion.
> > > > >> > > > > >
> > > > >> > > > > > Thanks!
> > > > >> > > > > > Jason
> > > > >> > > > > >
> > > > >> > > > >
> > > > >> > > >
> > > > >> > > >
> > > > >> > > >
> > > > >> > > > --
> > > > >> > > > Thanks,
> > > > >> > > > Ewen
> > > > >> > > >
> > > > >> > >
> > > > >> >
> > > > >> >
> > > > >> >
> > > > >> > --
> > > > >> > Thanks,
> > > > >> > Ewen
> > > > >> >
> > > > >>
> > > > >
> > > > >
> > > >
> > >
> >
>



-- 
Thanks,
Neha

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Jiangjie Qin <jq...@linkedin.com.INVALID>.
Ewen and Jason,

Thanks for the reply. Sorry I missed the metadata hash. Yes, that is a
clever approach and would solve my concern about the data passing around. I
can see both pros and cons from doing this, though. The advantage is we
don't need the topic metadata in JoinGroupResponse anymore. The downside is
that now rebalance have extra dependency on the consensus of metadata of
all consumers, which is obtained separately. So it is required that each
consumer refresh their metadata before sending a JoinGroupRequest,
otherwise in some cases (e.g. wildcard consumers) will almost certainly
fail for the first rebalance attempt. Even if we do that, since the
consumers are getting metadata from different brokers, the metadata might
still be inconsistent if there is a topic or partition change because the
UpdateMetadataRequest from controller might be handled at different time.
Just want to make sure we think through the cases so the protocol does not
cause us unexpected issues.

About the number of consumers, I think with the current liveliness
definition, we can tolerate churns by bumping up the session timeout. Also
I guess we will see an increasing number of consumers for new consumer,
because every the old consumer thread will probably become a consumer.

It is a valid concern for consumers that have large subscription set. This
might not be avoided though for client side assignment approach. One
solution is having topic names associate with a topic ID. And only use
topic ID in JoinGroupRequest and JoinGroupResponse, There is a discussion
thread about this to solve the topic renaming case but this is a completely
different discussion.

Thanks,

Jiangjie (Becket) Qin



On Thu, Aug 13, 2015 at 2:14 PM, Jason Gustafson <ja...@confluent.io> wrote:

> Thanks Jiangjie, that information helps. I agree the protocol must consider
> scalability. My point was that the synchronization barrier in the current
> protocol already effectively limits the number of consumers since it
> provides no way to gracefully handle churn. It wouldn't be worth worrying
> about scaling up to 100,000 members, for example, because there's no way
> the group would be stable. So we just need to set some clear expectations
> on the size we can scale to, and that can help inform the discussion on the
> size of messages in this protocol.
>
> Ewen and I were discussing this morning along similar lines to what you're
> suggesting. However, even if the coordinator decides on the metadata for
> the group, each member still needs to communicate its subscriptions to the
> rest of the group. This is nice for the regex case since the regex is
> probably small, but if the members have a large topic list, then we have
> the same problem. One thing I was thinking about was whether we really need
> to handle different subscriptions for every member. If the coordinator
> could guarantee that all members had the same subscription, then there
> would be no need for the coordinator to return the subscriptions for each
> member. However, this would prevent graceful upgrades. We might be able to
> fix that problem by allowing the consumer to provide two subscriptions to
> allowing rolling updates, but that starts to sound pretty nasty.
>
> -Jason
>
> On Thu, Aug 13, 2015 at 1:41 PM, Jiangjie Qin <jq...@linkedin.com.invalid>
> wrote:
>
> > Jason,
> >
> > The protocol has to consider the scalability. The protocol in the wiki
> > means the JoinGroupResoponse size would be:
> > NumberOfTopics * (AvgTopicNameLength + 4) * (NumberOfConsumers)^2
> >
> > To give some real number, we have 26-node Mirror Maker cluster, each
> with 4
> > consumers. That is 104 consumers using regex ".*". And most of our
> clusters
> > have around 3000 topics, whose topic name are typically around 20
> > characters.
> >
> > I think the key issue for client side partition assignment logic is to
> make
> > sure 1) all the clients run the same algorithm. 2) all the clients make
> > decision on the same topic metadata. The second purpose can be done by
> > simply letting coordinator provide the topic metadata and all then member
> > information as source of truth. Is it necessary to pass topic metadata of
> > each consumer around? Can we keep the protocol metadata field completely
> > independent of topic metadata? I think In the JoinGroupResponse, we
> should
> > have only one copy of topic metadata provided by coordinator and is
> outside
> > of protocol metadata. If user decides to put some metadata in the
> > JoinGroupRequest and let coordinator pass around, they are responsible
> for
> > understanding the risk.
> >
> > Thanks,
> >
> > Jiangjie (Becket) Qin
> >
> >
> > On Thu, Aug 13, 2015 at 12:41 PM, Jason Gustafson <ja...@confluent.io>
> > wrote:
> >
> > > Hey Onur and Jiangjie,
> > >
> > > I've updated that wiki with a proposal to add regex subscriptions to
> the
> > > consumer metadata. Can you have a look to see if it addresses your
> > concern?
> > > In general, I think we should be a little careful when we are talking
> > about
> > > the scalability of the protocol. Regardless of whether assignment is
> done
> > > on the server or the client, the protocol assumes a relatively stable
> > > configuration. When the number of consumers increases beyond a certain
> > > limit, then membership churn becomes a major concern. Similarly there
> is
> > a
> > > notion of metadata churn when topics are added, deleted, or resized. If
> > > either membership or metadata changes, then the protocol forces all
> > > consumers to stop consumption and rejoin the group. If this happens
> often
> > > enough, then it can severely impact the ability of the consumer to make
> > > progress. The point is that the protocol may already be unsuited to
> cases
> > > where there are either a large number of consumers or topics. I wonder
> if
> > > you guys can share your thoughts about your scaling expectations?
> > >
> > > -Jason
> > >
> > >
> > >
> > >
> > > On Wed, Aug 12, 2015 at 12:28 PM, Jason Gustafson <ja...@confluent.io>
> > > wrote:
> > >
> > > > Hey Jiangjie,
> > > >
> > > > That's a great point. In the worst case (the mirror maker case I
> > guess),
> > > > the join group response can be massive. This would be especially
> deadly
> > > > when there is a lot of churn in the group (e.g. in a rolling
> upgrade).
> > > The
> > > > current protocol is not great for this case either, but it's
> > > significantly
> > > > better. Here are a couple ways to deal with the size:
> > > >
> > > > 1. First, we could have the coordinator compress the responses. This
> > > would
> > > > probably be pretty effective if applied across the metadata from all
> > > > members.
> > > >
> > > > 2. I think the regex case is the main problem. Is that right? We
> could
> > > > extend the metadata to allow the consumer to embed its regex
> > subscription
> > > > in the metadata directly (note this might be a good idea regardless
> of
> > > the
> > > > rest of this proposal). To support regex on the consumer, we must
> fetch
> > > > metadata for all topics. Rather than having all regex subscribers
> embed
> > > all
> > > > of this metadata in their join group requests, they could instead
> > embed a
> > > > hash of it. Then after the join group responses are received, they
> just
> > > > need to check that the hashes are the same. If there is a mismatch
> > (which
> > > > should only occur when topics are created, deleted, or resized), then
> > the
> > > > group members must refetch the metadata and rejoin the group. This is
> > > also
> > > > how the current protocol behaves when there is a change in the topic
> > > > metadata affecting the group--someone (either the coordinator or the
> > > > consumer) detects the change and forces the group to rebalance.
> > > >
> > > > What do you think?
> > > >
> > > > (Also I think adding groupId/generationId to fetch and produce
> requests
> > > > seems like an interesting line of thought.)
> > > >
> > > > -Jason
> > > >
> > > >
> > > >
> > > > On Wed, Aug 12, 2015 at 10:57 AM, Jiangjie Qin
> > <jqin@linkedin.com.invalid
> > > >
> > > > wrote:
> > > >
> > > >> Hey Ewen,
> > > >>
> > > >> Onur and I discussed this a little bit more. And we are still
> worrying
> > > >> about passing all the metadata of all consumers around.
> > > >>
> > > >> Let's say I have a cluster has 10,000 topics, the average topic name
> > > >> length
> > > >> is 10 bytes. In this case, the opaque metadata will have 10 *
> 10,000 =
> > > >> 100KB for topic name, for each topic, there is a 4-byte integer of
> > > number
> > > >> of partitions, that's another 40KB. So one global topic metadata
> will
> > > have
> > > >> 140KB data. If I have 100 consumers who are using wildcard to
> consume
> > > from
> > > >> all the topics. That means the protocol metadata end up in the
> > > >> JoinGroupResponse will be 140KB * 100 = 14MB. And the
> > JoinGroupResponse
> > > >> will need to be sent to 100 different consumers, that means 14MB *
> > 100 =
> > > >> 1.4GB need to be sent by the consumer coordinator for one rebalance.
> > How
> > > >> would that work?
> > > >>
> > > >> Also, having two consumers (old owner and new owner) consuming from
> > the
> > > >> same partition might also be a problem. e.g. people are updating
> > > database.
> > > >> One thing might worth doing is to add GroupId and Generation ID to
> > > >> ProducerRequest and FetchRequest as well. This will also help with
> the
> > > >> single producer use case. However, this is probably orthogonal to
> this
> > > >> thread given the current new consumer also has this problem and I
> > > believe
> > > >> we need to fix it.
> > > >>
> > > >> Thanks,
> > > >>
> > > >> Jiangjie (Becket) Qin
> > > >>
> > > >> On Tue, Aug 11, 2015 at 11:43 PM, Ewen Cheslack-Postava <
> > > >> ewen@confluent.io>
> > > >> wrote:
> > > >>
> > > >> > On Tue, Aug 11, 2015 at 11:29 PM, Jiangjie Qin
> > > >> <jq...@linkedin.com.invalid>
> > > >> > wrote:
> > > >> >
> > > >> > > Ewen,
> > > >> > >
> > > >> > > Thanks for the explanation.
> > > >> > >
> > > >> > > For (1), I am more concerned about the failure case instead of
> > > normal
> > > >> > case.
> > > >> > > What if a consumer somehow was kick out of a group but is still
> > > >> consuming
> > > >> > > and committing offsets? Does that mean the new owner and old
> owner
> > > >> might
> > > >> > > potentially consuming from and committing offsets for the same
> > > >> partition?
> > > >> > > In the old consumer, this won't happen because the new consumer
> > will
> > > >> not
> > > >> > be
> > > >> > > able to start consumption unless the previous owner has released
> > its
> > > >> > > ownership. Basically, without the ownership guarantee, I don't
> see
> > > how
> > > >> > the
> > > >> > > communication among consumers themselves alone can solve the
> > problem
> > > >> > here.
> > > >> > >
> > > >> >
> > > >> > The generation ID check still applies to offset commits. If one of
> > the
> > > >> > consumers is kicked out and misbehaving, it can obviously still
> > fetch
> > > >> and
> > > >> > process messages, but offset commits will not work since it will
> not
> > > >> have
> > > >> > the current generation ID.
> > > >> >
> > > >> >
> > > >> > >
> > > >> > > For (2) and (3), now I understand how metadata are used. But I
> > still
> > > >> > don't
> > > >> > > see why should we let the consumers to pass the topic
> information
> > > >> across
> > > >> > > instead of letting coordinator give the information. The single
> > > >> producer
> > > >> > > use case does not solve the ownership problem in abnormal case
> > > either,
> > > >> > > which seems to be a little bit vulnerable.
> > > >> > >
> > > >> >
> > > >> > One of the goals here was to generalize group membership so we
> can,
> > > for
> > > >> > example, use it for balancing Copycat tasks across workers.
> There's
> > no
> > > >> > topic subscription info in that case. The metadata for copycat
> > workers
> > > >> > would instead need to somehow indicate the current set of tasks
> that
> > > >> need
> > > >> > to be assigned to workers. By making the metadata completely
> opaque
> > to
> > > >> the
> > > >> > protocol, it becomes more generally useful since it focuses
> squarely
> > > on
> > > >> the
> > > >> > group membership problem, allowing for that additional bit of
> > metadata
> > > >> so
> > > >> > you don't just get a list of members, but also get a little bit of
> > > info
> > > >> > about each of them.
> > > >> >
> > > >> > A different option that we explored is to use a sort of mixed
> model
> > --
> > > >> > still bake all the topic subscriptions directly into the protocol
> > but
> > > >> also
> > > >> > include metadata. That would allow us to maintain the existing
> > > >> > coordinator-driven approach to handling the metadata and change
> > events
> > > >> like
> > > >> > the ones Onur pointed out. Then something like the Copycat workers
> > > would
> > > >> > just not fill in any topic subscriptions and it would be handled
> as
> > a
> > > >> > degenerate case. Based on the way I explained that we can handle
> > those
> > > >> > types of events, I personally feel its cleaner and a nicer
> > > >> generalization
> > > >> > to not include the subscriptions in the join group protocol,
> making
> > it
> > > >> part
> > > >> > of the metadata instead.
> > > >> >
> > > >> > For the single producer case, are you saying it doesn't solve
> > > ownership
> > > >> in
> > > >> > the abnormal case because a producer that doesn't know it has been
> > > >> kicked
> > > >> > out of the group yet can still produce data even though it
> shouldn't
> > > be
> > > >> > able to anymore? I definitely agree that that is a risk -- this
> > > >> provides a
> > > >> > way to get closer to a true single-writer, but there are
> definitely
> > > >> still
> > > >> > failure modes that this does not address.
> > > >> >
> > > >> > -Ewen
> > > >> >
> > > >> >
> > > >> > >
> > > >> > > Thanks,
> > > >> > >
> > > >> > > Jiangjie (Becket) Qin
> > > >> > >
> > > >> > >
> > > >> > > On Tue, Aug 11, 2015 at 11:06 PM, Ewen Cheslack-Postava <
> > > >> > ewen@confluent.io
> > > >> > > >
> > > >> > > wrote:
> > > >> > >
> > > >> > > > On Tue, Aug 11, 2015 at 10:15 PM, Jiangjie Qin
> > > >> > <jqin@linkedin.com.invalid
> > > >> > > >
> > > >> > > > wrote:
> > > >> > > >
> > > >> > > > > Hi Jason,
> > > >> > > > >
> > > >> > > > > Thanks for writing this up. It would be useful to generalize
> > the
> > > >> > group
> > > >> > > > > concept. I have a few questions below.
> > > >> > > > >
> > > >> > > > > 1. In old consumer actually the partition assignment are
> done
> > by
> > > >> > > > consumers
> > > >> > > > > themselves. We used zookeeper to guarantee that a partition
> > will
> > > >> only
> > > >> > > be
> > > >> > > > > consumed by one consumer thread who successfully claimed its
> > > >> > ownership.
> > > >> > > > > Does the new protocol plan to provide the same guarantee?
> > > >> > > > >
> > > >> > > >
> > > >> > > > Once you have all the metadata from all the consumers,
> > assignment
> > > >> > should
> > > >> > > > just be a simple function mapping that Map<ConsumerId,
> Metadata>
> > > to
> > > >> > > > Map<ConsumerId, List<TopicPartition>>. If everyone is
> consistent
> > > in
> > > >> > > > computing that, you don't need ZK involved at all.
> > > >> > > >
> > > >> > > > In practice, this shouldn't be that hard to ensure for most
> > > >> assignment
> > > >> > > > strategies just by having decent unit testing on them. You
> just
> > > >> have to
> > > >> > > do
> > > >> > > > things like ensure your assignment strategy sorts lists into a
> > > >> > consistent
> > > >> > > > order.
> > > >> > > >
> > > >> > > > You do give up the ability to use some techniques (e.g. any
> > > >> randomized
> > > >> > > > algorithm if you can't distribute the seed w/ the metadata)
> and
> > > it's
> > > >> > true
> > > >> > > > that nothing validates the assignment, but if that assignment
> > > >> algorithm
> > > >> > > > step is kept simple, small, and well tested, the risk is very
> > > >> minimal.
> > > >> > > >
> > > >> > > >
> > > >> > > > >
> > > >> > > > > 2. It looks that both JoinGroupRequest and JoinGroupResponse
> > has
> > > >> the
> > > >> > > > > ProtocolMetadata.AssignmentStrategyMetadata, what would be
> the
> > > >> > metadata
> > > >> > > > be
> > > >> > > > > sent and returned by coordinator? How will the coordinator
> > > handle
> > > >> the
> > > >> > > > > metadata?
> > > >> > > > >
> > > >> > > >
> > > >> > > > The coordinator is basically just blindly broadcasting all of
> it
> > > to
> > > >> > group
> > > >> > > > members so they have a consistent view.
> > > >> > > >
> > > >> > > > So from the coordinators perspective, it sees something like:
> > > >> > > >
> > > >> > > > Consumer 1 -> JoinGroupRequest with GroupProtocols = [
> > "consumer"
> > > >> > > > <Consumer1 opaque byte[]>]
> > > >> > > > Consumer 2 -> JoinGroupRequest with GroupProtocols = [
> > "consumer"
> > > >> > > > <Consumer2 opaque byte[]>]
> > > >> > > >
> > > >> > > > Then, in the responses would look like:
> > > >> > > >
> > > >> > > > Consumer 1 <- JoinGroupResponse with GroupProtocol =
> "consumer"
> > > and
> > > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque byte[]>,
> Consumer
> > 2
> > > >> > > > <Consumer2 opaque byte[]>]
> > > >> > > > Consumer 2 <- JoinGroupResponse with GroupProtocol =
> "consumer"
> > > and
> > > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque byte[]>,
> Consumer
> > 2
> > > >> > > > <Consumer2 opaque byte[]>]
> > > >> > > >
> > > >> > > > So all the responses include all the metadata for every member
> > in
> > > >> the
> > > >> > > > group, and everyone can use that to consistently decide on
> > > >> assignment.
> > > >> > > The
> > > >> > > > broker doesn't care and cannot even understand the metadata
> > since
> > > >> the
> > > >> > > data
> > > >> > > > format for it is dependent on the assignment strategy being
> > used.
> > > >> > > >
> > > >> > > > As another example that is *not* a consumer, let's say you
> just
> > > >> want to
> > > >> > > > have a single writer in the group which everyone will forward
> > > >> requests
> > > >> > > to.
> > > >> > > > To accomplish this, you could use a very dumb assignment
> > strategy:
> > > >> > there
> > > >> > > is
> > > >> > > > no metadata (empty byte[]) and all we care about is who is the
> > > first
> > > >> > > member
> > > >> > > > in the group (e.g. when IDs are sorted lexicographically).
> That
> > > >> member
> > > >> > is
> > > >> > > > selected as the writer. In that case, we actually just care
> > about
> > > >> the
> > > >> > > > membership list, there's no additional info about each member
> > that
> > > >> is
> > > >> > > > required to determine who is the writer.
> > > >> > > >
> > > >> > > >
> > > >> > > > > 3. Do you mean that the number of partitions in
> > > JoinGroupResponse
> > > >> > will
> > > >> > > be
> > > >> > > > > the max partition number of a topic among all the reported
> > > >> partition
> > > >> > > > number
> > > >> > > > > by consumers? Is there any reason not just let Coordinator
> to
> > > >> return
> > > >> > > the
> > > >> > > > > number of partitions of a topic in its metadata cache?
> > > >> > > > >
> > > >> > > >
> > > >> > > > Nothing from the embedded protocol is touched by the broker.
> The
> > > >> broker
> > > >> > > > just collects opaque bytes of metadata, does the selection of
> > the
> > > >> > > strategy
> > > >> > > > if multiple are supported by some consumers, and then returns
> > that
> > > >> > opaque
> > > >> > > > metadata for all the members back to every member. In that way
> > > they
> > > >> all
> > > >> > > > have a consistent view of the group. For regular consumers,
> that
> > > >> view
> > > >> > of
> > > >> > > > the group includes information about how many partitions each
> > > >> consumer
> > > >> > > > currently thinks the topics it is subscribed to has. These
> could
> > > be
> > > >> > > > inconsistent due to out of date metadata and it would be up to
> > the
> > > >> > > > assignment strategy on the *client* to resolve that. As you
> > point
> > > >> out,
> > > >> > in
> > > >> > > > that case they could just take the max value that any consumer
> > > >> reported
> > > >> > > > seeing and use that. The consumers that notice that their
> > metadata
> > > >> had
> > > >> > a
> > > >> > > > smaller # of partitions should also trigger a metadata update
> > when
> > > >> they
> > > >> > > see
> > > >> > > > someone else observing a larger # of partitions.
> > > >> > > >
> > > >> > > >
> > > >> > > > >
> > > >> > > > > Thanks,
> > > >> > > > >
> > > >> > > > > Jiangjie (Becket) Qin
> > > >> > > > >
> > > >> > > > >
> > > >> > > > >
> > > >> > > > >
> > > >> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <
> > > >> jason@confluent.io
> > > >> > >
> > > >> > > > > wrote:
> > > >> > > > >
> > > >> > > > > > Hi Kafka Devs,
> > > >> > > > > >
> > > >> > > > > > One of the nagging issues in the current design of the new
> > > >> consumer
> > > >> > > has
> > > >> > > > > > been the need to support a variety of assignment
> strategies.
> > > >> We've
> > > >> > > > > > encountered this in particular in the design of copycat
> and
> > > the
> > > >> > > > > processing
> > > >> > > > > > framework (KIP-28). From what I understand, Samza also
> has a
> > > >> number
> > > >> > > of
> > > >> > > > > use
> > > >> > > > > > cases with custom assignment needs. The new consumer
> > protocol
> > > >> > > supports
> > > >> > > > > new
> > > >> > > > > > assignment strategies by hooking them into the broker. For
> > > many
> > > >> > > > > > environments, this is a major pain and in some cases, a
> > > >> > non-starter.
> > > >> > > It
> > > >> > > > > > also challenges the validation that the coordinator can
> > > provide.
> > > >> > For
> > > >> > > > > > example, some assignment strategies call for partitions to
> > be
> > > >> > > assigned
> > > >> > > > > > multiple times, which means that the coordinator can only
> > > check
> > > >> > that
> > > >> > > > > > partitions have been assigned at least once.
> > > >> > > > > >
> > > >> > > > > > To solve these issues, we'd like to propose moving
> > assignment
> > > to
> > > >> > the
> > > >> > > > > > client. I've written a wiki which outlines some protocol
> > > >> changes to
> > > >> > > > > achieve
> > > >> > > > > > this:
> > > >> > > > > >
> > > >> > > > > >
> > > >> > > > >
> > > >> > > >
> > > >> > >
> > > >> >
> > > >>
> > >
> >
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> > > >> > > > > > .
> > > >> > > > > > To summarize briefly, instead of the coordinator assigning
> > the
> > > >> > > > partitions
> > > >> > > > > > itself, all subscriptions are forwarded to each member of
> > the
> > > >> group
> > > >> > > > which
> > > >> > > > > > then decides independently which partitions it should
> > consume.
> > > >> The
> > > >> > > > > protocol
> > > >> > > > > > provides a mechanism for the coordinator to validate that
> > all
> > > >> > > consumers
> > > >> > > > > use
> > > >> > > > > > the same assignment strategy, but it does not ensure that
> > the
> > > >> > > resulting
> > > >> > > > > > assignment is "correct." This provides a powerful
> capability
> > > for
> > > >> > > users
> > > >> > > > to
> > > >> > > > > > control the full data flow on the client side. They
> control
> > > how
> > > >> > data
> > > >> > > is
> > > >> > > > > > written to partitions through the Partitioner interface
> and
> > > they
> > > >> > > > control
> > > >> > > > > > how data is consumed through the assignment strategy, all
> > > >> without
> > > >> > > > > touching
> > > >> > > > > > the server.
> > > >> > > > > >
> > > >> > > > > > Of course nothing comes for free. In particular, this
> change
> > > >> > removes
> > > >> > > > the
> > > >> > > > > > ability of the coordinator to validate that commits are
> made
> > > by
> > > >> > > > consumers
> > > >> > > > > > who were assigned the respective partition. This might not
> > be
> > > >> too
> > > >> > bad
> > > >> > > > > since
> > > >> > > > > > we retain the ability to validate the generation id, but
> it
> > > is a
> > > >> > > > > potential
> > > >> > > > > > concern. We have considered alternative protocols which
> add
> > a
> > > >> > second
> > > >> > > > > > round-trip to the protocol in order to give the
> coordinator
> > > the
> > > >> > > ability
> > > >> > > > > to
> > > >> > > > > > confirm the assignment. As mentioned above, the
> coordinator
> > is
> > > >> > > somewhat
> > > >> > > > > > limited in what it can actually validate, but this would
> > > return
> > > >> its
> > > >> > > > > ability
> > > >> > > > > > to validate commits. The tradeoff is that it increases the
> > > >> > protocol's
> > > >> > > > > > complexity which means more ways for the protocol to fail
> > and
> > > >> > > > > consequently
> > > >> > > > > > more edge cases in the code.
> > > >> > > > > >
> > > >> > > > > > It also misses an opportunity to generalize the group
> > > membership
> > > >> > > > protocol
> > > >> > > > > > for additional use cases. In fact, after you've gone to
> the
> > > >> trouble
> > > >> > > of
> > > >> > > > > > moving assignment to the client, the main thing that is
> left
> > > in
> > > >> > this
> > > >> > > > > > protocol is basically a general group management
> capability.
> > > >> This
> > > >> > is
> > > >> > > > > > exactly what is needed for a few cases that are currently
> > > under
> > > >> > > > > discussion
> > > >> > > > > > (e.g. copycat or single-writer producer). We've taken this
> > > >> further
> > > >> > > step
> > > >> > > > > in
> > > >> > > > > > the proposal and attempted to envision what that general
> > > >> protocol
> > > >> > > might
> > > >> > > > > > look like and how it could be used both by the consumer
> and
> > > for
> > > >> > some
> > > >> > > of
> > > >> > > > > > these other cases.
> > > >> > > > > >
> > > >> > > > > > Anyway, since time is running out on the new consumer, we
> > have
> > > >> > > perhaps
> > > >> > > > > one
> > > >> > > > > > last chance to consider a significant change in the
> protocol
> > > >> like
> > > >> > > this,
> > > >> > > > > so
> > > >> > > > > > have a look at the wiki and share your thoughts. I've no
> > doubt
> > > >> that
> > > >> > > > some
> > > >> > > > > > ideas seem clearer in my mind than they do on paper, so
> ask
> > > >> > questions
> > > >> > > > if
> > > >> > > > > > there is any confusion.
> > > >> > > > > >
> > > >> > > > > > Thanks!
> > > >> > > > > > Jason
> > > >> > > > > >
> > > >> > > > >
> > > >> > > >
> > > >> > > >
> > > >> > > >
> > > >> > > > --
> > > >> > > > Thanks,
> > > >> > > > Ewen
> > > >> > > >
> > > >> > >
> > > >> >
> > > >> >
> > > >> >
> > > >> > --
> > > >> > Thanks,
> > > >> > Ewen
> > > >> >
> > > >>
> > > >
> > > >
> > >
> >
>

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Jason Gustafson <ja...@confluent.io>.
Thanks Jiangjie, that information helps. I agree the protocol must consider
scalability. My point was that the synchronization barrier in the current
protocol already effectively limits the number of consumers since it
provides no way to gracefully handle churn. It wouldn't be worth worrying
about scaling up to 100,000 members, for example, because there's no way
the group would be stable. So we just need to set some clear expectations
on the size we can scale to, and that can help inform the discussion on the
size of messages in this protocol.

Ewen and I were discussing this morning along similar lines to what you're
suggesting. However, even if the coordinator decides on the metadata for
the group, each member still needs to communicate its subscriptions to the
rest of the group. This is nice for the regex case since the regex is
probably small, but if the members have a large topic list, then we have
the same problem. One thing I was thinking about was whether we really need
to handle different subscriptions for every member. If the coordinator
could guarantee that all members had the same subscription, then there
would be no need for the coordinator to return the subscriptions for each
member. However, this would prevent graceful upgrades. We might be able to
fix that problem by allowing the consumer to provide two subscriptions to
allowing rolling updates, but that starts to sound pretty nasty.

-Jason

On Thu, Aug 13, 2015 at 1:41 PM, Jiangjie Qin <jq...@linkedin.com.invalid>
wrote:

> Jason,
>
> The protocol has to consider the scalability. The protocol in the wiki
> means the JoinGroupResoponse size would be:
> NumberOfTopics * (AvgTopicNameLength + 4) * (NumberOfConsumers)^2
>
> To give some real number, we have 26-node Mirror Maker cluster, each with 4
> consumers. That is 104 consumers using regex ".*". And most of our clusters
> have around 3000 topics, whose topic name are typically around 20
> characters.
>
> I think the key issue for client side partition assignment logic is to make
> sure 1) all the clients run the same algorithm. 2) all the clients make
> decision on the same topic metadata. The second purpose can be done by
> simply letting coordinator provide the topic metadata and all then member
> information as source of truth. Is it necessary to pass topic metadata of
> each consumer around? Can we keep the protocol metadata field completely
> independent of topic metadata? I think In the JoinGroupResponse, we should
> have only one copy of topic metadata provided by coordinator and is outside
> of protocol metadata. If user decides to put some metadata in the
> JoinGroupRequest and let coordinator pass around, they are responsible for
> understanding the risk.
>
> Thanks,
>
> Jiangjie (Becket) Qin
>
>
> On Thu, Aug 13, 2015 at 12:41 PM, Jason Gustafson <ja...@confluent.io>
> wrote:
>
> > Hey Onur and Jiangjie,
> >
> > I've updated that wiki with a proposal to add regex subscriptions to the
> > consumer metadata. Can you have a look to see if it addresses your
> concern?
> > In general, I think we should be a little careful when we are talking
> about
> > the scalability of the protocol. Regardless of whether assignment is done
> > on the server or the client, the protocol assumes a relatively stable
> > configuration. When the number of consumers increases beyond a certain
> > limit, then membership churn becomes a major concern. Similarly there is
> a
> > notion of metadata churn when topics are added, deleted, or resized. If
> > either membership or metadata changes, then the protocol forces all
> > consumers to stop consumption and rejoin the group. If this happens often
> > enough, then it can severely impact the ability of the consumer to make
> > progress. The point is that the protocol may already be unsuited to cases
> > where there are either a large number of consumers or topics. I wonder if
> > you guys can share your thoughts about your scaling expectations?
> >
> > -Jason
> >
> >
> >
> >
> > On Wed, Aug 12, 2015 at 12:28 PM, Jason Gustafson <ja...@confluent.io>
> > wrote:
> >
> > > Hey Jiangjie,
> > >
> > > That's a great point. In the worst case (the mirror maker case I
> guess),
> > > the join group response can be massive. This would be especially deadly
> > > when there is a lot of churn in the group (e.g. in a rolling upgrade).
> > The
> > > current protocol is not great for this case either, but it's
> > significantly
> > > better. Here are a couple ways to deal with the size:
> > >
> > > 1. First, we could have the coordinator compress the responses. This
> > would
> > > probably be pretty effective if applied across the metadata from all
> > > members.
> > >
> > > 2. I think the regex case is the main problem. Is that right? We could
> > > extend the metadata to allow the consumer to embed its regex
> subscription
> > > in the metadata directly (note this might be a good idea regardless of
> > the
> > > rest of this proposal). To support regex on the consumer, we must fetch
> > > metadata for all topics. Rather than having all regex subscribers embed
> > all
> > > of this metadata in their join group requests, they could instead
> embed a
> > > hash of it. Then after the join group responses are received, they just
> > > need to check that the hashes are the same. If there is a mismatch
> (which
> > > should only occur when topics are created, deleted, or resized), then
> the
> > > group members must refetch the metadata and rejoin the group. This is
> > also
> > > how the current protocol behaves when there is a change in the topic
> > > metadata affecting the group--someone (either the coordinator or the
> > > consumer) detects the change and forces the group to rebalance.
> > >
> > > What do you think?
> > >
> > > (Also I think adding groupId/generationId to fetch and produce requests
> > > seems like an interesting line of thought.)
> > >
> > > -Jason
> > >
> > >
> > >
> > > On Wed, Aug 12, 2015 at 10:57 AM, Jiangjie Qin
> <jqin@linkedin.com.invalid
> > >
> > > wrote:
> > >
> > >> Hey Ewen,
> > >>
> > >> Onur and I discussed this a little bit more. And we are still worrying
> > >> about passing all the metadata of all consumers around.
> > >>
> > >> Let's say I have a cluster has 10,000 topics, the average topic name
> > >> length
> > >> is 10 bytes. In this case, the opaque metadata will have 10 * 10,000 =
> > >> 100KB for topic name, for each topic, there is a 4-byte integer of
> > number
> > >> of partitions, that's another 40KB. So one global topic metadata will
> > have
> > >> 140KB data. If I have 100 consumers who are using wildcard to consume
> > from
> > >> all the topics. That means the protocol metadata end up in the
> > >> JoinGroupResponse will be 140KB * 100 = 14MB. And the
> JoinGroupResponse
> > >> will need to be sent to 100 different consumers, that means 14MB *
> 100 =
> > >> 1.4GB need to be sent by the consumer coordinator for one rebalance.
> How
> > >> would that work?
> > >>
> > >> Also, having two consumers (old owner and new owner) consuming from
> the
> > >> same partition might also be a problem. e.g. people are updating
> > database.
> > >> One thing might worth doing is to add GroupId and Generation ID to
> > >> ProducerRequest and FetchRequest as well. This will also help with the
> > >> single producer use case. However, this is probably orthogonal to this
> > >> thread given the current new consumer also has this problem and I
> > believe
> > >> we need to fix it.
> > >>
> > >> Thanks,
> > >>
> > >> Jiangjie (Becket) Qin
> > >>
> > >> On Tue, Aug 11, 2015 at 11:43 PM, Ewen Cheslack-Postava <
> > >> ewen@confluent.io>
> > >> wrote:
> > >>
> > >> > On Tue, Aug 11, 2015 at 11:29 PM, Jiangjie Qin
> > >> <jq...@linkedin.com.invalid>
> > >> > wrote:
> > >> >
> > >> > > Ewen,
> > >> > >
> > >> > > Thanks for the explanation.
> > >> > >
> > >> > > For (1), I am more concerned about the failure case instead of
> > normal
> > >> > case.
> > >> > > What if a consumer somehow was kick out of a group but is still
> > >> consuming
> > >> > > and committing offsets? Does that mean the new owner and old owner
> > >> might
> > >> > > potentially consuming from and committing offsets for the same
> > >> partition?
> > >> > > In the old consumer, this won't happen because the new consumer
> will
> > >> not
> > >> > be
> > >> > > able to start consumption unless the previous owner has released
> its
> > >> > > ownership. Basically, without the ownership guarantee, I don't see
> > how
> > >> > the
> > >> > > communication among consumers themselves alone can solve the
> problem
> > >> > here.
> > >> > >
> > >> >
> > >> > The generation ID check still applies to offset commits. If one of
> the
> > >> > consumers is kicked out and misbehaving, it can obviously still
> fetch
> > >> and
> > >> > process messages, but offset commits will not work since it will not
> > >> have
> > >> > the current generation ID.
> > >> >
> > >> >
> > >> > >
> > >> > > For (2) and (3), now I understand how metadata are used. But I
> still
> > >> > don't
> > >> > > see why should we let the consumers to pass the topic information
> > >> across
> > >> > > instead of letting coordinator give the information. The single
> > >> producer
> > >> > > use case does not solve the ownership problem in abnormal case
> > either,
> > >> > > which seems to be a little bit vulnerable.
> > >> > >
> > >> >
> > >> > One of the goals here was to generalize group membership so we can,
> > for
> > >> > example, use it for balancing Copycat tasks across workers. There's
> no
> > >> > topic subscription info in that case. The metadata for copycat
> workers
> > >> > would instead need to somehow indicate the current set of tasks that
> > >> need
> > >> > to be assigned to workers. By making the metadata completely opaque
> to
> > >> the
> > >> > protocol, it becomes more generally useful since it focuses squarely
> > on
> > >> the
> > >> > group membership problem, allowing for that additional bit of
> metadata
> > >> so
> > >> > you don't just get a list of members, but also get a little bit of
> > info
> > >> > about each of them.
> > >> >
> > >> > A different option that we explored is to use a sort of mixed model
> --
> > >> > still bake all the topic subscriptions directly into the protocol
> but
> > >> also
> > >> > include metadata. That would allow us to maintain the existing
> > >> > coordinator-driven approach to handling the metadata and change
> events
> > >> like
> > >> > the ones Onur pointed out. Then something like the Copycat workers
> > would
> > >> > just not fill in any topic subscriptions and it would be handled as
> a
> > >> > degenerate case. Based on the way I explained that we can handle
> those
> > >> > types of events, I personally feel its cleaner and a nicer
> > >> generalization
> > >> > to not include the subscriptions in the join group protocol, making
> it
> > >> part
> > >> > of the metadata instead.
> > >> >
> > >> > For the single producer case, are you saying it doesn't solve
> > ownership
> > >> in
> > >> > the abnormal case because a producer that doesn't know it has been
> > >> kicked
> > >> > out of the group yet can still produce data even though it shouldn't
> > be
> > >> > able to anymore? I definitely agree that that is a risk -- this
> > >> provides a
> > >> > way to get closer to a true single-writer, but there are definitely
> > >> still
> > >> > failure modes that this does not address.
> > >> >
> > >> > -Ewen
> > >> >
> > >> >
> > >> > >
> > >> > > Thanks,
> > >> > >
> > >> > > Jiangjie (Becket) Qin
> > >> > >
> > >> > >
> > >> > > On Tue, Aug 11, 2015 at 11:06 PM, Ewen Cheslack-Postava <
> > >> > ewen@confluent.io
> > >> > > >
> > >> > > wrote:
> > >> > >
> > >> > > > On Tue, Aug 11, 2015 at 10:15 PM, Jiangjie Qin
> > >> > <jqin@linkedin.com.invalid
> > >> > > >
> > >> > > > wrote:
> > >> > > >
> > >> > > > > Hi Jason,
> > >> > > > >
> > >> > > > > Thanks for writing this up. It would be useful to generalize
> the
> > >> > group
> > >> > > > > concept. I have a few questions below.
> > >> > > > >
> > >> > > > > 1. In old consumer actually the partition assignment are done
> by
> > >> > > > consumers
> > >> > > > > themselves. We used zookeeper to guarantee that a partition
> will
> > >> only
> > >> > > be
> > >> > > > > consumed by one consumer thread who successfully claimed its
> > >> > ownership.
> > >> > > > > Does the new protocol plan to provide the same guarantee?
> > >> > > > >
> > >> > > >
> > >> > > > Once you have all the metadata from all the consumers,
> assignment
> > >> > should
> > >> > > > just be a simple function mapping that Map<ConsumerId, Metadata>
> > to
> > >> > > > Map<ConsumerId, List<TopicPartition>>. If everyone is consistent
> > in
> > >> > > > computing that, you don't need ZK involved at all.
> > >> > > >
> > >> > > > In practice, this shouldn't be that hard to ensure for most
> > >> assignment
> > >> > > > strategies just by having decent unit testing on them. You just
> > >> have to
> > >> > > do
> > >> > > > things like ensure your assignment strategy sorts lists into a
> > >> > consistent
> > >> > > > order.
> > >> > > >
> > >> > > > You do give up the ability to use some techniques (e.g. any
> > >> randomized
> > >> > > > algorithm if you can't distribute the seed w/ the metadata) and
> > it's
> > >> > true
> > >> > > > that nothing validates the assignment, but if that assignment
> > >> algorithm
> > >> > > > step is kept simple, small, and well tested, the risk is very
> > >> minimal.
> > >> > > >
> > >> > > >
> > >> > > > >
> > >> > > > > 2. It looks that both JoinGroupRequest and JoinGroupResponse
> has
> > >> the
> > >> > > > > ProtocolMetadata.AssignmentStrategyMetadata, what would be the
> > >> > metadata
> > >> > > > be
> > >> > > > > sent and returned by coordinator? How will the coordinator
> > handle
> > >> the
> > >> > > > > metadata?
> > >> > > > >
> > >> > > >
> > >> > > > The coordinator is basically just blindly broadcasting all of it
> > to
> > >> > group
> > >> > > > members so they have a consistent view.
> > >> > > >
> > >> > > > So from the coordinators perspective, it sees something like:
> > >> > > >
> > >> > > > Consumer 1 -> JoinGroupRequest with GroupProtocols = [
> "consumer"
> > >> > > > <Consumer1 opaque byte[]>]
> > >> > > > Consumer 2 -> JoinGroupRequest with GroupProtocols = [
> "consumer"
> > >> > > > <Consumer2 opaque byte[]>]
> > >> > > >
> > >> > > > Then, in the responses would look like:
> > >> > > >
> > >> > > > Consumer 1 <- JoinGroupResponse with GroupProtocol = "consumer"
> > and
> > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque byte[]>, Consumer
> 2
> > >> > > > <Consumer2 opaque byte[]>]
> > >> > > > Consumer 2 <- JoinGroupResponse with GroupProtocol = "consumer"
> > and
> > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque byte[]>, Consumer
> 2
> > >> > > > <Consumer2 opaque byte[]>]
> > >> > > >
> > >> > > > So all the responses include all the metadata for every member
> in
> > >> the
> > >> > > > group, and everyone can use that to consistently decide on
> > >> assignment.
> > >> > > The
> > >> > > > broker doesn't care and cannot even understand the metadata
> since
> > >> the
> > >> > > data
> > >> > > > format for it is dependent on the assignment strategy being
> used.
> > >> > > >
> > >> > > > As another example that is *not* a consumer, let's say you just
> > >> want to
> > >> > > > have a single writer in the group which everyone will forward
> > >> requests
> > >> > > to.
> > >> > > > To accomplish this, you could use a very dumb assignment
> strategy:
> > >> > there
> > >> > > is
> > >> > > > no metadata (empty byte[]) and all we care about is who is the
> > first
> > >> > > member
> > >> > > > in the group (e.g. when IDs are sorted lexicographically). That
> > >> member
> > >> > is
> > >> > > > selected as the writer. In that case, we actually just care
> about
> > >> the
> > >> > > > membership list, there's no additional info about each member
> that
> > >> is
> > >> > > > required to determine who is the writer.
> > >> > > >
> > >> > > >
> > >> > > > > 3. Do you mean that the number of partitions in
> > JoinGroupResponse
> > >> > will
> > >> > > be
> > >> > > > > the max partition number of a topic among all the reported
> > >> partition
> > >> > > > number
> > >> > > > > by consumers? Is there any reason not just let Coordinator to
> > >> return
> > >> > > the
> > >> > > > > number of partitions of a topic in its metadata cache?
> > >> > > > >
> > >> > > >
> > >> > > > Nothing from the embedded protocol is touched by the broker. The
> > >> broker
> > >> > > > just collects opaque bytes of metadata, does the selection of
> the
> > >> > > strategy
> > >> > > > if multiple are supported by some consumers, and then returns
> that
> > >> > opaque
> > >> > > > metadata for all the members back to every member. In that way
> > they
> > >> all
> > >> > > > have a consistent view of the group. For regular consumers, that
> > >> view
> > >> > of
> > >> > > > the group includes information about how many partitions each
> > >> consumer
> > >> > > > currently thinks the topics it is subscribed to has. These could
> > be
> > >> > > > inconsistent due to out of date metadata and it would be up to
> the
> > >> > > > assignment strategy on the *client* to resolve that. As you
> point
> > >> out,
> > >> > in
> > >> > > > that case they could just take the max value that any consumer
> > >> reported
> > >> > > > seeing and use that. The consumers that notice that their
> metadata
> > >> had
> > >> > a
> > >> > > > smaller # of partitions should also trigger a metadata update
> when
> > >> they
> > >> > > see
> > >> > > > someone else observing a larger # of partitions.
> > >> > > >
> > >> > > >
> > >> > > > >
> > >> > > > > Thanks,
> > >> > > > >
> > >> > > > > Jiangjie (Becket) Qin
> > >> > > > >
> > >> > > > >
> > >> > > > >
> > >> > > > >
> > >> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <
> > >> jason@confluent.io
> > >> > >
> > >> > > > > wrote:
> > >> > > > >
> > >> > > > > > Hi Kafka Devs,
> > >> > > > > >
> > >> > > > > > One of the nagging issues in the current design of the new
> > >> consumer
> > >> > > has
> > >> > > > > > been the need to support a variety of assignment strategies.
> > >> We've
> > >> > > > > > encountered this in particular in the design of copycat and
> > the
> > >> > > > > processing
> > >> > > > > > framework (KIP-28). From what I understand, Samza also has a
> > >> number
> > >> > > of
> > >> > > > > use
> > >> > > > > > cases with custom assignment needs. The new consumer
> protocol
> > >> > > supports
> > >> > > > > new
> > >> > > > > > assignment strategies by hooking them into the broker. For
> > many
> > >> > > > > > environments, this is a major pain and in some cases, a
> > >> > non-starter.
> > >> > > It
> > >> > > > > > also challenges the validation that the coordinator can
> > provide.
> > >> > For
> > >> > > > > > example, some assignment strategies call for partitions to
> be
> > >> > > assigned
> > >> > > > > > multiple times, which means that the coordinator can only
> > check
> > >> > that
> > >> > > > > > partitions have been assigned at least once.
> > >> > > > > >
> > >> > > > > > To solve these issues, we'd like to propose moving
> assignment
> > to
> > >> > the
> > >> > > > > > client. I've written a wiki which outlines some protocol
> > >> changes to
> > >> > > > > achieve
> > >> > > > > > this:
> > >> > > > > >
> > >> > > > > >
> > >> > > > >
> > >> > > >
> > >> > >
> > >> >
> > >>
> >
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> > >> > > > > > .
> > >> > > > > > To summarize briefly, instead of the coordinator assigning
> the
> > >> > > > partitions
> > >> > > > > > itself, all subscriptions are forwarded to each member of
> the
> > >> group
> > >> > > > which
> > >> > > > > > then decides independently which partitions it should
> consume.
> > >> The
> > >> > > > > protocol
> > >> > > > > > provides a mechanism for the coordinator to validate that
> all
> > >> > > consumers
> > >> > > > > use
> > >> > > > > > the same assignment strategy, but it does not ensure that
> the
> > >> > > resulting
> > >> > > > > > assignment is "correct." This provides a powerful capability
> > for
> > >> > > users
> > >> > > > to
> > >> > > > > > control the full data flow on the client side. They control
> > how
> > >> > data
> > >> > > is
> > >> > > > > > written to partitions through the Partitioner interface and
> > they
> > >> > > > control
> > >> > > > > > how data is consumed through the assignment strategy, all
> > >> without
> > >> > > > > touching
> > >> > > > > > the server.
> > >> > > > > >
> > >> > > > > > Of course nothing comes for free. In particular, this change
> > >> > removes
> > >> > > > the
> > >> > > > > > ability of the coordinator to validate that commits are made
> > by
> > >> > > > consumers
> > >> > > > > > who were assigned the respective partition. This might not
> be
> > >> too
> > >> > bad
> > >> > > > > since
> > >> > > > > > we retain the ability to validate the generation id, but it
> > is a
> > >> > > > > potential
> > >> > > > > > concern. We have considered alternative protocols which add
> a
> > >> > second
> > >> > > > > > round-trip to the protocol in order to give the coordinator
> > the
> > >> > > ability
> > >> > > > > to
> > >> > > > > > confirm the assignment. As mentioned above, the coordinator
> is
> > >> > > somewhat
> > >> > > > > > limited in what it can actually validate, but this would
> > return
> > >> its
> > >> > > > > ability
> > >> > > > > > to validate commits. The tradeoff is that it increases the
> > >> > protocol's
> > >> > > > > > complexity which means more ways for the protocol to fail
> and
> > >> > > > > consequently
> > >> > > > > > more edge cases in the code.
> > >> > > > > >
> > >> > > > > > It also misses an opportunity to generalize the group
> > membership
> > >> > > > protocol
> > >> > > > > > for additional use cases. In fact, after you've gone to the
> > >> trouble
> > >> > > of
> > >> > > > > > moving assignment to the client, the main thing that is left
> > in
> > >> > this
> > >> > > > > > protocol is basically a general group management capability.
> > >> This
> > >> > is
> > >> > > > > > exactly what is needed for a few cases that are currently
> > under
> > >> > > > > discussion
> > >> > > > > > (e.g. copycat or single-writer producer). We've taken this
> > >> further
> > >> > > step
> > >> > > > > in
> > >> > > > > > the proposal and attempted to envision what that general
> > >> protocol
> > >> > > might
> > >> > > > > > look like and how it could be used both by the consumer and
> > for
> > >> > some
> > >> > > of
> > >> > > > > > these other cases.
> > >> > > > > >
> > >> > > > > > Anyway, since time is running out on the new consumer, we
> have
> > >> > > perhaps
> > >> > > > > one
> > >> > > > > > last chance to consider a significant change in the protocol
> > >> like
> > >> > > this,
> > >> > > > > so
> > >> > > > > > have a look at the wiki and share your thoughts. I've no
> doubt
> > >> that
> > >> > > > some
> > >> > > > > > ideas seem clearer in my mind than they do on paper, so ask
> > >> > questions
> > >> > > > if
> > >> > > > > > there is any confusion.
> > >> > > > > >
> > >> > > > > > Thanks!
> > >> > > > > > Jason
> > >> > > > > >
> > >> > > > >
> > >> > > >
> > >> > > >
> > >> > > >
> > >> > > > --
> > >> > > > Thanks,
> > >> > > > Ewen
> > >> > > >
> > >> > >
> > >> >
> > >> >
> > >> >
> > >> > --
> > >> > Thanks,
> > >> > Ewen
> > >> >
> > >>
> > >
> > >
> >
>

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Ewen Cheslack-Postava <ew...@confluent.io>.
Becket,

Did you see the updates to the "ConsumerEmbeddedProtocol" section,
specifically on how regex subscriptions like you're describing are handled?
The updated version removes almost all the metadata in the regex case by
taking advantage of exactly the point you made in (2). The clients don't
actually need to transmit all the metadata, they just need to make sure
they are all making decisions using the same metadata. They can verify this
with a hash of the metadata they are using instead of sending the full
metadata.

-Ewen

On Thu, Aug 13, 2015 at 1:41 PM, Jiangjie Qin <jq...@linkedin.com.invalid>
wrote:

> Jason,
>
> The protocol has to consider the scalability. The protocol in the wiki
> means the JoinGroupResoponse size would be:
> NumberOfTopics * (AvgTopicNameLength + 4) * (NumberOfConsumers)^2
>
> To give some real number, we have 26-node Mirror Maker cluster, each with 4
> consumers. That is 104 consumers using regex ".*". And most of our clusters
> have around 3000 topics, whose topic name are typically around 20
> characters.
>
> I think the key issue for client side partition assignment logic is to make
> sure 1) all the clients run the same algorithm. 2) all the clients make
> decision on the same topic metadata. The second purpose can be done by
> simply letting coordinator provide the topic metadata and all then member
> information as source of truth. Is it necessary to pass topic metadata of
> each consumer around? Can we keep the protocol metadata field completely
> independent of topic metadata? I think In the JoinGroupResponse, we should
> have only one copy of topic metadata provided by coordinator and is outside
> of protocol metadata. If user decides to put some metadata in the
> JoinGroupRequest and let coordinator pass around, they are responsible for
> understanding the risk.
>
> Thanks,
>
> Jiangjie (Becket) Qin
>
>
> On Thu, Aug 13, 2015 at 12:41 PM, Jason Gustafson <ja...@confluent.io>
> wrote:
>
> > Hey Onur and Jiangjie,
> >
> > I've updated that wiki with a proposal to add regex subscriptions to the
> > consumer metadata. Can you have a look to see if it addresses your
> concern?
> > In general, I think we should be a little careful when we are talking
> about
> > the scalability of the protocol. Regardless of whether assignment is done
> > on the server or the client, the protocol assumes a relatively stable
> > configuration. When the number of consumers increases beyond a certain
> > limit, then membership churn becomes a major concern. Similarly there is
> a
> > notion of metadata churn when topics are added, deleted, or resized. If
> > either membership or metadata changes, then the protocol forces all
> > consumers to stop consumption and rejoin the group. If this happens often
> > enough, then it can severely impact the ability of the consumer to make
> > progress. The point is that the protocol may already be unsuited to cases
> > where there are either a large number of consumers or topics. I wonder if
> > you guys can share your thoughts about your scaling expectations?
> >
> > -Jason
> >
> >
> >
> >
> > On Wed, Aug 12, 2015 at 12:28 PM, Jason Gustafson <ja...@confluent.io>
> > wrote:
> >
> > > Hey Jiangjie,
> > >
> > > That's a great point. In the worst case (the mirror maker case I
> guess),
> > > the join group response can be massive. This would be especially deadly
> > > when there is a lot of churn in the group (e.g. in a rolling upgrade).
> > The
> > > current protocol is not great for this case either, but it's
> > significantly
> > > better. Here are a couple ways to deal with the size:
> > >
> > > 1. First, we could have the coordinator compress the responses. This
> > would
> > > probably be pretty effective if applied across the metadata from all
> > > members.
> > >
> > > 2. I think the regex case is the main problem. Is that right? We could
> > > extend the metadata to allow the consumer to embed its regex
> subscription
> > > in the metadata directly (note this might be a good idea regardless of
> > the
> > > rest of this proposal). To support regex on the consumer, we must fetch
> > > metadata for all topics. Rather than having all regex subscribers embed
> > all
> > > of this metadata in their join group requests, they could instead
> embed a
> > > hash of it. Then after the join group responses are received, they just
> > > need to check that the hashes are the same. If there is a mismatch
> (which
> > > should only occur when topics are created, deleted, or resized), then
> the
> > > group members must refetch the metadata and rejoin the group. This is
> > also
> > > how the current protocol behaves when there is a change in the topic
> > > metadata affecting the group--someone (either the coordinator or the
> > > consumer) detects the change and forces the group to rebalance.
> > >
> > > What do you think?
> > >
> > > (Also I think adding groupId/generationId to fetch and produce requests
> > > seems like an interesting line of thought.)
> > >
> > > -Jason
> > >
> > >
> > >
> > > On Wed, Aug 12, 2015 at 10:57 AM, Jiangjie Qin
> <jqin@linkedin.com.invalid
> > >
> > > wrote:
> > >
> > >> Hey Ewen,
> > >>
> > >> Onur and I discussed this a little bit more. And we are still worrying
> > >> about passing all the metadata of all consumers around.
> > >>
> > >> Let's say I have a cluster has 10,000 topics, the average topic name
> > >> length
> > >> is 10 bytes. In this case, the opaque metadata will have 10 * 10,000 =
> > >> 100KB for topic name, for each topic, there is a 4-byte integer of
> > number
> > >> of partitions, that's another 40KB. So one global topic metadata will
> > have
> > >> 140KB data. If I have 100 consumers who are using wildcard to consume
> > from
> > >> all the topics. That means the protocol metadata end up in the
> > >> JoinGroupResponse will be 140KB * 100 = 14MB. And the
> JoinGroupResponse
> > >> will need to be sent to 100 different consumers, that means 14MB *
> 100 =
> > >> 1.4GB need to be sent by the consumer coordinator for one rebalance.
> How
> > >> would that work?
> > >>
> > >> Also, having two consumers (old owner and new owner) consuming from
> the
> > >> same partition might also be a problem. e.g. people are updating
> > database.
> > >> One thing might worth doing is to add GroupId and Generation ID to
> > >> ProducerRequest and FetchRequest as well. This will also help with the
> > >> single producer use case. However, this is probably orthogonal to this
> > >> thread given the current new consumer also has this problem and I
> > believe
> > >> we need to fix it.
> > >>
> > >> Thanks,
> > >>
> > >> Jiangjie (Becket) Qin
> > >>
> > >> On Tue, Aug 11, 2015 at 11:43 PM, Ewen Cheslack-Postava <
> > >> ewen@confluent.io>
> > >> wrote:
> > >>
> > >> > On Tue, Aug 11, 2015 at 11:29 PM, Jiangjie Qin
> > >> <jq...@linkedin.com.invalid>
> > >> > wrote:
> > >> >
> > >> > > Ewen,
> > >> > >
> > >> > > Thanks for the explanation.
> > >> > >
> > >> > > For (1), I am more concerned about the failure case instead of
> > normal
> > >> > case.
> > >> > > What if a consumer somehow was kick out of a group but is still
> > >> consuming
> > >> > > and committing offsets? Does that mean the new owner and old owner
> > >> might
> > >> > > potentially consuming from and committing offsets for the same
> > >> partition?
> > >> > > In the old consumer, this won't happen because the new consumer
> will
> > >> not
> > >> > be
> > >> > > able to start consumption unless the previous owner has released
> its
> > >> > > ownership. Basically, without the ownership guarantee, I don't see
> > how
> > >> > the
> > >> > > communication among consumers themselves alone can solve the
> problem
> > >> > here.
> > >> > >
> > >> >
> > >> > The generation ID check still applies to offset commits. If one of
> the
> > >> > consumers is kicked out and misbehaving, it can obviously still
> fetch
> > >> and
> > >> > process messages, but offset commits will not work since it will not
> > >> have
> > >> > the current generation ID.
> > >> >
> > >> >
> > >> > >
> > >> > > For (2) and (3), now I understand how metadata are used. But I
> still
> > >> > don't
> > >> > > see why should we let the consumers to pass the topic information
> > >> across
> > >> > > instead of letting coordinator give the information. The single
> > >> producer
> > >> > > use case does not solve the ownership problem in abnormal case
> > either,
> > >> > > which seems to be a little bit vulnerable.
> > >> > >
> > >> >
> > >> > One of the goals here was to generalize group membership so we can,
> > for
> > >> > example, use it for balancing Copycat tasks across workers. There's
> no
> > >> > topic subscription info in that case. The metadata for copycat
> workers
> > >> > would instead need to somehow indicate the current set of tasks that
> > >> need
> > >> > to be assigned to workers. By making the metadata completely opaque
> to
> > >> the
> > >> > protocol, it becomes more generally useful since it focuses squarely
> > on
> > >> the
> > >> > group membership problem, allowing for that additional bit of
> metadata
> > >> so
> > >> > you don't just get a list of members, but also get a little bit of
> > info
> > >> > about each of them.
> > >> >
> > >> > A different option that we explored is to use a sort of mixed model
> --
> > >> > still bake all the topic subscriptions directly into the protocol
> but
> > >> also
> > >> > include metadata. That would allow us to maintain the existing
> > >> > coordinator-driven approach to handling the metadata and change
> events
> > >> like
> > >> > the ones Onur pointed out. Then something like the Copycat workers
> > would
> > >> > just not fill in any topic subscriptions and it would be handled as
> a
> > >> > degenerate case. Based on the way I explained that we can handle
> those
> > >> > types of events, I personally feel its cleaner and a nicer
> > >> generalization
> > >> > to not include the subscriptions in the join group protocol, making
> it
> > >> part
> > >> > of the metadata instead.
> > >> >
> > >> > For the single producer case, are you saying it doesn't solve
> > ownership
> > >> in
> > >> > the abnormal case because a producer that doesn't know it has been
> > >> kicked
> > >> > out of the group yet can still produce data even though it shouldn't
> > be
> > >> > able to anymore? I definitely agree that that is a risk -- this
> > >> provides a
> > >> > way to get closer to a true single-writer, but there are definitely
> > >> still
> > >> > failure modes that this does not address.
> > >> >
> > >> > -Ewen
> > >> >
> > >> >
> > >> > >
> > >> > > Thanks,
> > >> > >
> > >> > > Jiangjie (Becket) Qin
> > >> > >
> > >> > >
> > >> > > On Tue, Aug 11, 2015 at 11:06 PM, Ewen Cheslack-Postava <
> > >> > ewen@confluent.io
> > >> > > >
> > >> > > wrote:
> > >> > >
> > >> > > > On Tue, Aug 11, 2015 at 10:15 PM, Jiangjie Qin
> > >> > <jqin@linkedin.com.invalid
> > >> > > >
> > >> > > > wrote:
> > >> > > >
> > >> > > > > Hi Jason,
> > >> > > > >
> > >> > > > > Thanks for writing this up. It would be useful to generalize
> the
> > >> > group
> > >> > > > > concept. I have a few questions below.
> > >> > > > >
> > >> > > > > 1. In old consumer actually the partition assignment are done
> by
> > >> > > > consumers
> > >> > > > > themselves. We used zookeeper to guarantee that a partition
> will
> > >> only
> > >> > > be
> > >> > > > > consumed by one consumer thread who successfully claimed its
> > >> > ownership.
> > >> > > > > Does the new protocol plan to provide the same guarantee?
> > >> > > > >
> > >> > > >
> > >> > > > Once you have all the metadata from all the consumers,
> assignment
> > >> > should
> > >> > > > just be a simple function mapping that Map<ConsumerId, Metadata>
> > to
> > >> > > > Map<ConsumerId, List<TopicPartition>>. If everyone is consistent
> > in
> > >> > > > computing that, you don't need ZK involved at all.
> > >> > > >
> > >> > > > In practice, this shouldn't be that hard to ensure for most
> > >> assignment
> > >> > > > strategies just by having decent unit testing on them. You just
> > >> have to
> > >> > > do
> > >> > > > things like ensure your assignment strategy sorts lists into a
> > >> > consistent
> > >> > > > order.
> > >> > > >
> > >> > > > You do give up the ability to use some techniques (e.g. any
> > >> randomized
> > >> > > > algorithm if you can't distribute the seed w/ the metadata) and
> > it's
> > >> > true
> > >> > > > that nothing validates the assignment, but if that assignment
> > >> algorithm
> > >> > > > step is kept simple, small, and well tested, the risk is very
> > >> minimal.
> > >> > > >
> > >> > > >
> > >> > > > >
> > >> > > > > 2. It looks that both JoinGroupRequest and JoinGroupResponse
> has
> > >> the
> > >> > > > > ProtocolMetadata.AssignmentStrategyMetadata, what would be the
> > >> > metadata
> > >> > > > be
> > >> > > > > sent and returned by coordinator? How will the coordinator
> > handle
> > >> the
> > >> > > > > metadata?
> > >> > > > >
> > >> > > >
> > >> > > > The coordinator is basically just blindly broadcasting all of it
> > to
> > >> > group
> > >> > > > members so they have a consistent view.
> > >> > > >
> > >> > > > So from the coordinators perspective, it sees something like:
> > >> > > >
> > >> > > > Consumer 1 -> JoinGroupRequest with GroupProtocols = [
> "consumer"
> > >> > > > <Consumer1 opaque byte[]>]
> > >> > > > Consumer 2 -> JoinGroupRequest with GroupProtocols = [
> "consumer"
> > >> > > > <Consumer2 opaque byte[]>]
> > >> > > >
> > >> > > > Then, in the responses would look like:
> > >> > > >
> > >> > > > Consumer 1 <- JoinGroupResponse with GroupProtocol = "consumer"
> > and
> > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque byte[]>, Consumer
> 2
> > >> > > > <Consumer2 opaque byte[]>]
> > >> > > > Consumer 2 <- JoinGroupResponse with GroupProtocol = "consumer"
> > and
> > >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque byte[]>, Consumer
> 2
> > >> > > > <Consumer2 opaque byte[]>]
> > >> > > >
> > >> > > > So all the responses include all the metadata for every member
> in
> > >> the
> > >> > > > group, and everyone can use that to consistently decide on
> > >> assignment.
> > >> > > The
> > >> > > > broker doesn't care and cannot even understand the metadata
> since
> > >> the
> > >> > > data
> > >> > > > format for it is dependent on the assignment strategy being
> used.
> > >> > > >
> > >> > > > As another example that is *not* a consumer, let's say you just
> > >> want to
> > >> > > > have a single writer in the group which everyone will forward
> > >> requests
> > >> > > to.
> > >> > > > To accomplish this, you could use a very dumb assignment
> strategy:
> > >> > there
> > >> > > is
> > >> > > > no metadata (empty byte[]) and all we care about is who is the
> > first
> > >> > > member
> > >> > > > in the group (e.g. when IDs are sorted lexicographically). That
> > >> member
> > >> > is
> > >> > > > selected as the writer. In that case, we actually just care
> about
> > >> the
> > >> > > > membership list, there's no additional info about each member
> that
> > >> is
> > >> > > > required to determine who is the writer.
> > >> > > >
> > >> > > >
> > >> > > > > 3. Do you mean that the number of partitions in
> > JoinGroupResponse
> > >> > will
> > >> > > be
> > >> > > > > the max partition number of a topic among all the reported
> > >> partition
> > >> > > > number
> > >> > > > > by consumers? Is there any reason not just let Coordinator to
> > >> return
> > >> > > the
> > >> > > > > number of partitions of a topic in its metadata cache?
> > >> > > > >
> > >> > > >
> > >> > > > Nothing from the embedded protocol is touched by the broker. The
> > >> broker
> > >> > > > just collects opaque bytes of metadata, does the selection of
> the
> > >> > > strategy
> > >> > > > if multiple are supported by some consumers, and then returns
> that
> > >> > opaque
> > >> > > > metadata for all the members back to every member. In that way
> > they
> > >> all
> > >> > > > have a consistent view of the group. For regular consumers, that
> > >> view
> > >> > of
> > >> > > > the group includes information about how many partitions each
> > >> consumer
> > >> > > > currently thinks the topics it is subscribed to has. These could
> > be
> > >> > > > inconsistent due to out of date metadata and it would be up to
> the
> > >> > > > assignment strategy on the *client* to resolve that. As you
> point
> > >> out,
> > >> > in
> > >> > > > that case they could just take the max value that any consumer
> > >> reported
> > >> > > > seeing and use that. The consumers that notice that their
> metadata
> > >> had
> > >> > a
> > >> > > > smaller # of partitions should also trigger a metadata update
> when
> > >> they
> > >> > > see
> > >> > > > someone else observing a larger # of partitions.
> > >> > > >
> > >> > > >
> > >> > > > >
> > >> > > > > Thanks,
> > >> > > > >
> > >> > > > > Jiangjie (Becket) Qin
> > >> > > > >
> > >> > > > >
> > >> > > > >
> > >> > > > >
> > >> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <
> > >> jason@confluent.io
> > >> > >
> > >> > > > > wrote:
> > >> > > > >
> > >> > > > > > Hi Kafka Devs,
> > >> > > > > >
> > >> > > > > > One of the nagging issues in the current design of the new
> > >> consumer
> > >> > > has
> > >> > > > > > been the need to support a variety of assignment strategies.
> > >> We've
> > >> > > > > > encountered this in particular in the design of copycat and
> > the
> > >> > > > > processing
> > >> > > > > > framework (KIP-28). From what I understand, Samza also has a
> > >> number
> > >> > > of
> > >> > > > > use
> > >> > > > > > cases with custom assignment needs. The new consumer
> protocol
> > >> > > supports
> > >> > > > > new
> > >> > > > > > assignment strategies by hooking them into the broker. For
> > many
> > >> > > > > > environments, this is a major pain and in some cases, a
> > >> > non-starter.
> > >> > > It
> > >> > > > > > also challenges the validation that the coordinator can
> > provide.
> > >> > For
> > >> > > > > > example, some assignment strategies call for partitions to
> be
> > >> > > assigned
> > >> > > > > > multiple times, which means that the coordinator can only
> > check
> > >> > that
> > >> > > > > > partitions have been assigned at least once.
> > >> > > > > >
> > >> > > > > > To solve these issues, we'd like to propose moving
> assignment
> > to
> > >> > the
> > >> > > > > > client. I've written a wiki which outlines some protocol
> > >> changes to
> > >> > > > > achieve
> > >> > > > > > this:
> > >> > > > > >
> > >> > > > > >
> > >> > > > >
> > >> > > >
> > >> > >
> > >> >
> > >>
> >
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> > >> > > > > > .
> > >> > > > > > To summarize briefly, instead of the coordinator assigning
> the
> > >> > > > partitions
> > >> > > > > > itself, all subscriptions are forwarded to each member of
> the
> > >> group
> > >> > > > which
> > >> > > > > > then decides independently which partitions it should
> consume.
> > >> The
> > >> > > > > protocol
> > >> > > > > > provides a mechanism for the coordinator to validate that
> all
> > >> > > consumers
> > >> > > > > use
> > >> > > > > > the same assignment strategy, but it does not ensure that
> the
> > >> > > resulting
> > >> > > > > > assignment is "correct." This provides a powerful capability
> > for
> > >> > > users
> > >> > > > to
> > >> > > > > > control the full data flow on the client side. They control
> > how
> > >> > data
> > >> > > is
> > >> > > > > > written to partitions through the Partitioner interface and
> > they
> > >> > > > control
> > >> > > > > > how data is consumed through the assignment strategy, all
> > >> without
> > >> > > > > touching
> > >> > > > > > the server.
> > >> > > > > >
> > >> > > > > > Of course nothing comes for free. In particular, this change
> > >> > removes
> > >> > > > the
> > >> > > > > > ability of the coordinator to validate that commits are made
> > by
> > >> > > > consumers
> > >> > > > > > who were assigned the respective partition. This might not
> be
> > >> too
> > >> > bad
> > >> > > > > since
> > >> > > > > > we retain the ability to validate the generation id, but it
> > is a
> > >> > > > > potential
> > >> > > > > > concern. We have considered alternative protocols which add
> a
> > >> > second
> > >> > > > > > round-trip to the protocol in order to give the coordinator
> > the
> > >> > > ability
> > >> > > > > to
> > >> > > > > > confirm the assignment. As mentioned above, the coordinator
> is
> > >> > > somewhat
> > >> > > > > > limited in what it can actually validate, but this would
> > return
> > >> its
> > >> > > > > ability
> > >> > > > > > to validate commits. The tradeoff is that it increases the
> > >> > protocol's
> > >> > > > > > complexity which means more ways for the protocol to fail
> and
> > >> > > > > consequently
> > >> > > > > > more edge cases in the code.
> > >> > > > > >
> > >> > > > > > It also misses an opportunity to generalize the group
> > membership
> > >> > > > protocol
> > >> > > > > > for additional use cases. In fact, after you've gone to the
> > >> trouble
> > >> > > of
> > >> > > > > > moving assignment to the client, the main thing that is left
> > in
> > >> > this
> > >> > > > > > protocol is basically a general group management capability.
> > >> This
> > >> > is
> > >> > > > > > exactly what is needed for a few cases that are currently
> > under
> > >> > > > > discussion
> > >> > > > > > (e.g. copycat or single-writer producer). We've taken this
> > >> further
> > >> > > step
> > >> > > > > in
> > >> > > > > > the proposal and attempted to envision what that general
> > >> protocol
> > >> > > might
> > >> > > > > > look like and how it could be used both by the consumer and
> > for
> > >> > some
> > >> > > of
> > >> > > > > > these other cases.
> > >> > > > > >
> > >> > > > > > Anyway, since time is running out on the new consumer, we
> have
> > >> > > perhaps
> > >> > > > > one
> > >> > > > > > last chance to consider a significant change in the protocol
> > >> like
> > >> > > this,
> > >> > > > > so
> > >> > > > > > have a look at the wiki and share your thoughts. I've no
> doubt
> > >> that
> > >> > > > some
> > >> > > > > > ideas seem clearer in my mind than they do on paper, so ask
> > >> > questions
> > >> > > > if
> > >> > > > > > there is any confusion.
> > >> > > > > >
> > >> > > > > > Thanks!
> > >> > > > > > Jason
> > >> > > > > >
> > >> > > > >
> > >> > > >
> > >> > > >
> > >> > > >
> > >> > > > --
> > >> > > > Thanks,
> > >> > > > Ewen
> > >> > > >
> > >> > >
> > >> >
> > >> >
> > >> >
> > >> > --
> > >> > Thanks,
> > >> > Ewen
> > >> >
> > >>
> > >
> > >
> >
>



-- 
Thanks,
Ewen

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Jiangjie Qin <jq...@linkedin.com.INVALID>.
Jason,

The protocol has to consider the scalability. The protocol in the wiki
means the JoinGroupResoponse size would be:
NumberOfTopics * (AvgTopicNameLength + 4) * (NumberOfConsumers)^2

To give some real number, we have 26-node Mirror Maker cluster, each with 4
consumers. That is 104 consumers using regex ".*". And most of our clusters
have around 3000 topics, whose topic name are typically around 20
characters.

I think the key issue for client side partition assignment logic is to make
sure 1) all the clients run the same algorithm. 2) all the clients make
decision on the same topic metadata. The second purpose can be done by
simply letting coordinator provide the topic metadata and all then member
information as source of truth. Is it necessary to pass topic metadata of
each consumer around? Can we keep the protocol metadata field completely
independent of topic metadata? I think In the JoinGroupResponse, we should
have only one copy of topic metadata provided by coordinator and is outside
of protocol metadata. If user decides to put some metadata in the
JoinGroupRequest and let coordinator pass around, they are responsible for
understanding the risk.

Thanks,

Jiangjie (Becket) Qin


On Thu, Aug 13, 2015 at 12:41 PM, Jason Gustafson <ja...@confluent.io>
wrote:

> Hey Onur and Jiangjie,
>
> I've updated that wiki with a proposal to add regex subscriptions to the
> consumer metadata. Can you have a look to see if it addresses your concern?
> In general, I think we should be a little careful when we are talking about
> the scalability of the protocol. Regardless of whether assignment is done
> on the server or the client, the protocol assumes a relatively stable
> configuration. When the number of consumers increases beyond a certain
> limit, then membership churn becomes a major concern. Similarly there is a
> notion of metadata churn when topics are added, deleted, or resized. If
> either membership or metadata changes, then the protocol forces all
> consumers to stop consumption and rejoin the group. If this happens often
> enough, then it can severely impact the ability of the consumer to make
> progress. The point is that the protocol may already be unsuited to cases
> where there are either a large number of consumers or topics. I wonder if
> you guys can share your thoughts about your scaling expectations?
>
> -Jason
>
>
>
>
> On Wed, Aug 12, 2015 at 12:28 PM, Jason Gustafson <ja...@confluent.io>
> wrote:
>
> > Hey Jiangjie,
> >
> > That's a great point. In the worst case (the mirror maker case I guess),
> > the join group response can be massive. This would be especially deadly
> > when there is a lot of churn in the group (e.g. in a rolling upgrade).
> The
> > current protocol is not great for this case either, but it's
> significantly
> > better. Here are a couple ways to deal with the size:
> >
> > 1. First, we could have the coordinator compress the responses. This
> would
> > probably be pretty effective if applied across the metadata from all
> > members.
> >
> > 2. I think the regex case is the main problem. Is that right? We could
> > extend the metadata to allow the consumer to embed its regex subscription
> > in the metadata directly (note this might be a good idea regardless of
> the
> > rest of this proposal). To support regex on the consumer, we must fetch
> > metadata for all topics. Rather than having all regex subscribers embed
> all
> > of this metadata in their join group requests, they could instead embed a
> > hash of it. Then after the join group responses are received, they just
> > need to check that the hashes are the same. If there is a mismatch (which
> > should only occur when topics are created, deleted, or resized), then the
> > group members must refetch the metadata and rejoin the group. This is
> also
> > how the current protocol behaves when there is a change in the topic
> > metadata affecting the group--someone (either the coordinator or the
> > consumer) detects the change and forces the group to rebalance.
> >
> > What do you think?
> >
> > (Also I think adding groupId/generationId to fetch and produce requests
> > seems like an interesting line of thought.)
> >
> > -Jason
> >
> >
> >
> > On Wed, Aug 12, 2015 at 10:57 AM, Jiangjie Qin <jqin@linkedin.com.invalid
> >
> > wrote:
> >
> >> Hey Ewen,
> >>
> >> Onur and I discussed this a little bit more. And we are still worrying
> >> about passing all the metadata of all consumers around.
> >>
> >> Let's say I have a cluster has 10,000 topics, the average topic name
> >> length
> >> is 10 bytes. In this case, the opaque metadata will have 10 * 10,000 =
> >> 100KB for topic name, for each topic, there is a 4-byte integer of
> number
> >> of partitions, that's another 40KB. So one global topic metadata will
> have
> >> 140KB data. If I have 100 consumers who are using wildcard to consume
> from
> >> all the topics. That means the protocol metadata end up in the
> >> JoinGroupResponse will be 140KB * 100 = 14MB. And the JoinGroupResponse
> >> will need to be sent to 100 different consumers, that means 14MB * 100 =
> >> 1.4GB need to be sent by the consumer coordinator for one rebalance. How
> >> would that work?
> >>
> >> Also, having two consumers (old owner and new owner) consuming from the
> >> same partition might also be a problem. e.g. people are updating
> database.
> >> One thing might worth doing is to add GroupId and Generation ID to
> >> ProducerRequest and FetchRequest as well. This will also help with the
> >> single producer use case. However, this is probably orthogonal to this
> >> thread given the current new consumer also has this problem and I
> believe
> >> we need to fix it.
> >>
> >> Thanks,
> >>
> >> Jiangjie (Becket) Qin
> >>
> >> On Tue, Aug 11, 2015 at 11:43 PM, Ewen Cheslack-Postava <
> >> ewen@confluent.io>
> >> wrote:
> >>
> >> > On Tue, Aug 11, 2015 at 11:29 PM, Jiangjie Qin
> >> <jq...@linkedin.com.invalid>
> >> > wrote:
> >> >
> >> > > Ewen,
> >> > >
> >> > > Thanks for the explanation.
> >> > >
> >> > > For (1), I am more concerned about the failure case instead of
> normal
> >> > case.
> >> > > What if a consumer somehow was kick out of a group but is still
> >> consuming
> >> > > and committing offsets? Does that mean the new owner and old owner
> >> might
> >> > > potentially consuming from and committing offsets for the same
> >> partition?
> >> > > In the old consumer, this won't happen because the new consumer will
> >> not
> >> > be
> >> > > able to start consumption unless the previous owner has released its
> >> > > ownership. Basically, without the ownership guarantee, I don't see
> how
> >> > the
> >> > > communication among consumers themselves alone can solve the problem
> >> > here.
> >> > >
> >> >
> >> > The generation ID check still applies to offset commits. If one of the
> >> > consumers is kicked out and misbehaving, it can obviously still fetch
> >> and
> >> > process messages, but offset commits will not work since it will not
> >> have
> >> > the current generation ID.
> >> >
> >> >
> >> > >
> >> > > For (2) and (3), now I understand how metadata are used. But I still
> >> > don't
> >> > > see why should we let the consumers to pass the topic information
> >> across
> >> > > instead of letting coordinator give the information. The single
> >> producer
> >> > > use case does not solve the ownership problem in abnormal case
> either,
> >> > > which seems to be a little bit vulnerable.
> >> > >
> >> >
> >> > One of the goals here was to generalize group membership so we can,
> for
> >> > example, use it for balancing Copycat tasks across workers. There's no
> >> > topic subscription info in that case. The metadata for copycat workers
> >> > would instead need to somehow indicate the current set of tasks that
> >> need
> >> > to be assigned to workers. By making the metadata completely opaque to
> >> the
> >> > protocol, it becomes more generally useful since it focuses squarely
> on
> >> the
> >> > group membership problem, allowing for that additional bit of metadata
> >> so
> >> > you don't just get a list of members, but also get a little bit of
> info
> >> > about each of them.
> >> >
> >> > A different option that we explored is to use a sort of mixed model --
> >> > still bake all the topic subscriptions directly into the protocol but
> >> also
> >> > include metadata. That would allow us to maintain the existing
> >> > coordinator-driven approach to handling the metadata and change events
> >> like
> >> > the ones Onur pointed out. Then something like the Copycat workers
> would
> >> > just not fill in any topic subscriptions and it would be handled as a
> >> > degenerate case. Based on the way I explained that we can handle those
> >> > types of events, I personally feel its cleaner and a nicer
> >> generalization
> >> > to not include the subscriptions in the join group protocol, making it
> >> part
> >> > of the metadata instead.
> >> >
> >> > For the single producer case, are you saying it doesn't solve
> ownership
> >> in
> >> > the abnormal case because a producer that doesn't know it has been
> >> kicked
> >> > out of the group yet can still produce data even though it shouldn't
> be
> >> > able to anymore? I definitely agree that that is a risk -- this
> >> provides a
> >> > way to get closer to a true single-writer, but there are definitely
> >> still
> >> > failure modes that this does not address.
> >> >
> >> > -Ewen
> >> >
> >> >
> >> > >
> >> > > Thanks,
> >> > >
> >> > > Jiangjie (Becket) Qin
> >> > >
> >> > >
> >> > > On Tue, Aug 11, 2015 at 11:06 PM, Ewen Cheslack-Postava <
> >> > ewen@confluent.io
> >> > > >
> >> > > wrote:
> >> > >
> >> > > > On Tue, Aug 11, 2015 at 10:15 PM, Jiangjie Qin
> >> > <jqin@linkedin.com.invalid
> >> > > >
> >> > > > wrote:
> >> > > >
> >> > > > > Hi Jason,
> >> > > > >
> >> > > > > Thanks for writing this up. It would be useful to generalize the
> >> > group
> >> > > > > concept. I have a few questions below.
> >> > > > >
> >> > > > > 1. In old consumer actually the partition assignment are done by
> >> > > > consumers
> >> > > > > themselves. We used zookeeper to guarantee that a partition will
> >> only
> >> > > be
> >> > > > > consumed by one consumer thread who successfully claimed its
> >> > ownership.
> >> > > > > Does the new protocol plan to provide the same guarantee?
> >> > > > >
> >> > > >
> >> > > > Once you have all the metadata from all the consumers, assignment
> >> > should
> >> > > > just be a simple function mapping that Map<ConsumerId, Metadata>
> to
> >> > > > Map<ConsumerId, List<TopicPartition>>. If everyone is consistent
> in
> >> > > > computing that, you don't need ZK involved at all.
> >> > > >
> >> > > > In practice, this shouldn't be that hard to ensure for most
> >> assignment
> >> > > > strategies just by having decent unit testing on them. You just
> >> have to
> >> > > do
> >> > > > things like ensure your assignment strategy sorts lists into a
> >> > consistent
> >> > > > order.
> >> > > >
> >> > > > You do give up the ability to use some techniques (e.g. any
> >> randomized
> >> > > > algorithm if you can't distribute the seed w/ the metadata) and
> it's
> >> > true
> >> > > > that nothing validates the assignment, but if that assignment
> >> algorithm
> >> > > > step is kept simple, small, and well tested, the risk is very
> >> minimal.
> >> > > >
> >> > > >
> >> > > > >
> >> > > > > 2. It looks that both JoinGroupRequest and JoinGroupResponse has
> >> the
> >> > > > > ProtocolMetadata.AssignmentStrategyMetadata, what would be the
> >> > metadata
> >> > > > be
> >> > > > > sent and returned by coordinator? How will the coordinator
> handle
> >> the
> >> > > > > metadata?
> >> > > > >
> >> > > >
> >> > > > The coordinator is basically just blindly broadcasting all of it
> to
> >> > group
> >> > > > members so they have a consistent view.
> >> > > >
> >> > > > So from the coordinators perspective, it sees something like:
> >> > > >
> >> > > > Consumer 1 -> JoinGroupRequest with GroupProtocols = [ "consumer"
> >> > > > <Consumer1 opaque byte[]>]
> >> > > > Consumer 2 -> JoinGroupRequest with GroupProtocols = [ "consumer"
> >> > > > <Consumer2 opaque byte[]>]
> >> > > >
> >> > > > Then, in the responses would look like:
> >> > > >
> >> > > > Consumer 1 <- JoinGroupResponse with GroupProtocol = "consumer"
> and
> >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque byte[]>, Consumer 2
> >> > > > <Consumer2 opaque byte[]>]
> >> > > > Consumer 2 <- JoinGroupResponse with GroupProtocol = "consumer"
> and
> >> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque byte[]>, Consumer 2
> >> > > > <Consumer2 opaque byte[]>]
> >> > > >
> >> > > > So all the responses include all the metadata for every member in
> >> the
> >> > > > group, and everyone can use that to consistently decide on
> >> assignment.
> >> > > The
> >> > > > broker doesn't care and cannot even understand the metadata since
> >> the
> >> > > data
> >> > > > format for it is dependent on the assignment strategy being used.
> >> > > >
> >> > > > As another example that is *not* a consumer, let's say you just
> >> want to
> >> > > > have a single writer in the group which everyone will forward
> >> requests
> >> > > to.
> >> > > > To accomplish this, you could use a very dumb assignment strategy:
> >> > there
> >> > > is
> >> > > > no metadata (empty byte[]) and all we care about is who is the
> first
> >> > > member
> >> > > > in the group (e.g. when IDs are sorted lexicographically). That
> >> member
> >> > is
> >> > > > selected as the writer. In that case, we actually just care about
> >> the
> >> > > > membership list, there's no additional info about each member that
> >> is
> >> > > > required to determine who is the writer.
> >> > > >
> >> > > >
> >> > > > > 3. Do you mean that the number of partitions in
> JoinGroupResponse
> >> > will
> >> > > be
> >> > > > > the max partition number of a topic among all the reported
> >> partition
> >> > > > number
> >> > > > > by consumers? Is there any reason not just let Coordinator to
> >> return
> >> > > the
> >> > > > > number of partitions of a topic in its metadata cache?
> >> > > > >
> >> > > >
> >> > > > Nothing from the embedded protocol is touched by the broker. The
> >> broker
> >> > > > just collects opaque bytes of metadata, does the selection of the
> >> > > strategy
> >> > > > if multiple are supported by some consumers, and then returns that
> >> > opaque
> >> > > > metadata for all the members back to every member. In that way
> they
> >> all
> >> > > > have a consistent view of the group. For regular consumers, that
> >> view
> >> > of
> >> > > > the group includes information about how many partitions each
> >> consumer
> >> > > > currently thinks the topics it is subscribed to has. These could
> be
> >> > > > inconsistent due to out of date metadata and it would be up to the
> >> > > > assignment strategy on the *client* to resolve that. As you point
> >> out,
> >> > in
> >> > > > that case they could just take the max value that any consumer
> >> reported
> >> > > > seeing and use that. The consumers that notice that their metadata
> >> had
> >> > a
> >> > > > smaller # of partitions should also trigger a metadata update when
> >> they
> >> > > see
> >> > > > someone else observing a larger # of partitions.
> >> > > >
> >> > > >
> >> > > > >
> >> > > > > Thanks,
> >> > > > >
> >> > > > > Jiangjie (Becket) Qin
> >> > > > >
> >> > > > >
> >> > > > >
> >> > > > >
> >> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <
> >> jason@confluent.io
> >> > >
> >> > > > > wrote:
> >> > > > >
> >> > > > > > Hi Kafka Devs,
> >> > > > > >
> >> > > > > > One of the nagging issues in the current design of the new
> >> consumer
> >> > > has
> >> > > > > > been the need to support a variety of assignment strategies.
> >> We've
> >> > > > > > encountered this in particular in the design of copycat and
> the
> >> > > > > processing
> >> > > > > > framework (KIP-28). From what I understand, Samza also has a
> >> number
> >> > > of
> >> > > > > use
> >> > > > > > cases with custom assignment needs. The new consumer protocol
> >> > > supports
> >> > > > > new
> >> > > > > > assignment strategies by hooking them into the broker. For
> many
> >> > > > > > environments, this is a major pain and in some cases, a
> >> > non-starter.
> >> > > It
> >> > > > > > also challenges the validation that the coordinator can
> provide.
> >> > For
> >> > > > > > example, some assignment strategies call for partitions to be
> >> > > assigned
> >> > > > > > multiple times, which means that the coordinator can only
> check
> >> > that
> >> > > > > > partitions have been assigned at least once.
> >> > > > > >
> >> > > > > > To solve these issues, we'd like to propose moving assignment
> to
> >> > the
> >> > > > > > client. I've written a wiki which outlines some protocol
> >> changes to
> >> > > > > achieve
> >> > > > > > this:
> >> > > > > >
> >> > > > > >
> >> > > > >
> >> > > >
> >> > >
> >> >
> >>
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> >> > > > > > .
> >> > > > > > To summarize briefly, instead of the coordinator assigning the
> >> > > > partitions
> >> > > > > > itself, all subscriptions are forwarded to each member of the
> >> group
> >> > > > which
> >> > > > > > then decides independently which partitions it should consume.
> >> The
> >> > > > > protocol
> >> > > > > > provides a mechanism for the coordinator to validate that all
> >> > > consumers
> >> > > > > use
> >> > > > > > the same assignment strategy, but it does not ensure that the
> >> > > resulting
> >> > > > > > assignment is "correct." This provides a powerful capability
> for
> >> > > users
> >> > > > to
> >> > > > > > control the full data flow on the client side. They control
> how
> >> > data
> >> > > is
> >> > > > > > written to partitions through the Partitioner interface and
> they
> >> > > > control
> >> > > > > > how data is consumed through the assignment strategy, all
> >> without
> >> > > > > touching
> >> > > > > > the server.
> >> > > > > >
> >> > > > > > Of course nothing comes for free. In particular, this change
> >> > removes
> >> > > > the
> >> > > > > > ability of the coordinator to validate that commits are made
> by
> >> > > > consumers
> >> > > > > > who were assigned the respective partition. This might not be
> >> too
> >> > bad
> >> > > > > since
> >> > > > > > we retain the ability to validate the generation id, but it
> is a
> >> > > > > potential
> >> > > > > > concern. We have considered alternative protocols which add a
> >> > second
> >> > > > > > round-trip to the protocol in order to give the coordinator
> the
> >> > > ability
> >> > > > > to
> >> > > > > > confirm the assignment. As mentioned above, the coordinator is
> >> > > somewhat
> >> > > > > > limited in what it can actually validate, but this would
> return
> >> its
> >> > > > > ability
> >> > > > > > to validate commits. The tradeoff is that it increases the
> >> > protocol's
> >> > > > > > complexity which means more ways for the protocol to fail and
> >> > > > > consequently
> >> > > > > > more edge cases in the code.
> >> > > > > >
> >> > > > > > It also misses an opportunity to generalize the group
> membership
> >> > > > protocol
> >> > > > > > for additional use cases. In fact, after you've gone to the
> >> trouble
> >> > > of
> >> > > > > > moving assignment to the client, the main thing that is left
> in
> >> > this
> >> > > > > > protocol is basically a general group management capability.
> >> This
> >> > is
> >> > > > > > exactly what is needed for a few cases that are currently
> under
> >> > > > > discussion
> >> > > > > > (e.g. copycat or single-writer producer). We've taken this
> >> further
> >> > > step
> >> > > > > in
> >> > > > > > the proposal and attempted to envision what that general
> >> protocol
> >> > > might
> >> > > > > > look like and how it could be used both by the consumer and
> for
> >> > some
> >> > > of
> >> > > > > > these other cases.
> >> > > > > >
> >> > > > > > Anyway, since time is running out on the new consumer, we have
> >> > > perhaps
> >> > > > > one
> >> > > > > > last chance to consider a significant change in the protocol
> >> like
> >> > > this,
> >> > > > > so
> >> > > > > > have a look at the wiki and share your thoughts. I've no doubt
> >> that
> >> > > > some
> >> > > > > > ideas seem clearer in my mind than they do on paper, so ask
> >> > questions
> >> > > > if
> >> > > > > > there is any confusion.
> >> > > > > >
> >> > > > > > Thanks!
> >> > > > > > Jason
> >> > > > > >
> >> > > > >
> >> > > >
> >> > > >
> >> > > >
> >> > > > --
> >> > > > Thanks,
> >> > > > Ewen
> >> > > >
> >> > >
> >> >
> >> >
> >> >
> >> > --
> >> > Thanks,
> >> > Ewen
> >> >
> >>
> >
> >
>

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Jason Gustafson <ja...@confluent.io>.
Hey Onur and Jiangjie,

I've updated that wiki with a proposal to add regex subscriptions to the
consumer metadata. Can you have a look to see if it addresses your concern?
In general, I think we should be a little careful when we are talking about
the scalability of the protocol. Regardless of whether assignment is done
on the server or the client, the protocol assumes a relatively stable
configuration. When the number of consumers increases beyond a certain
limit, then membership churn becomes a major concern. Similarly there is a
notion of metadata churn when topics are added, deleted, or resized. If
either membership or metadata changes, then the protocol forces all
consumers to stop consumption and rejoin the group. If this happens often
enough, then it can severely impact the ability of the consumer to make
progress. The point is that the protocol may already be unsuited to cases
where there are either a large number of consumers or topics. I wonder if
you guys can share your thoughts about your scaling expectations?

-Jason




On Wed, Aug 12, 2015 at 12:28 PM, Jason Gustafson <ja...@confluent.io>
wrote:

> Hey Jiangjie,
>
> That's a great point. In the worst case (the mirror maker case I guess),
> the join group response can be massive. This would be especially deadly
> when there is a lot of churn in the group (e.g. in a rolling upgrade). The
> current protocol is not great for this case either, but it's significantly
> better. Here are a couple ways to deal with the size:
>
> 1. First, we could have the coordinator compress the responses. This would
> probably be pretty effective if applied across the metadata from all
> members.
>
> 2. I think the regex case is the main problem. Is that right? We could
> extend the metadata to allow the consumer to embed its regex subscription
> in the metadata directly (note this might be a good idea regardless of the
> rest of this proposal). To support regex on the consumer, we must fetch
> metadata for all topics. Rather than having all regex subscribers embed all
> of this metadata in their join group requests, they could instead embed a
> hash of it. Then after the join group responses are received, they just
> need to check that the hashes are the same. If there is a mismatch (which
> should only occur when topics are created, deleted, or resized), then the
> group members must refetch the metadata and rejoin the group. This is also
> how the current protocol behaves when there is a change in the topic
> metadata affecting the group--someone (either the coordinator or the
> consumer) detects the change and forces the group to rebalance.
>
> What do you think?
>
> (Also I think adding groupId/generationId to fetch and produce requests
> seems like an interesting line of thought.)
>
> -Jason
>
>
>
> On Wed, Aug 12, 2015 at 10:57 AM, Jiangjie Qin <jq...@linkedin.com.invalid>
> wrote:
>
>> Hey Ewen,
>>
>> Onur and I discussed this a little bit more. And we are still worrying
>> about passing all the metadata of all consumers around.
>>
>> Let's say I have a cluster has 10,000 topics, the average topic name
>> length
>> is 10 bytes. In this case, the opaque metadata will have 10 * 10,000 =
>> 100KB for topic name, for each topic, there is a 4-byte integer of number
>> of partitions, that's another 40KB. So one global topic metadata will have
>> 140KB data. If I have 100 consumers who are using wildcard to consume from
>> all the topics. That means the protocol metadata end up in the
>> JoinGroupResponse will be 140KB * 100 = 14MB. And the JoinGroupResponse
>> will need to be sent to 100 different consumers, that means 14MB * 100 =
>> 1.4GB need to be sent by the consumer coordinator for one rebalance. How
>> would that work?
>>
>> Also, having two consumers (old owner and new owner) consuming from the
>> same partition might also be a problem. e.g. people are updating database.
>> One thing might worth doing is to add GroupId and Generation ID to
>> ProducerRequest and FetchRequest as well. This will also help with the
>> single producer use case. However, this is probably orthogonal to this
>> thread given the current new consumer also has this problem and I believe
>> we need to fix it.
>>
>> Thanks,
>>
>> Jiangjie (Becket) Qin
>>
>> On Tue, Aug 11, 2015 at 11:43 PM, Ewen Cheslack-Postava <
>> ewen@confluent.io>
>> wrote:
>>
>> > On Tue, Aug 11, 2015 at 11:29 PM, Jiangjie Qin
>> <jq...@linkedin.com.invalid>
>> > wrote:
>> >
>> > > Ewen,
>> > >
>> > > Thanks for the explanation.
>> > >
>> > > For (1), I am more concerned about the failure case instead of normal
>> > case.
>> > > What if a consumer somehow was kick out of a group but is still
>> consuming
>> > > and committing offsets? Does that mean the new owner and old owner
>> might
>> > > potentially consuming from and committing offsets for the same
>> partition?
>> > > In the old consumer, this won't happen because the new consumer will
>> not
>> > be
>> > > able to start consumption unless the previous owner has released its
>> > > ownership. Basically, without the ownership guarantee, I don't see how
>> > the
>> > > communication among consumers themselves alone can solve the problem
>> > here.
>> > >
>> >
>> > The generation ID check still applies to offset commits. If one of the
>> > consumers is kicked out and misbehaving, it can obviously still fetch
>> and
>> > process messages, but offset commits will not work since it will not
>> have
>> > the current generation ID.
>> >
>> >
>> > >
>> > > For (2) and (3), now I understand how metadata are used. But I still
>> > don't
>> > > see why should we let the consumers to pass the topic information
>> across
>> > > instead of letting coordinator give the information. The single
>> producer
>> > > use case does not solve the ownership problem in abnormal case either,
>> > > which seems to be a little bit vulnerable.
>> > >
>> >
>> > One of the goals here was to generalize group membership so we can, for
>> > example, use it for balancing Copycat tasks across workers. There's no
>> > topic subscription info in that case. The metadata for copycat workers
>> > would instead need to somehow indicate the current set of tasks that
>> need
>> > to be assigned to workers. By making the metadata completely opaque to
>> the
>> > protocol, it becomes more generally useful since it focuses squarely on
>> the
>> > group membership problem, allowing for that additional bit of metadata
>> so
>> > you don't just get a list of members, but also get a little bit of info
>> > about each of them.
>> >
>> > A different option that we explored is to use a sort of mixed model --
>> > still bake all the topic subscriptions directly into the protocol but
>> also
>> > include metadata. That would allow us to maintain the existing
>> > coordinator-driven approach to handling the metadata and change events
>> like
>> > the ones Onur pointed out. Then something like the Copycat workers would
>> > just not fill in any topic subscriptions and it would be handled as a
>> > degenerate case. Based on the way I explained that we can handle those
>> > types of events, I personally feel its cleaner and a nicer
>> generalization
>> > to not include the subscriptions in the join group protocol, making it
>> part
>> > of the metadata instead.
>> >
>> > For the single producer case, are you saying it doesn't solve ownership
>> in
>> > the abnormal case because a producer that doesn't know it has been
>> kicked
>> > out of the group yet can still produce data even though it shouldn't be
>> > able to anymore? I definitely agree that that is a risk -- this
>> provides a
>> > way to get closer to a true single-writer, but there are definitely
>> still
>> > failure modes that this does not address.
>> >
>> > -Ewen
>> >
>> >
>> > >
>> > > Thanks,
>> > >
>> > > Jiangjie (Becket) Qin
>> > >
>> > >
>> > > On Tue, Aug 11, 2015 at 11:06 PM, Ewen Cheslack-Postava <
>> > ewen@confluent.io
>> > > >
>> > > wrote:
>> > >
>> > > > On Tue, Aug 11, 2015 at 10:15 PM, Jiangjie Qin
>> > <jqin@linkedin.com.invalid
>> > > >
>> > > > wrote:
>> > > >
>> > > > > Hi Jason,
>> > > > >
>> > > > > Thanks for writing this up. It would be useful to generalize the
>> > group
>> > > > > concept. I have a few questions below.
>> > > > >
>> > > > > 1. In old consumer actually the partition assignment are done by
>> > > > consumers
>> > > > > themselves. We used zookeeper to guarantee that a partition will
>> only
>> > > be
>> > > > > consumed by one consumer thread who successfully claimed its
>> > ownership.
>> > > > > Does the new protocol plan to provide the same guarantee?
>> > > > >
>> > > >
>> > > > Once you have all the metadata from all the consumers, assignment
>> > should
>> > > > just be a simple function mapping that Map<ConsumerId, Metadata> to
>> > > > Map<ConsumerId, List<TopicPartition>>. If everyone is consistent in
>> > > > computing that, you don't need ZK involved at all.
>> > > >
>> > > > In practice, this shouldn't be that hard to ensure for most
>> assignment
>> > > > strategies just by having decent unit testing on them. You just
>> have to
>> > > do
>> > > > things like ensure your assignment strategy sorts lists into a
>> > consistent
>> > > > order.
>> > > >
>> > > > You do give up the ability to use some techniques (e.g. any
>> randomized
>> > > > algorithm if you can't distribute the seed w/ the metadata) and it's
>> > true
>> > > > that nothing validates the assignment, but if that assignment
>> algorithm
>> > > > step is kept simple, small, and well tested, the risk is very
>> minimal.
>> > > >
>> > > >
>> > > > >
>> > > > > 2. It looks that both JoinGroupRequest and JoinGroupResponse has
>> the
>> > > > > ProtocolMetadata.AssignmentStrategyMetadata, what would be the
>> > metadata
>> > > > be
>> > > > > sent and returned by coordinator? How will the coordinator handle
>> the
>> > > > > metadata?
>> > > > >
>> > > >
>> > > > The coordinator is basically just blindly broadcasting all of it to
>> > group
>> > > > members so they have a consistent view.
>> > > >
>> > > > So from the coordinators perspective, it sees something like:
>> > > >
>> > > > Consumer 1 -> JoinGroupRequest with GroupProtocols = [ "consumer"
>> > > > <Consumer1 opaque byte[]>]
>> > > > Consumer 2 -> JoinGroupRequest with GroupProtocols = [ "consumer"
>> > > > <Consumer2 opaque byte[]>]
>> > > >
>> > > > Then, in the responses would look like:
>> > > >
>> > > > Consumer 1 <- JoinGroupResponse with GroupProtocol = "consumer" and
>> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque byte[]>, Consumer 2
>> > > > <Consumer2 opaque byte[]>]
>> > > > Consumer 2 <- JoinGroupResponse with GroupProtocol = "consumer" and
>> > > > GroupMembers = [ Consumer 1 <Consumer1 opaque byte[]>, Consumer 2
>> > > > <Consumer2 opaque byte[]>]
>> > > >
>> > > > So all the responses include all the metadata for every member in
>> the
>> > > > group, and everyone can use that to consistently decide on
>> assignment.
>> > > The
>> > > > broker doesn't care and cannot even understand the metadata since
>> the
>> > > data
>> > > > format for it is dependent on the assignment strategy being used.
>> > > >
>> > > > As another example that is *not* a consumer, let's say you just
>> want to
>> > > > have a single writer in the group which everyone will forward
>> requests
>> > > to.
>> > > > To accomplish this, you could use a very dumb assignment strategy:
>> > there
>> > > is
>> > > > no metadata (empty byte[]) and all we care about is who is the first
>> > > member
>> > > > in the group (e.g. when IDs are sorted lexicographically). That
>> member
>> > is
>> > > > selected as the writer. In that case, we actually just care about
>> the
>> > > > membership list, there's no additional info about each member that
>> is
>> > > > required to determine who is the writer.
>> > > >
>> > > >
>> > > > > 3. Do you mean that the number of partitions in JoinGroupResponse
>> > will
>> > > be
>> > > > > the max partition number of a topic among all the reported
>> partition
>> > > > number
>> > > > > by consumers? Is there any reason not just let Coordinator to
>> return
>> > > the
>> > > > > number of partitions of a topic in its metadata cache?
>> > > > >
>> > > >
>> > > > Nothing from the embedded protocol is touched by the broker. The
>> broker
>> > > > just collects opaque bytes of metadata, does the selection of the
>> > > strategy
>> > > > if multiple are supported by some consumers, and then returns that
>> > opaque
>> > > > metadata for all the members back to every member. In that way they
>> all
>> > > > have a consistent view of the group. For regular consumers, that
>> view
>> > of
>> > > > the group includes information about how many partitions each
>> consumer
>> > > > currently thinks the topics it is subscribed to has. These could be
>> > > > inconsistent due to out of date metadata and it would be up to the
>> > > > assignment strategy on the *client* to resolve that. As you point
>> out,
>> > in
>> > > > that case they could just take the max value that any consumer
>> reported
>> > > > seeing and use that. The consumers that notice that their metadata
>> had
>> > a
>> > > > smaller # of partitions should also trigger a metadata update when
>> they
>> > > see
>> > > > someone else observing a larger # of partitions.
>> > > >
>> > > >
>> > > > >
>> > > > > Thanks,
>> > > > >
>> > > > > Jiangjie (Becket) Qin
>> > > > >
>> > > > >
>> > > > >
>> > > > >
>> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <
>> jason@confluent.io
>> > >
>> > > > > wrote:
>> > > > >
>> > > > > > Hi Kafka Devs,
>> > > > > >
>> > > > > > One of the nagging issues in the current design of the new
>> consumer
>> > > has
>> > > > > > been the need to support a variety of assignment strategies.
>> We've
>> > > > > > encountered this in particular in the design of copycat and the
>> > > > > processing
>> > > > > > framework (KIP-28). From what I understand, Samza also has a
>> number
>> > > of
>> > > > > use
>> > > > > > cases with custom assignment needs. The new consumer protocol
>> > > supports
>> > > > > new
>> > > > > > assignment strategies by hooking them into the broker. For many
>> > > > > > environments, this is a major pain and in some cases, a
>> > non-starter.
>> > > It
>> > > > > > also challenges the validation that the coordinator can provide.
>> > For
>> > > > > > example, some assignment strategies call for partitions to be
>> > > assigned
>> > > > > > multiple times, which means that the coordinator can only check
>> > that
>> > > > > > partitions have been assigned at least once.
>> > > > > >
>> > > > > > To solve these issues, we'd like to propose moving assignment to
>> > the
>> > > > > > client. I've written a wiki which outlines some protocol
>> changes to
>> > > > > achieve
>> > > > > > this:
>> > > > > >
>> > > > > >
>> > > > >
>> > > >
>> > >
>> >
>> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
>> > > > > > .
>> > > > > > To summarize briefly, instead of the coordinator assigning the
>> > > > partitions
>> > > > > > itself, all subscriptions are forwarded to each member of the
>> group
>> > > > which
>> > > > > > then decides independently which partitions it should consume.
>> The
>> > > > > protocol
>> > > > > > provides a mechanism for the coordinator to validate that all
>> > > consumers
>> > > > > use
>> > > > > > the same assignment strategy, but it does not ensure that the
>> > > resulting
>> > > > > > assignment is "correct." This provides a powerful capability for
>> > > users
>> > > > to
>> > > > > > control the full data flow on the client side. They control how
>> > data
>> > > is
>> > > > > > written to partitions through the Partitioner interface and they
>> > > > control
>> > > > > > how data is consumed through the assignment strategy, all
>> without
>> > > > > touching
>> > > > > > the server.
>> > > > > >
>> > > > > > Of course nothing comes for free. In particular, this change
>> > removes
>> > > > the
>> > > > > > ability of the coordinator to validate that commits are made by
>> > > > consumers
>> > > > > > who were assigned the respective partition. This might not be
>> too
>> > bad
>> > > > > since
>> > > > > > we retain the ability to validate the generation id, but it is a
>> > > > > potential
>> > > > > > concern. We have considered alternative protocols which add a
>> > second
>> > > > > > round-trip to the protocol in order to give the coordinator the
>> > > ability
>> > > > > to
>> > > > > > confirm the assignment. As mentioned above, the coordinator is
>> > > somewhat
>> > > > > > limited in what it can actually validate, but this would return
>> its
>> > > > > ability
>> > > > > > to validate commits. The tradeoff is that it increases the
>> > protocol's
>> > > > > > complexity which means more ways for the protocol to fail and
>> > > > > consequently
>> > > > > > more edge cases in the code.
>> > > > > >
>> > > > > > It also misses an opportunity to generalize the group membership
>> > > > protocol
>> > > > > > for additional use cases. In fact, after you've gone to the
>> trouble
>> > > of
>> > > > > > moving assignment to the client, the main thing that is left in
>> > this
>> > > > > > protocol is basically a general group management capability.
>> This
>> > is
>> > > > > > exactly what is needed for a few cases that are currently under
>> > > > > discussion
>> > > > > > (e.g. copycat or single-writer producer). We've taken this
>> further
>> > > step
>> > > > > in
>> > > > > > the proposal and attempted to envision what that general
>> protocol
>> > > might
>> > > > > > look like and how it could be used both by the consumer and for
>> > some
>> > > of
>> > > > > > these other cases.
>> > > > > >
>> > > > > > Anyway, since time is running out on the new consumer, we have
>> > > perhaps
>> > > > > one
>> > > > > > last chance to consider a significant change in the protocol
>> like
>> > > this,
>> > > > > so
>> > > > > > have a look at the wiki and share your thoughts. I've no doubt
>> that
>> > > > some
>> > > > > > ideas seem clearer in my mind than they do on paper, so ask
>> > questions
>> > > > if
>> > > > > > there is any confusion.
>> > > > > >
>> > > > > > Thanks!
>> > > > > > Jason
>> > > > > >
>> > > > >
>> > > >
>> > > >
>> > > >
>> > > > --
>> > > > Thanks,
>> > > > Ewen
>> > > >
>> > >
>> >
>> >
>> >
>> > --
>> > Thanks,
>> > Ewen
>> >
>>
>
>

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Jiangjie Qin <jq...@linkedin.com.INVALID>.
Hey Ewen,

Onur and I discussed this a little bit more. And we are still worrying
about passing all the metadata of all consumers around.

Let's say I have a cluster has 10,000 topics, the average topic name length
is 10 bytes. In this case, the opaque metadata will have 10 * 10,000 =
100KB for topic name, for each topic, there is a 4-byte integer of number
of partitions, that's another 40KB. So one global topic metadata will have
140KB data. If I have 100 consumers who are using wildcard to consume from
all the topics. That means the protocol metadata end up in the
JoinGroupResponse will be 140KB * 100 = 14MB. And the JoinGroupResponse
will need to be sent to 100 different consumers, that means 14MB * 100 =
1.4GB need to be sent by the consumer coordinator for one rebalance. How
would that work?

Also, having two consumers (old owner and new owner) consuming from the
same partition might also be a problem. e.g. people are updating database.
One thing might worth doing is to add GroupId and Generation ID to
ProducerRequest and FetchRequest as well. This will also help with the
single producer use case. However, this is probably orthogonal to this
thread given the current new consumer also has this problem and I believe
we need to fix it.

Thanks,

Jiangjie (Becket) Qin

On Tue, Aug 11, 2015 at 11:43 PM, Ewen Cheslack-Postava <ew...@confluent.io>
wrote:

> On Tue, Aug 11, 2015 at 11:29 PM, Jiangjie Qin <jq...@linkedin.com.invalid>
> wrote:
>
> > Ewen,
> >
> > Thanks for the explanation.
> >
> > For (1), I am more concerned about the failure case instead of normal
> case.
> > What if a consumer somehow was kick out of a group but is still consuming
> > and committing offsets? Does that mean the new owner and old owner might
> > potentially consuming from and committing offsets for the same partition?
> > In the old consumer, this won't happen because the new consumer will not
> be
> > able to start consumption unless the previous owner has released its
> > ownership. Basically, without the ownership guarantee, I don't see how
> the
> > communication among consumers themselves alone can solve the problem
> here.
> >
>
> The generation ID check still applies to offset commits. If one of the
> consumers is kicked out and misbehaving, it can obviously still fetch and
> process messages, but offset commits will not work since it will not have
> the current generation ID.
>
>
> >
> > For (2) and (3), now I understand how metadata are used. But I still
> don't
> > see why should we let the consumers to pass the topic information across
> > instead of letting coordinator give the information. The single producer
> > use case does not solve the ownership problem in abnormal case either,
> > which seems to be a little bit vulnerable.
> >
>
> One of the goals here was to generalize group membership so we can, for
> example, use it for balancing Copycat tasks across workers. There's no
> topic subscription info in that case. The metadata for copycat workers
> would instead need to somehow indicate the current set of tasks that need
> to be assigned to workers. By making the metadata completely opaque to the
> protocol, it becomes more generally useful since it focuses squarely on the
> group membership problem, allowing for that additional bit of metadata so
> you don't just get a list of members, but also get a little bit of info
> about each of them.
>
> A different option that we explored is to use a sort of mixed model --
> still bake all the topic subscriptions directly into the protocol but also
> include metadata. That would allow us to maintain the existing
> coordinator-driven approach to handling the metadata and change events like
> the ones Onur pointed out. Then something like the Copycat workers would
> just not fill in any topic subscriptions and it would be handled as a
> degenerate case. Based on the way I explained that we can handle those
> types of events, I personally feel its cleaner and a nicer generalization
> to not include the subscriptions in the join group protocol, making it part
> of the metadata instead.
>
> For the single producer case, are you saying it doesn't solve ownership in
> the abnormal case because a producer that doesn't know it has been kicked
> out of the group yet can still produce data even though it shouldn't be
> able to anymore? I definitely agree that that is a risk -- this provides a
> way to get closer to a true single-writer, but there are definitely still
> failure modes that this does not address.
>
> -Ewen
>
>
> >
> > Thanks,
> >
> > Jiangjie (Becket) Qin
> >
> >
> > On Tue, Aug 11, 2015 at 11:06 PM, Ewen Cheslack-Postava <
> ewen@confluent.io
> > >
> > wrote:
> >
> > > On Tue, Aug 11, 2015 at 10:15 PM, Jiangjie Qin
> <jqin@linkedin.com.invalid
> > >
> > > wrote:
> > >
> > > > Hi Jason,
> > > >
> > > > Thanks for writing this up. It would be useful to generalize the
> group
> > > > concept. I have a few questions below.
> > > >
> > > > 1. In old consumer actually the partition assignment are done by
> > > consumers
> > > > themselves. We used zookeeper to guarantee that a partition will only
> > be
> > > > consumed by one consumer thread who successfully claimed its
> ownership.
> > > > Does the new protocol plan to provide the same guarantee?
> > > >
> > >
> > > Once you have all the metadata from all the consumers, assignment
> should
> > > just be a simple function mapping that Map<ConsumerId, Metadata> to
> > > Map<ConsumerId, List<TopicPartition>>. If everyone is consistent in
> > > computing that, you don't need ZK involved at all.
> > >
> > > In practice, this shouldn't be that hard to ensure for most assignment
> > > strategies just by having decent unit testing on them. You just have to
> > do
> > > things like ensure your assignment strategy sorts lists into a
> consistent
> > > order.
> > >
> > > You do give up the ability to use some techniques (e.g. any randomized
> > > algorithm if you can't distribute the seed w/ the metadata) and it's
> true
> > > that nothing validates the assignment, but if that assignment algorithm
> > > step is kept simple, small, and well tested, the risk is very minimal.
> > >
> > >
> > > >
> > > > 2. It looks that both JoinGroupRequest and JoinGroupResponse has the
> > > > ProtocolMetadata.AssignmentStrategyMetadata, what would be the
> metadata
> > > be
> > > > sent and returned by coordinator? How will the coordinator handle the
> > > > metadata?
> > > >
> > >
> > > The coordinator is basically just blindly broadcasting all of it to
> group
> > > members so they have a consistent view.
> > >
> > > So from the coordinators perspective, it sees something like:
> > >
> > > Consumer 1 -> JoinGroupRequest with GroupProtocols = [ "consumer"
> > > <Consumer1 opaque byte[]>]
> > > Consumer 2 -> JoinGroupRequest with GroupProtocols = [ "consumer"
> > > <Consumer2 opaque byte[]>]
> > >
> > > Then, in the responses would look like:
> > >
> > > Consumer 1 <- JoinGroupResponse with GroupProtocol = "consumer" and
> > > GroupMembers = [ Consumer 1 <Consumer1 opaque byte[]>, Consumer 2
> > > <Consumer2 opaque byte[]>]
> > > Consumer 2 <- JoinGroupResponse with GroupProtocol = "consumer" and
> > > GroupMembers = [ Consumer 1 <Consumer1 opaque byte[]>, Consumer 2
> > > <Consumer2 opaque byte[]>]
> > >
> > > So all the responses include all the metadata for every member in the
> > > group, and everyone can use that to consistently decide on assignment.
> > The
> > > broker doesn't care and cannot even understand the metadata since the
> > data
> > > format for it is dependent on the assignment strategy being used.
> > >
> > > As another example that is *not* a consumer, let's say you just want to
> > > have a single writer in the group which everyone will forward requests
> > to.
> > > To accomplish this, you could use a very dumb assignment strategy:
> there
> > is
> > > no metadata (empty byte[]) and all we care about is who is the first
> > member
> > > in the group (e.g. when IDs are sorted lexicographically). That member
> is
> > > selected as the writer. In that case, we actually just care about the
> > > membership list, there's no additional info about each member that is
> > > required to determine who is the writer.
> > >
> > >
> > > > 3. Do you mean that the number of partitions in JoinGroupResponse
> will
> > be
> > > > the max partition number of a topic among all the reported partition
> > > number
> > > > by consumers? Is there any reason not just let Coordinator to return
> > the
> > > > number of partitions of a topic in its metadata cache?
> > > >
> > >
> > > Nothing from the embedded protocol is touched by the broker. The broker
> > > just collects opaque bytes of metadata, does the selection of the
> > strategy
> > > if multiple are supported by some consumers, and then returns that
> opaque
> > > metadata for all the members back to every member. In that way they all
> > > have a consistent view of the group. For regular consumers, that view
> of
> > > the group includes information about how many partitions each consumer
> > > currently thinks the topics it is subscribed to has. These could be
> > > inconsistent due to out of date metadata and it would be up to the
> > > assignment strategy on the *client* to resolve that. As you point out,
> in
> > > that case they could just take the max value that any consumer reported
> > > seeing and use that. The consumers that notice that their metadata had
> a
> > > smaller # of partitions should also trigger a metadata update when they
> > see
> > > someone else observing a larger # of partitions.
> > >
> > >
> > > >
> > > > Thanks,
> > > >
> > > > Jiangjie (Becket) Qin
> > > >
> > > >
> > > >
> > > >
> > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <jason@confluent.io
> >
> > > > wrote:
> > > >
> > > > > Hi Kafka Devs,
> > > > >
> > > > > One of the nagging issues in the current design of the new consumer
> > has
> > > > > been the need to support a variety of assignment strategies. We've
> > > > > encountered this in particular in the design of copycat and the
> > > > processing
> > > > > framework (KIP-28). From what I understand, Samza also has a number
> > of
> > > > use
> > > > > cases with custom assignment needs. The new consumer protocol
> > supports
> > > > new
> > > > > assignment strategies by hooking them into the broker. For many
> > > > > environments, this is a major pain and in some cases, a
> non-starter.
> > It
> > > > > also challenges the validation that the coordinator can provide.
> For
> > > > > example, some assignment strategies call for partitions to be
> > assigned
> > > > > multiple times, which means that the coordinator can only check
> that
> > > > > partitions have been assigned at least once.
> > > > >
> > > > > To solve these issues, we'd like to propose moving assignment to
> the
> > > > > client. I've written a wiki which outlines some protocol changes to
> > > > achieve
> > > > > this:
> > > > >
> > > > >
> > > >
> > >
> >
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> > > > > .
> > > > > To summarize briefly, instead of the coordinator assigning the
> > > partitions
> > > > > itself, all subscriptions are forwarded to each member of the group
> > > which
> > > > > then decides independently which partitions it should consume. The
> > > > protocol
> > > > > provides a mechanism for the coordinator to validate that all
> > consumers
> > > > use
> > > > > the same assignment strategy, but it does not ensure that the
> > resulting
> > > > > assignment is "correct." This provides a powerful capability for
> > users
> > > to
> > > > > control the full data flow on the client side. They control how
> data
> > is
> > > > > written to partitions through the Partitioner interface and they
> > > control
> > > > > how data is consumed through the assignment strategy, all without
> > > > touching
> > > > > the server.
> > > > >
> > > > > Of course nothing comes for free. In particular, this change
> removes
> > > the
> > > > > ability of the coordinator to validate that commits are made by
> > > consumers
> > > > > who were assigned the respective partition. This might not be too
> bad
> > > > since
> > > > > we retain the ability to validate the generation id, but it is a
> > > > potential
> > > > > concern. We have considered alternative protocols which add a
> second
> > > > > round-trip to the protocol in order to give the coordinator the
> > ability
> > > > to
> > > > > confirm the assignment. As mentioned above, the coordinator is
> > somewhat
> > > > > limited in what it can actually validate, but this would return its
> > > > ability
> > > > > to validate commits. The tradeoff is that it increases the
> protocol's
> > > > > complexity which means more ways for the protocol to fail and
> > > > consequently
> > > > > more edge cases in the code.
> > > > >
> > > > > It also misses an opportunity to generalize the group membership
> > > protocol
> > > > > for additional use cases. In fact, after you've gone to the trouble
> > of
> > > > > moving assignment to the client, the main thing that is left in
> this
> > > > > protocol is basically a general group management capability. This
> is
> > > > > exactly what is needed for a few cases that are currently under
> > > > discussion
> > > > > (e.g. copycat or single-writer producer). We've taken this further
> > step
> > > > in
> > > > > the proposal and attempted to envision what that general protocol
> > might
> > > > > look like and how it could be used both by the consumer and for
> some
> > of
> > > > > these other cases.
> > > > >
> > > > > Anyway, since time is running out on the new consumer, we have
> > perhaps
> > > > one
> > > > > last chance to consider a significant change in the protocol like
> > this,
> > > > so
> > > > > have a look at the wiki and share your thoughts. I've no doubt that
> > > some
> > > > > ideas seem clearer in my mind than they do on paper, so ask
> questions
> > > if
> > > > > there is any confusion.
> > > > >
> > > > > Thanks!
> > > > > Jason
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Thanks,
> > > Ewen
> > >
> >
>
>
>
> --
> Thanks,
> Ewen
>

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Ewen Cheslack-Postava <ew...@confluent.io>.
On Tue, Aug 11, 2015 at 11:29 PM, Jiangjie Qin <jq...@linkedin.com.invalid>
wrote:

> Ewen,
>
> Thanks for the explanation.
>
> For (1), I am more concerned about the failure case instead of normal case.
> What if a consumer somehow was kick out of a group but is still consuming
> and committing offsets? Does that mean the new owner and old owner might
> potentially consuming from and committing offsets for the same partition?
> In the old consumer, this won't happen because the new consumer will not be
> able to start consumption unless the previous owner has released its
> ownership. Basically, without the ownership guarantee, I don't see how the
> communication among consumers themselves alone can solve the problem here.
>

The generation ID check still applies to offset commits. If one of the
consumers is kicked out and misbehaving, it can obviously still fetch and
process messages, but offset commits will not work since it will not have
the current generation ID.


>
> For (2) and (3), now I understand how metadata are used. But I still don't
> see why should we let the consumers to pass the topic information across
> instead of letting coordinator give the information. The single producer
> use case does not solve the ownership problem in abnormal case either,
> which seems to be a little bit vulnerable.
>

One of the goals here was to generalize group membership so we can, for
example, use it for balancing Copycat tasks across workers. There's no
topic subscription info in that case. The metadata for copycat workers
would instead need to somehow indicate the current set of tasks that need
to be assigned to workers. By making the metadata completely opaque to the
protocol, it becomes more generally useful since it focuses squarely on the
group membership problem, allowing for that additional bit of metadata so
you don't just get a list of members, but also get a little bit of info
about each of them.

A different option that we explored is to use a sort of mixed model --
still bake all the topic subscriptions directly into the protocol but also
include metadata. That would allow us to maintain the existing
coordinator-driven approach to handling the metadata and change events like
the ones Onur pointed out. Then something like the Copycat workers would
just not fill in any topic subscriptions and it would be handled as a
degenerate case. Based on the way I explained that we can handle those
types of events, I personally feel its cleaner and a nicer generalization
to not include the subscriptions in the join group protocol, making it part
of the metadata instead.

For the single producer case, are you saying it doesn't solve ownership in
the abnormal case because a producer that doesn't know it has been kicked
out of the group yet can still produce data even though it shouldn't be
able to anymore? I definitely agree that that is a risk -- this provides a
way to get closer to a true single-writer, but there are definitely still
failure modes that this does not address.

-Ewen


>
> Thanks,
>
> Jiangjie (Becket) Qin
>
>
> On Tue, Aug 11, 2015 at 11:06 PM, Ewen Cheslack-Postava <ewen@confluent.io
> >
> wrote:
>
> > On Tue, Aug 11, 2015 at 10:15 PM, Jiangjie Qin <jqin@linkedin.com.invalid
> >
> > wrote:
> >
> > > Hi Jason,
> > >
> > > Thanks for writing this up. It would be useful to generalize the group
> > > concept. I have a few questions below.
> > >
> > > 1. In old consumer actually the partition assignment are done by
> > consumers
> > > themselves. We used zookeeper to guarantee that a partition will only
> be
> > > consumed by one consumer thread who successfully claimed its ownership.
> > > Does the new protocol plan to provide the same guarantee?
> > >
> >
> > Once you have all the metadata from all the consumers, assignment should
> > just be a simple function mapping that Map<ConsumerId, Metadata> to
> > Map<ConsumerId, List<TopicPartition>>. If everyone is consistent in
> > computing that, you don't need ZK involved at all.
> >
> > In practice, this shouldn't be that hard to ensure for most assignment
> > strategies just by having decent unit testing on them. You just have to
> do
> > things like ensure your assignment strategy sorts lists into a consistent
> > order.
> >
> > You do give up the ability to use some techniques (e.g. any randomized
> > algorithm if you can't distribute the seed w/ the metadata) and it's true
> > that nothing validates the assignment, but if that assignment algorithm
> > step is kept simple, small, and well tested, the risk is very minimal.
> >
> >
> > >
> > > 2. It looks that both JoinGroupRequest and JoinGroupResponse has the
> > > ProtocolMetadata.AssignmentStrategyMetadata, what would be the metadata
> > be
> > > sent and returned by coordinator? How will the coordinator handle the
> > > metadata?
> > >
> >
> > The coordinator is basically just blindly broadcasting all of it to group
> > members so they have a consistent view.
> >
> > So from the coordinators perspective, it sees something like:
> >
> > Consumer 1 -> JoinGroupRequest with GroupProtocols = [ "consumer"
> > <Consumer1 opaque byte[]>]
> > Consumer 2 -> JoinGroupRequest with GroupProtocols = [ "consumer"
> > <Consumer2 opaque byte[]>]
> >
> > Then, in the responses would look like:
> >
> > Consumer 1 <- JoinGroupResponse with GroupProtocol = "consumer" and
> > GroupMembers = [ Consumer 1 <Consumer1 opaque byte[]>, Consumer 2
> > <Consumer2 opaque byte[]>]
> > Consumer 2 <- JoinGroupResponse with GroupProtocol = "consumer" and
> > GroupMembers = [ Consumer 1 <Consumer1 opaque byte[]>, Consumer 2
> > <Consumer2 opaque byte[]>]
> >
> > So all the responses include all the metadata for every member in the
> > group, and everyone can use that to consistently decide on assignment.
> The
> > broker doesn't care and cannot even understand the metadata since the
> data
> > format for it is dependent on the assignment strategy being used.
> >
> > As another example that is *not* a consumer, let's say you just want to
> > have a single writer in the group which everyone will forward requests
> to.
> > To accomplish this, you could use a very dumb assignment strategy: there
> is
> > no metadata (empty byte[]) and all we care about is who is the first
> member
> > in the group (e.g. when IDs are sorted lexicographically). That member is
> > selected as the writer. In that case, we actually just care about the
> > membership list, there's no additional info about each member that is
> > required to determine who is the writer.
> >
> >
> > > 3. Do you mean that the number of partitions in JoinGroupResponse will
> be
> > > the max partition number of a topic among all the reported partition
> > number
> > > by consumers? Is there any reason not just let Coordinator to return
> the
> > > number of partitions of a topic in its metadata cache?
> > >
> >
> > Nothing from the embedded protocol is touched by the broker. The broker
> > just collects opaque bytes of metadata, does the selection of the
> strategy
> > if multiple are supported by some consumers, and then returns that opaque
> > metadata for all the members back to every member. In that way they all
> > have a consistent view of the group. For regular consumers, that view of
> > the group includes information about how many partitions each consumer
> > currently thinks the topics it is subscribed to has. These could be
> > inconsistent due to out of date metadata and it would be up to the
> > assignment strategy on the *client* to resolve that. As you point out, in
> > that case they could just take the max value that any consumer reported
> > seeing and use that. The consumers that notice that their metadata had a
> > smaller # of partitions should also trigger a metadata update when they
> see
> > someone else observing a larger # of partitions.
> >
> >
> > >
> > > Thanks,
> > >
> > > Jiangjie (Becket) Qin
> > >
> > >
> > >
> > >
> > > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <ja...@confluent.io>
> > > wrote:
> > >
> > > > Hi Kafka Devs,
> > > >
> > > > One of the nagging issues in the current design of the new consumer
> has
> > > > been the need to support a variety of assignment strategies. We've
> > > > encountered this in particular in the design of copycat and the
> > > processing
> > > > framework (KIP-28). From what I understand, Samza also has a number
> of
> > > use
> > > > cases with custom assignment needs. The new consumer protocol
> supports
> > > new
> > > > assignment strategies by hooking them into the broker. For many
> > > > environments, this is a major pain and in some cases, a non-starter.
> It
> > > > also challenges the validation that the coordinator can provide. For
> > > > example, some assignment strategies call for partitions to be
> assigned
> > > > multiple times, which means that the coordinator can only check that
> > > > partitions have been assigned at least once.
> > > >
> > > > To solve these issues, we'd like to propose moving assignment to the
> > > > client. I've written a wiki which outlines some protocol changes to
> > > achieve
> > > > this:
> > > >
> > > >
> > >
> >
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> > > > .
> > > > To summarize briefly, instead of the coordinator assigning the
> > partitions
> > > > itself, all subscriptions are forwarded to each member of the group
> > which
> > > > then decides independently which partitions it should consume. The
> > > protocol
> > > > provides a mechanism for the coordinator to validate that all
> consumers
> > > use
> > > > the same assignment strategy, but it does not ensure that the
> resulting
> > > > assignment is "correct." This provides a powerful capability for
> users
> > to
> > > > control the full data flow on the client side. They control how data
> is
> > > > written to partitions through the Partitioner interface and they
> > control
> > > > how data is consumed through the assignment strategy, all without
> > > touching
> > > > the server.
> > > >
> > > > Of course nothing comes for free. In particular, this change removes
> > the
> > > > ability of the coordinator to validate that commits are made by
> > consumers
> > > > who were assigned the respective partition. This might not be too bad
> > > since
> > > > we retain the ability to validate the generation id, but it is a
> > > potential
> > > > concern. We have considered alternative protocols which add a second
> > > > round-trip to the protocol in order to give the coordinator the
> ability
> > > to
> > > > confirm the assignment. As mentioned above, the coordinator is
> somewhat
> > > > limited in what it can actually validate, but this would return its
> > > ability
> > > > to validate commits. The tradeoff is that it increases the protocol's
> > > > complexity which means more ways for the protocol to fail and
> > > consequently
> > > > more edge cases in the code.
> > > >
> > > > It also misses an opportunity to generalize the group membership
> > protocol
> > > > for additional use cases. In fact, after you've gone to the trouble
> of
> > > > moving assignment to the client, the main thing that is left in this
> > > > protocol is basically a general group management capability. This is
> > > > exactly what is needed for a few cases that are currently under
> > > discussion
> > > > (e.g. copycat or single-writer producer). We've taken this further
> step
> > > in
> > > > the proposal and attempted to envision what that general protocol
> might
> > > > look like and how it could be used both by the consumer and for some
> of
> > > > these other cases.
> > > >
> > > > Anyway, since time is running out on the new consumer, we have
> perhaps
> > > one
> > > > last chance to consider a significant change in the protocol like
> this,
> > > so
> > > > have a look at the wiki and share your thoughts. I've no doubt that
> > some
> > > > ideas seem clearer in my mind than they do on paper, so ask questions
> > if
> > > > there is any confusion.
> > > >
> > > > Thanks!
> > > > Jason
> > > >
> > >
> >
> >
> >
> > --
> > Thanks,
> > Ewen
> >
>



-- 
Thanks,
Ewen

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Jiangjie Qin <jq...@linkedin.com.INVALID>.
Ewen,

Thanks for the explanation.

For (1), I am more concerned about the failure case instead of normal case.
What if a consumer somehow was kick out of a group but is still consuming
and committing offsets? Does that mean the new owner and old owner might
potentially consuming from and committing offsets for the same partition?
In the old consumer, this won't happen because the new consumer will not be
able to start consumption unless the previous owner has released its
ownership. Basically, without the ownership guarantee, I don't see how the
communication among consumers themselves alone can solve the problem here.

For (2) and (3), now I understand how metadata are used. But I still don't
see why should we let the consumers to pass the topic information across
instead of letting coordinator give the information. The single producer
use case does not solve the ownership problem in abnormal case either,
which seems to be a little bit vulnerable.

Thanks,

Jiangjie (Becket) Qin


On Tue, Aug 11, 2015 at 11:06 PM, Ewen Cheslack-Postava <ew...@confluent.io>
wrote:

> On Tue, Aug 11, 2015 at 10:15 PM, Jiangjie Qin <jq...@linkedin.com.invalid>
> wrote:
>
> > Hi Jason,
> >
> > Thanks for writing this up. It would be useful to generalize the group
> > concept. I have a few questions below.
> >
> > 1. In old consumer actually the partition assignment are done by
> consumers
> > themselves. We used zookeeper to guarantee that a partition will only be
> > consumed by one consumer thread who successfully claimed its ownership.
> > Does the new protocol plan to provide the same guarantee?
> >
>
> Once you have all the metadata from all the consumers, assignment should
> just be a simple function mapping that Map<ConsumerId, Metadata> to
> Map<ConsumerId, List<TopicPartition>>. If everyone is consistent in
> computing that, you don't need ZK involved at all.
>
> In practice, this shouldn't be that hard to ensure for most assignment
> strategies just by having decent unit testing on them. You just have to do
> things like ensure your assignment strategy sorts lists into a consistent
> order.
>
> You do give up the ability to use some techniques (e.g. any randomized
> algorithm if you can't distribute the seed w/ the metadata) and it's true
> that nothing validates the assignment, but if that assignment algorithm
> step is kept simple, small, and well tested, the risk is very minimal.
>
>
> >
> > 2. It looks that both JoinGroupRequest and JoinGroupResponse has the
> > ProtocolMetadata.AssignmentStrategyMetadata, what would be the metadata
> be
> > sent and returned by coordinator? How will the coordinator handle the
> > metadata?
> >
>
> The coordinator is basically just blindly broadcasting all of it to group
> members so they have a consistent view.
>
> So from the coordinators perspective, it sees something like:
>
> Consumer 1 -> JoinGroupRequest with GroupProtocols = [ "consumer"
> <Consumer1 opaque byte[]>]
> Consumer 2 -> JoinGroupRequest with GroupProtocols = [ "consumer"
> <Consumer2 opaque byte[]>]
>
> Then, in the responses would look like:
>
> Consumer 1 <- JoinGroupResponse with GroupProtocol = "consumer" and
> GroupMembers = [ Consumer 1 <Consumer1 opaque byte[]>, Consumer 2
> <Consumer2 opaque byte[]>]
> Consumer 2 <- JoinGroupResponse with GroupProtocol = "consumer" and
> GroupMembers = [ Consumer 1 <Consumer1 opaque byte[]>, Consumer 2
> <Consumer2 opaque byte[]>]
>
> So all the responses include all the metadata for every member in the
> group, and everyone can use that to consistently decide on assignment. The
> broker doesn't care and cannot even understand the metadata since the data
> format for it is dependent on the assignment strategy being used.
>
> As another example that is *not* a consumer, let's say you just want to
> have a single writer in the group which everyone will forward requests to.
> To accomplish this, you could use a very dumb assignment strategy: there is
> no metadata (empty byte[]) and all we care about is who is the first member
> in the group (e.g. when IDs are sorted lexicographically). That member is
> selected as the writer. In that case, we actually just care about the
> membership list, there's no additional info about each member that is
> required to determine who is the writer.
>
>
> > 3. Do you mean that the number of partitions in JoinGroupResponse will be
> > the max partition number of a topic among all the reported partition
> number
> > by consumers? Is there any reason not just let Coordinator to return the
> > number of partitions of a topic in its metadata cache?
> >
>
> Nothing from the embedded protocol is touched by the broker. The broker
> just collects opaque bytes of metadata, does the selection of the strategy
> if multiple are supported by some consumers, and then returns that opaque
> metadata for all the members back to every member. In that way they all
> have a consistent view of the group. For regular consumers, that view of
> the group includes information about how many partitions each consumer
> currently thinks the topics it is subscribed to has. These could be
> inconsistent due to out of date metadata and it would be up to the
> assignment strategy on the *client* to resolve that. As you point out, in
> that case they could just take the max value that any consumer reported
> seeing and use that. The consumers that notice that their metadata had a
> smaller # of partitions should also trigger a metadata update when they see
> someone else observing a larger # of partitions.
>
>
> >
> > Thanks,
> >
> > Jiangjie (Becket) Qin
> >
> >
> >
> >
> > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <ja...@confluent.io>
> > wrote:
> >
> > > Hi Kafka Devs,
> > >
> > > One of the nagging issues in the current design of the new consumer has
> > > been the need to support a variety of assignment strategies. We've
> > > encountered this in particular in the design of copycat and the
> > processing
> > > framework (KIP-28). From what I understand, Samza also has a number of
> > use
> > > cases with custom assignment needs. The new consumer protocol supports
> > new
> > > assignment strategies by hooking them into the broker. For many
> > > environments, this is a major pain and in some cases, a non-starter. It
> > > also challenges the validation that the coordinator can provide. For
> > > example, some assignment strategies call for partitions to be assigned
> > > multiple times, which means that the coordinator can only check that
> > > partitions have been assigned at least once.
> > >
> > > To solve these issues, we'd like to propose moving assignment to the
> > > client. I've written a wiki which outlines some protocol changes to
> > achieve
> > > this:
> > >
> > >
> >
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> > > .
> > > To summarize briefly, instead of the coordinator assigning the
> partitions
> > > itself, all subscriptions are forwarded to each member of the group
> which
> > > then decides independently which partitions it should consume. The
> > protocol
> > > provides a mechanism for the coordinator to validate that all consumers
> > use
> > > the same assignment strategy, but it does not ensure that the resulting
> > > assignment is "correct." This provides a powerful capability for users
> to
> > > control the full data flow on the client side. They control how data is
> > > written to partitions through the Partitioner interface and they
> control
> > > how data is consumed through the assignment strategy, all without
> > touching
> > > the server.
> > >
> > > Of course nothing comes for free. In particular, this change removes
> the
> > > ability of the coordinator to validate that commits are made by
> consumers
> > > who were assigned the respective partition. This might not be too bad
> > since
> > > we retain the ability to validate the generation id, but it is a
> > potential
> > > concern. We have considered alternative protocols which add a second
> > > round-trip to the protocol in order to give the coordinator the ability
> > to
> > > confirm the assignment. As mentioned above, the coordinator is somewhat
> > > limited in what it can actually validate, but this would return its
> > ability
> > > to validate commits. The tradeoff is that it increases the protocol's
> > > complexity which means more ways for the protocol to fail and
> > consequently
> > > more edge cases in the code.
> > >
> > > It also misses an opportunity to generalize the group membership
> protocol
> > > for additional use cases. In fact, after you've gone to the trouble of
> > > moving assignment to the client, the main thing that is left in this
> > > protocol is basically a general group management capability. This is
> > > exactly what is needed for a few cases that are currently under
> > discussion
> > > (e.g. copycat or single-writer producer). We've taken this further step
> > in
> > > the proposal and attempted to envision what that general protocol might
> > > look like and how it could be used both by the consumer and for some of
> > > these other cases.
> > >
> > > Anyway, since time is running out on the new consumer, we have perhaps
> > one
> > > last chance to consider a significant change in the protocol like this,
> > so
> > > have a look at the wiki and share your thoughts. I've no doubt that
> some
> > > ideas seem clearer in my mind than they do on paper, so ask questions
> if
> > > there is any confusion.
> > >
> > > Thanks!
> > > Jason
> > >
> >
>
>
>
> --
> Thanks,
> Ewen
>

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Ewen Cheslack-Postava <ew...@confluent.io>.
On Tue, Aug 11, 2015 at 10:15 PM, Jiangjie Qin <jq...@linkedin.com.invalid>
wrote:

> Hi Jason,
>
> Thanks for writing this up. It would be useful to generalize the group
> concept. I have a few questions below.
>
> 1. In old consumer actually the partition assignment are done by consumers
> themselves. We used zookeeper to guarantee that a partition will only be
> consumed by one consumer thread who successfully claimed its ownership.
> Does the new protocol plan to provide the same guarantee?
>

Once you have all the metadata from all the consumers, assignment should
just be a simple function mapping that Map<ConsumerId, Metadata> to
Map<ConsumerId, List<TopicPartition>>. If everyone is consistent in
computing that, you don't need ZK involved at all.

In practice, this shouldn't be that hard to ensure for most assignment
strategies just by having decent unit testing on them. You just have to do
things like ensure your assignment strategy sorts lists into a consistent
order.

You do give up the ability to use some techniques (e.g. any randomized
algorithm if you can't distribute the seed w/ the metadata) and it's true
that nothing validates the assignment, but if that assignment algorithm
step is kept simple, small, and well tested, the risk is very minimal.


>
> 2. It looks that both JoinGroupRequest and JoinGroupResponse has the
> ProtocolMetadata.AssignmentStrategyMetadata, what would be the metadata be
> sent and returned by coordinator? How will the coordinator handle the
> metadata?
>

The coordinator is basically just blindly broadcasting all of it to group
members so they have a consistent view.

So from the coordinators perspective, it sees something like:

Consumer 1 -> JoinGroupRequest with GroupProtocols = [ "consumer"
<Consumer1 opaque byte[]>]
Consumer 2 -> JoinGroupRequest with GroupProtocols = [ "consumer"
<Consumer2 opaque byte[]>]

Then, in the responses would look like:

Consumer 1 <- JoinGroupResponse with GroupProtocol = "consumer" and
GroupMembers = [ Consumer 1 <Consumer1 opaque byte[]>, Consumer 2
<Consumer2 opaque byte[]>]
Consumer 2 <- JoinGroupResponse with GroupProtocol = "consumer" and
GroupMembers = [ Consumer 1 <Consumer1 opaque byte[]>, Consumer 2
<Consumer2 opaque byte[]>]

So all the responses include all the metadata for every member in the
group, and everyone can use that to consistently decide on assignment. The
broker doesn't care and cannot even understand the metadata since the data
format for it is dependent on the assignment strategy being used.

As another example that is *not* a consumer, let's say you just want to
have a single writer in the group which everyone will forward requests to.
To accomplish this, you could use a very dumb assignment strategy: there is
no metadata (empty byte[]) and all we care about is who is the first member
in the group (e.g. when IDs are sorted lexicographically). That member is
selected as the writer. In that case, we actually just care about the
membership list, there's no additional info about each member that is
required to determine who is the writer.


> 3. Do you mean that the number of partitions in JoinGroupResponse will be
> the max partition number of a topic among all the reported partition number
> by consumers? Is there any reason not just let Coordinator to return the
> number of partitions of a topic in its metadata cache?
>

Nothing from the embedded protocol is touched by the broker. The broker
just collects opaque bytes of metadata, does the selection of the strategy
if multiple are supported by some consumers, and then returns that opaque
metadata for all the members back to every member. In that way they all
have a consistent view of the group. For regular consumers, that view of
the group includes information about how many partitions each consumer
currently thinks the topics it is subscribed to has. These could be
inconsistent due to out of date metadata and it would be up to the
assignment strategy on the *client* to resolve that. As you point out, in
that case they could just take the max value that any consumer reported
seeing and use that. The consumers that notice that their metadata had a
smaller # of partitions should also trigger a metadata update when they see
someone else observing a larger # of partitions.


>
> Thanks,
>
> Jiangjie (Becket) Qin
>
>
>
>
> On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <ja...@confluent.io>
> wrote:
>
> > Hi Kafka Devs,
> >
> > One of the nagging issues in the current design of the new consumer has
> > been the need to support a variety of assignment strategies. We've
> > encountered this in particular in the design of copycat and the
> processing
> > framework (KIP-28). From what I understand, Samza also has a number of
> use
> > cases with custom assignment needs. The new consumer protocol supports
> new
> > assignment strategies by hooking them into the broker. For many
> > environments, this is a major pain and in some cases, a non-starter. It
> > also challenges the validation that the coordinator can provide. For
> > example, some assignment strategies call for partitions to be assigned
> > multiple times, which means that the coordinator can only check that
> > partitions have been assigned at least once.
> >
> > To solve these issues, we'd like to propose moving assignment to the
> > client. I've written a wiki which outlines some protocol changes to
> achieve
> > this:
> >
> >
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> > .
> > To summarize briefly, instead of the coordinator assigning the partitions
> > itself, all subscriptions are forwarded to each member of the group which
> > then decides independently which partitions it should consume. The
> protocol
> > provides a mechanism for the coordinator to validate that all consumers
> use
> > the same assignment strategy, but it does not ensure that the resulting
> > assignment is "correct." This provides a powerful capability for users to
> > control the full data flow on the client side. They control how data is
> > written to partitions through the Partitioner interface and they control
> > how data is consumed through the assignment strategy, all without
> touching
> > the server.
> >
> > Of course nothing comes for free. In particular, this change removes the
> > ability of the coordinator to validate that commits are made by consumers
> > who were assigned the respective partition. This might not be too bad
> since
> > we retain the ability to validate the generation id, but it is a
> potential
> > concern. We have considered alternative protocols which add a second
> > round-trip to the protocol in order to give the coordinator the ability
> to
> > confirm the assignment. As mentioned above, the coordinator is somewhat
> > limited in what it can actually validate, but this would return its
> ability
> > to validate commits. The tradeoff is that it increases the protocol's
> > complexity which means more ways for the protocol to fail and
> consequently
> > more edge cases in the code.
> >
> > It also misses an opportunity to generalize the group membership protocol
> > for additional use cases. In fact, after you've gone to the trouble of
> > moving assignment to the client, the main thing that is left in this
> > protocol is basically a general group management capability. This is
> > exactly what is needed for a few cases that are currently under
> discussion
> > (e.g. copycat or single-writer producer). We've taken this further step
> in
> > the proposal and attempted to envision what that general protocol might
> > look like and how it could be used both by the consumer and for some of
> > these other cases.
> >
> > Anyway, since time is running out on the new consumer, we have perhaps
> one
> > last chance to consider a significant change in the protocol like this,
> so
> > have a look at the wiki and share your thoughts. I've no doubt that some
> > ideas seem clearer in my mind than they do on paper, so ask questions if
> > there is any confusion.
> >
> > Thanks!
> > Jason
> >
>



-- 
Thanks,
Ewen

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Jiangjie Qin <jq...@linkedin.com.INVALID>.
Hi Jason,

Thanks for writing this up. It would be useful to generalize the group
concept. I have a few questions below.

1. In old consumer actually the partition assignment are done by consumers
themselves. We used zookeeper to guarantee that a partition will only be
consumed by one consumer thread who successfully claimed its ownership.
Does the new protocol plan to provide the same guarantee?

2. It looks that both JoinGroupRequest and JoinGroupResponse has the
ProtocolMetadata.AssignmentStrategyMetadata, what would be the metadata be
sent and returned by coordinator? How will the coordinator handle the
metadata?

3. Do you mean that the number of partitions in JoinGroupResponse will be
the max partition number of a topic among all the reported partition number
by consumers? Is there any reason not just let Coordinator to return the
number of partitions of a topic in its metadata cache?

Thanks,

Jiangjie (Becket) Qin




On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <ja...@confluent.io> wrote:

> Hi Kafka Devs,
>
> One of the nagging issues in the current design of the new consumer has
> been the need to support a variety of assignment strategies. We've
> encountered this in particular in the design of copycat and the processing
> framework (KIP-28). From what I understand, Samza also has a number of use
> cases with custom assignment needs. The new consumer protocol supports new
> assignment strategies by hooking them into the broker. For many
> environments, this is a major pain and in some cases, a non-starter. It
> also challenges the validation that the coordinator can provide. For
> example, some assignment strategies call for partitions to be assigned
> multiple times, which means that the coordinator can only check that
> partitions have been assigned at least once.
>
> To solve these issues, we'd like to propose moving assignment to the
> client. I've written a wiki which outlines some protocol changes to achieve
> this:
>
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> .
> To summarize briefly, instead of the coordinator assigning the partitions
> itself, all subscriptions are forwarded to each member of the group which
> then decides independently which partitions it should consume. The protocol
> provides a mechanism for the coordinator to validate that all consumers use
> the same assignment strategy, but it does not ensure that the resulting
> assignment is "correct." This provides a powerful capability for users to
> control the full data flow on the client side. They control how data is
> written to partitions through the Partitioner interface and they control
> how data is consumed through the assignment strategy, all without touching
> the server.
>
> Of course nothing comes for free. In particular, this change removes the
> ability of the coordinator to validate that commits are made by consumers
> who were assigned the respective partition. This might not be too bad since
> we retain the ability to validate the generation id, but it is a potential
> concern. We have considered alternative protocols which add a second
> round-trip to the protocol in order to give the coordinator the ability to
> confirm the assignment. As mentioned above, the coordinator is somewhat
> limited in what it can actually validate, but this would return its ability
> to validate commits. The tradeoff is that it increases the protocol's
> complexity which means more ways for the protocol to fail and consequently
> more edge cases in the code.
>
> It also misses an opportunity to generalize the group membership protocol
> for additional use cases. In fact, after you've gone to the trouble of
> moving assignment to the client, the main thing that is left in this
> protocol is basically a general group management capability. This is
> exactly what is needed for a few cases that are currently under discussion
> (e.g. copycat or single-writer producer). We've taken this further step in
> the proposal and attempted to envision what that general protocol might
> look like and how it could be used both by the consumer and for some of
> these other cases.
>
> Anyway, since time is running out on the new consumer, we have perhaps one
> last chance to consider a significant change in the protocol like this, so
> have a look at the wiki and share your thoughts. I've no doubt that some
> ideas seem clearer in my mind than they do on paper, so ask questions if
> there is any confusion.
>
> Thanks!
> Jason
>

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Jiangjie Qin <jq...@linkedin.com.INVALID>.
Ewen,

To be more clear about the numbers in LinkedIn including the expected
growth, we have the following table (Assuming avg topic name length is 27
bytes):

#TopicMirrored       #MirrorMakerNodes       #ConsumerPerNode
#BytesPerRebalance         #BytesPerMirrorMakerRollingBounce
100                       26
4                                   33MB                               33MB
* 26 * 2 = 1.7 GB
300                       48                                4
                    342MB                             342MB * 48 * 2 = 32 GB
500                       64                                4
                    1GB                                 1GB * 48 * 2 = 96 GB

The number is planed based on the current growth rate of our traffic in
future 3 years. The bytes in the table are calculated based on the proposed
protocol. We are concerned about whether the broadcast based protocol would
be able to support the scale at that point. The table above only accounts
for one mirror maker consumer group. Given we have four mirror maker
consumer groups, even more bytes would be transferred.

In general, I think for Kafka as a distributed system that can support
thousands of consumers, the consumer rebalance needs to be cheap. It is
important for a few reasons. e.g. Consumer churn might happen from time to
time when we have so many consumers; Supporting for basic use case like
rolling bounce, etc.

Thanks,

Jiangjie (Becket) Qin


On Sun, Aug 30, 2015 at 12:58 AM, Jiangjie Qin <jq...@linkedin.com> wrote:

> Ewen,
>
> 1. My concern is for the long subscription set that will be included in
> the protocol metadata. Because we are using selective copy with a long
> subscription set. 100 topics with 27 avg name length will give a 2.7K for
> topic name and 0.4K for the partition number bytes. This gives 3.1K for
> each subscription set. For each mirror maker consumer group, the total size
> of JoinGroupResponse will be 3.1K * 104 * 104 ~ 33 MB. We have several
> other things to think about as well: What happen if the four mirror maker
> consumer group have same broker as coordinator (unlikely for a large
> cluster but still possible)? What if the number of topics increase to 300
> or 500? What if the outbound traffic on the coordinator broker was large?
> What if quota is applied to a client (currently quota only applies to fetch
> and produce, but if metadata is big, maybe we also need to consider take it
> into account)?
>
> 2. For the rolling bounce. Are you saying we can send LeaveGroupRequest if
> it is a shutdown, and don't send LeaveGroupRequest if it is a bounce? I am
> not sure how would that work. But when people do a rolling bounce typically
> it is just a stop-then-start operation. When mirror maker shutdown, how can
> we know whether there will be a follow up start or not? If we send a
> LeaveGroupRequest to trigger a rebalance. In that case, the rebalance
> supposedly would be picked up by all the consumers in the group at next
> heartbeat. The rebalance would likely finish within a few seconds if the
> heartbeat interval is set to 3 seconds. So it seems another round of
> rebalance is unavoidable after the shutdown mirror maker node come back.
>
> 3. For the metadata inconsistency, I am actually not sure how useful it is
> to have all the consumer to fetch from the least used brokers as we are
> doing now. The "least used node" is purely based on the client side view,
> it does not necessarily mean the broker is actually "least used". It is
> totally possible that one of the consume thought a broker is least used
> while everyone else are sending data to that broker. Also, the amount of
> bytes for topic metadata will only be linear to the number of consumers in
> the group. I suppose it will cause big issue. We might get unlucky, for
> example the four mirror maker consumer groups are hashed to the same
> broker. In that case, the total TopicMetadataResponse sent by that that
> broker might be a few MB, but is way less than the total size of
> JoinGroupResponse. So that would be the first issue to solve.
>
> Thanks,
>
> Jiangjie (Becket) Qin
>
>
>
>
>
>
>
>
>
> On Sat, Aug 29, 2015 at 12:39 AM, Ewen Cheslack-Postava <ewen@confluent.io
> > wrote:
>
>> @Onur - I think you reviewed the KAFKA-2464 patch in some detail. wrt the
>> specific problem you raised about using largest # of partitions, you're
>> right, with the updated proposal this isn't possible because we only send
>> a
>> hash of the metadata in order to avoid the overhead of per-member metadata
>> being transmitted back to members in the join group response.
>>
>> However, the KAKFA-2464 patch addresses this by avoiding inconsistencies
>> as
>> much as possible by preferring the coordinator for metadata fetches when
>> it
>> detects inconsistencies. If metadata is changing fast enough, this can
>> still result in another round of inconsistency. However, note that this
>> only applies to metadata that would be included in an subscription (i.e.,
>> if quickly created/deleted topics were excluded from mirror maker
>> consumers, those consumers would not be affected by those metadata changes
>> since the hash is computed based on the topics included in the
>> subscription). Additionally, it seems based on Becket's numbers that the
>> frequency that you *might* hit this is very small and the duration of the
>> delay in getting the group to reconverge should be 2 rounds of heartbeats,
>> or 6 seconds based on current defaults.
>>
>> @Becket - these numbers are *really* useful, thanks for including them.
>> The
>> average topic name length is actually quite useful it sorting out the
>> protocol overhead.
>>
>> 1. I think the only reason this is a question is because of the metadata?
>> Otherwise we always have the standard heartbeat cycle, which is currently
>> set at 3 seconds. If metadata mismatches, all clients need to refresh.
>> Because of concerns of inconsistency, the patch for KAFKA-2464 has all
>> clients in the group hit the coordinator to achieve consistency (only
>> after
>> they detect inconsistency, so normal case should be spread across
>> brokers).
>> I'm actually not convinced this is a good idea since it centralizes all
>> metadata lookups for the group to one host, which seems risky. But it does
>> guarantee consistency as long as the metadata doesn't change in that
>> window, and any member that can't fetch metadata should just drop out of
>> the group anyway. Your numbers seem to suggest it's unlikely to be *that*
>> unstable in that window. It seems the bad case is that it takes 9 seconds
>> rather than 6 seconds to converge. And those numbers confirm previous
>> arguments that the metadata changes slowly enough that a temporary
>> inconsistency can be resolved very quickly.
>> 2. Rolling bounces are pretty clean regardless of whether assignment is
>> server- or client-side. We're following the same basic process either way.
>> In the normal case, processes restart cleanly and upon start, they
>> immediately try to join the group. There are two cases. If you're the
>> *first* node to restart, you'll trigger a join group and everyone will
>> need
>> to rejoin at their next heartbeat. It'll take as long as the heartbeat
>> interval. If you're not the first node, then there's probably another node
>> that was bounced that's already triggered the next generation. In that
>> case
>> you're just waiting to join the next generation anyway, and you'll
>> probably
>> be done in the next 3 seconds (again, based on current intervals). I think
>> the major question here is how you schedule the rolling bounce -- if you
>> do
>> too quickly, you might have a long period where lots of nodes aren't doing
>> any real work because there's always join groups in progress, which
>> requires everyone stopping, committing, then starting again. However, this
>> is true with any version of the current protocol -- it has nothing to do
>> with client side partition assignment.
>> Note that this is clearly affected by the proposal for a LeaveGroup
>> message. Rolling bounce is a case where you might not want to trigger a
>> LeaveGroup because you actually expect to restart and rejoin the group
>> immediately. This is a good argument for not using TCP disconnect as a
>> LeaveGroup signal.
>> 3. I think this is addressed in the previous two comments. Maybe one thing
>> to address again is that metadata hashes can be based only on topics
>> matching subscriptions, so any changes in, e.g., test topics that do not
>> affect a consumer groups subscriptions should have 0 effect. They never
>> trigger any join groups, never affect membership, etc. Re: actual sync,
>> I'd
>> be curious if defaulting to the coordinator to ensure consistency has any
>> problems that you can think of? It's not strictly a guarantee of
>> consistency since the metadata can change between requests from different
>> clients, but practically speaking, I don't see a case where metadata would
>> change so quickly and so consistently that we'd run into problems.
>>
>> -Ewen
>>
>>
>>
>> On Fri, Aug 28, 2015 at 9:32 PM, Jiangjie Qin <jq...@linkedin.com.invalid>
>> wrote:
>>
>> > Hi Neha,
>> >
>> > Following are some numbers we have in the pipeline. It would be very
>> > helpful to see how it goes with the proposed protocol. We will try to do
>> > some tests with the current patch as well. Please also let us know if
>> you
>> > want further information.
>> >
>> > 32 brokers, 1Gbps NIC
>> > 547 topics
>> > 27 chars average topic name length
>> > 2-3 consumers for each topic
>> >
>> > Four 26-node mirror maker instances (Four different consumer groups).
>> Each
>> > node has 4 consumers. (Each mirror maker instance has 104 consumers)
>> > We are actually using selective copy, so we have a big whitelist for
>> each
>> > mirror maker, copying about 100 topics (We expect it to grow to a
>> couple of
>> > hundreds).
>> > The mirror makers are co-located with target cluster, so the consumer
>> > traffic go through the WAN.
>> >
>> > We have 5 to 6 wildcard consumers consuming from all the topics.
>> >
>> > The topic creation frequency is not high now, roughly about 1 / day.
>> >
>> > The scenarios we are interested in are:
>> > 1. The time for one round of rebalance.
>> > 2. The time for a rolling bounce of mirror maker.
>> > 3. For wildcard topic, does metadata sync up cause problem.
>> >
>> > Thanks,
>> >
>> > Jiangjie (Becket) Qin
>> >
>> >
>> > On Fri, Aug 28, 2015 at 1:24 PM, Joel Koshy <jj...@gmail.com>
>> wrote:
>> >
>> > > Another use-case I was thinking of was something like rack-aware
>> > > assignment of partitions to clients. This would require some
>> > > additional topic metadata to be propagated to and from the coordinator
>> > > and you would need some way to resolve conflicts for such strategies.
>> > > I think that could be addressed by attaching a generation id to the
>> > > metadata and use that (i.e., pick the highest) in order to resolve
>> > > conflicts without another round of join-group requests.
>> > >
>> > > Likewise, without delete/recreate, partition counts are a sort of
>> > > generation id since they are non-decreasing. If we need to account for
>> > > delete/recreate that could perhaps be addressed by an explicit
>> > > (per-topic) generation id attached to each topic in the metadata blob.
>> > > Does that make sense? I think that covers my concerns wrt the
>> > > split-brain issues.
>> > >
>> > > I'm still a bit wary of the n^2*m sized rebroadcast of all the
>> > > metadata - mainly because for various reasons at LinkedIn, we are
>> > > actually using large explicit whitelists (and not wildcards) in
>> > > several of our mirroring pipelines. At this point I feel that is a
>> > > reasonable cost to pay for having all the logic in one place (i.e.,
>> > > client side) but I would like to think a bit more on that.
>> > >
>> > > Joel
>> > >
>> > >
>> > > On Fri, Aug 28, 2015 at 1:02 PM, Onur Karaman
>> > > <ok...@linkedin.com.invalid> wrote:
>> > > > From what I understand, the "largest number of partitions" trick is
>> > based
>> > > > on the assumption that topics can only expand their partitions. What
>> > > > happens when a topic gets deleted and recreated? This breaks that
>> > > > assumption.
>> > > >
>> > > > On Fri, Aug 28, 2015 at 6:33 AM, Neha Narkhede <ne...@confluent.io>
>> > > wrote:
>> > > >
>> > > >> Thanks for re-reviewing Joel.
>> > > >>
>> > > >>
>> > > >>
>> > > >>
>> > > >>
>> > > >>
>> > > >> On Fri, Aug 28, 2015 at 2:51 AM -0700, "Joel Koshy" <
>> > > jjkoshy.w@gmail.com>
>> > > >> wrote:
>> > > >>
>> > > >>
>> > > >>
>> > > >>
>> > > >>
>> > > >>
>> > > >>
>> > > >>
>> > > >>
>> > > >>
>> > > >> > I think we think this proposal addresses 100% of the split brain
>> > > issues
>> > > >> > ever seen in the ZK-based protocol, but I think you think there
>> are
>> > > still
>> > > >> > issues. Can you explain what your thinking of and when you think
>> it
>> > > would
>> > > >> > happen? I want to make sure you aren't assuming
>> > > client-side=>split-brain
>> > > >> > since I think that is totally not the case.
>> > > >>
>> > > >> Yes I had concluded that client-side assignment would still result
>> in
>> > > >> split-brain wrt partition counts, but I overlooked a key sentence
>> in
>> > > >> the wiki - i.e., that the assignment algorithm for consumers can
>> just
>> > > >> use the largest number of partitions for each topic reported by
>> any of
>> > > >> the consumers. i.e., I assumed that consumers would just fail
>> > > >> rebalance if the partition counts were inconsistent but that is not
>> > > >> the case since this conflict can be easily resolved as described
>> > > >> without further join-group requests. Sorry about that. There is
>> still
>> > > >> the issue of the coordinator having to send back n*m worth of
>> > > >> metadata, but that was not my biggest concern. I'll look over it
>> again
>> > > >> and reply back tomorrow.
>> > > >>
>> > > >> Joel
>> > > >>
>> > > >> On Thu, Aug 27, 2015 at 2:55 PM, Jay Kreps  wrote:
>> > > >> > Hey Joel,
>> > > >> >
>> > > >> > I really don't think we should do both. There are pros and cons
>> but
>> > we
>> > > >> > should make a decision and work on operationalizing one approach.
>> > > Much of
>> > > >> > really making something like this work is getting all the bugs
>> out,
>> > > >> getting
>> > > >> > monitoring in place, getting rigorous system tests in place.
>> Trying
>> > > to do
>> > > >> > those things twice with the same resources will just mean we do
>> them
>> > > half
>> > > >> > as well. I also think this buys nothing from the user's point of
>> > > >> view--they
>> > > >> > want co-ordination that works correctly, the debate we are
>> having is
>> > > >> purely
>> > > >> > a "how should we build that" debate. So this is really not the
>> kind
>> > of
>> > > >> > thing we'd want to make pluggable and if we did that would just
>> > > >> complicate
>> > > >> > life for the user.
>> > > >> >
>> > > >> > I think we think this proposal addresses 100% of the split brain
>> > > issues
>> > > >> > ever seen in the ZK-based protocol, but I think you think there
>> are
>> > > still
>> > > >> > issues. Can you explain what your thinking of and when you think
>> it
>> > > would
>> > > >> > happen? I want to make sure you aren't assuming
>> > > client-side=>split-brain
>> > > >> > since I think that is totally not the case.
>> > > >> >
>> > > >> > With respect to "herd issues" I actually think all the proposals
>> > > address
>> > > >> > this by scaling the co-ordinator out to all nodes and making the
>> > > >> > co-ordination vastly cheaper. No proposal, of course, gets rid of
>> > the
>> > > >> fact
>> > > >> > that all clients rejoin at once when there is a membership
>> change,
>> > but
>> > > >> that
>> > > >> > is kind of fundamental to the problem.
>> > > >> >
>> > > >> > -Jay
>> > > >> >
>> > > >> > On Thu, Aug 27, 2015 at 2:02 PM, Joel Koshy  wrote:
>> > > >> >
>> > > >> >> I actually feel these set of tests (whatever they may be) are
>> > > somewhat
>> > > >> >> irrelevant here. My main concern with the current client-side
>> > > proposal
>> > > >> >> (i.e., without Becket's follow-up suggestions) is that it makes
>> a
>> > > >> >> significant compromise to the original charter of the new
>> consumer
>> > -
>> > > >> >> i.e., reduce/eliminate herd and split brain problems in both
>> group
>> > > >> >> management and partition assignment. I understand the need for
>> > > >> >> client-side partition assignment in some use cases (which we are
>> > also
>> > > >> >> interested in), but I also think we should make every effort to
>> > keep
>> > > >> >> full server-side coordination for the remaining (majority) of
>> use
>> > > >> >> cases especially if it does not complicate the protocol. The
>> > proposed
>> > > >> >> changes do not complicate the protocol IMO - i.e., there is no
>> > > further
>> > > >> >> modification to the request/response formats beyond the current
>> > > >> >> client-side proposal. It only involves a trivial
>> reinterpretation
>> > of
>> > > >> >> the content of the protocol metadata field.
>> > > >> >>
>> > > >> >> Joel
>> > > >> >>
>> > > >> >> On Wed, Aug 26, 2015 at 9:33 PM, Neha Narkhede  wrote:
>> > > >> >> > Hey Becket,
>> > > >> >> >
>> > > >> >> > In that case, the broker side partition assignment would be
>> ideal
>> > > >> because
>> > > >> >> >> it avoids
>> > > >> >> >> issues like metadata inconsistency / split brain / exploding
>> > > >> >> subscription
>> > > >> >> >> set propagation.
>> > > >> >> >
>> > > >> >> >
>> > > >> >> > As per our previous discussions regarding each of those
>> concerns
>> > > >> >> (referring
>> > > >> >> > to this email thread, KIP calls and JIRA comments), we are
>> going
>> > to
>> > > >> run a
>> > > >> >> > set of tests using the LinkedIn deployment numbers that we
>> will
>> > > wait
>> > > >> for
>> > > >> >> > you to share. The purpose is to see if those concerns are
>> really
>> > > >> valid or
>> > > >> >> > not. I'd prefer to see that before making any more changes
>> that
>> > > will
>> > > >> >> > complicate the protocol.
>> > > >> >> >
>> > > >> >> > On Wed, Aug 26, 2015 at 4:57 PM, Jiangjie Qin > >
>> > > >> >> > wrote:
>> > > >> >> >
>> > > >> >> >> Hi folks,
>> > > >> >> >>
>> > > >> >> >> After further discussion in LinkedIn, we found that while
>> > having a
>> > > >> more
>> > > >> >> >> general group management protocol is very useful, the vast
>> > > majority
>> > > >> of
>> > > >> >> the
>> > > >> >> >> clients will not use customized partition assignment
>> strategy.
>> > In
>> > > >> that
>> > > >> >> >> case, the broker side partition assignment would be ideal
>> > because
>> > > it
>> > > >> >> avoids
>> > > >> >> >> issues like metadata inconsistency / split brain / exploding
>> > > >> >> subscription
>> > > >> >> >> set propagation.
>> > > >> >> >>
>> > > >> >> >> So we have the following proposal that satisfies the
>> majority of
>> > > the
>> > > >> >> >> clients' needs without changing the currently proposed binary
>> > > >> protocol.
>> > > >> >> >> i.e., Continue to support broker-side assignment if the
>> > assignment
>> > > >> >> strategy
>> > > >> >> >> is recognized by the coordinator.
>> > > >> >> >>
>> > > >> >> >> 1. Keep the binary protocol as currently proposed.
>> > > >> >> >>
>> > > >> >> >> 2. Change the way we interpret ProtocolMetadata:
>> > > >> >> >> 2.1 On consumer side, change partition.assignment.strategy to
>> > > >> >> >> partition.assignor.class. Implement the something like the
>> > > following
>> > > >> >> >> PartitionAssignor Interface:
>> > > >> >> >>
>> > > >> >> >> public interface PartitionAssignor {
>> > > >> >> >>   List protocolTypes();
>> > > >> >> >>   byte[] protocolMetadata();
>> > > >> >> >>   // return the Topic->List map that are assigned to this
>> > > >> >> >> consumer.
>> > > >> >> >>   List assignPartitions(String protocolType, byte[]
>> > > >> >> >> responseProtocolMetadata);
>> > > >> >> >> }
>> > > >> >> >>
>> > > >> >> >> public abstract class AbstractPartitionAssignor implements
>> > > >> >> >> PartitionAssignor {
>> > > >> >> >>   protected final KafkaConsumer consumer;
>> > > >> >> >>   AbstractPartitionAssignor(KafkaConsumer consumer) {
>> > > >> >> >>     this.consumer = consumer;
>> > > >> >> >>   }
>> > > >> >> >> }
>> > > >> >> >>
>> > > >> >> >> 2.2 The ProtocolMetadata in JoinGroupRequest will be
>> > > >> >> >> partitionAssignor.protocolMetadata(). When
>> > > partition.assignor.class
>> > > >> is
>> > > >> >> >> "range" or "roundrobin", the ProtocolMetadata in
>> > JoinGroupRequest
>> > > >> will
>> > > >> >> be a
>> > > >> >> >> JSON subscription set. ("range", "roundrobin" will be
>> reserved
>> > > >> words, we
>> > > >> >> >> can also consider reserving some Prefix such as "broker-" to
>> be
>> > > more
>> > > >> >> clear)
>> > > >> >> >> 2.3 On broker side when ProtocolType is "range" or
>> > "roundroubin",
>> > > >> >> >> coordinator will parse the ProtocolMetadata in the
>> > > JoinGroupRequest
>> > > >> and
>> > > >> >> >> assign the partitions for consumers. In the
>> JoinGroupResponse,
>> > the
>> > > >> >> >> ProtocolMetadata will be the global assignment of partitions.
>> > > >> >> >> 2.4 On client side, after receiving the JoinGroupResponse,
>> > > >> >> >> partitionAssignor.assignPartitions() will be invoked to
>> return
>> > the
>> > > >> >> actual
>> > > >> >> >> assignment. If the assignor is RangeAssignor or
>> > > RoundRobinAssignor,
>> > > >> they
>> > > >> >> >> will parse the assignment from the ProtocolMetadata returned
>> by
>> > > >> >> >> coordinator.
>> > > >> >> >>
>> > > >> >> >> This approach has a few merits:
>> > > >> >> >> 1. Does not change the proposed binary protocol, which is
>> still
>> > > >> general.
>> > > >> >> >> 2. The majority of the consumers will not suffer from
>> > inconsistent
>> > > >> >> metadata
>> > > >> >> >> / split brain / exploding subscription set propagation. This
>> is
>> > > >> >> >> specifically to deal with the issue that the current proposal
>> > > caters
>> > > >> to
>> > > >> >> a
>> > > >> >> >> 20% use-case while adversely impacting the more common 80%
>> > > use-cases.
>> > > >> >> >> 3. Easy to implement. The only thing needed is implement a
>> > > >> partitioner
>> > > >> >> >> class. For most users, the default range and roundrobin
>> > > partitioner
>> > > >> are
>> > > >> >> >> good enough.
>> > > >> >> >>
>> > > >> >> >> Thoughts?
>> > > >> >> >>
>> > > >> >> >> Thanks,
>> > > >> >> >>
>> > > >> >> >> Jiangjie (Becket) Qin
>> > > >> >> >>
>> > > >> >> >> On Tue, Aug 18, 2015 at 2:51 PM, Jason Gustafson
>> > > >> >> >> wrote:
>> > > >> >> >>
>> > > >> >> >> > Follow-up from the kip call:
>> > > >> >> >> >
>> > > >> >> >> > 1. Onur brought up the question of whether this protocol
>> > > provides
>> > > >> >> enough
>> > > >> >> >> > coordination capabilities to be generally useful in
>> practice
>> > (is
>> > > >> that
>> > > >> >> >> > accurate, Onur?). If it doesn't, then each use case would
>> > > probably
>> > > >> >> need a
>> > > >> >> >> > dependence on zookeeper anyway, and we haven't really
>> gained
>> > > >> anything.
>> > > >> >> >> The
>> > > >> >> >> > group membership provided by this protocol is a useful
>> > primitive
>> > > >> for
>> > > >> >> >> > coordination, but it's limited in the sense that everything
>> > > shared
>> > > >> >> among
>> > > >> >> >> > the group has to be communicated at the time the group is
>> > > created.
>> > > >> If
>> > > >> >> any
>> > > >> >> >> > shared data changes, then the only way the group can ensure
>> > > >> agreement
>> > > >> >> is
>> > > >> >> >> to
>> > > >> >> >> > force a rebalance. This is expensive since all members must
>> > > stall
>> > > >> >> while
>> > > >> >> >> the
>> > > >> >> >> > rebalancing takes place. As we have also seen, there is a
>> > > practical
>> > > >> >> limit
>> > > >> >> >> > on the amount of metadata that can be sent through this
>> > protocol
>> > > >> when
>> > > >> >> >> > groups get a little larger. This protocol is therefore not
>> > > >> suitable to
>> > > >> >> >> > cases which require frequent communication or which
>> require a
>> > > large
>> > > >> >> >> amount
>> > > >> >> >> > of data to be communicated. For the use cases listed on the
>> > > wiki,
>> > > >> >> neither
>> > > >> >> >> > of these appear to be an issue, but there may be other
>> > > limitations
>> > > >> >> which
>> > > >> >> >> > would limit reuse of the protocol. Perhaps it would be
>> > > sufficient
>> > > >> to
>> > > >> >> >> sketch
>> > > >> >> >> > how these cases might work?
>> > > >> >> >> >
>> > > >> >> >> > 2. We talked a little bit about the issue of metadata
>> churn.
>> > > Becket
>> > > >> >> >> brought
>> > > >> >> >> > up the interesting point that not only do we depend on
>> topic
>> > > >> metadata
>> > > >> >> >> > changing relatively infrequently, but we also expect timely
>> > > >> agreement
>> > > >> >> >> among
>> > > >> >> >> > the brokers on what that metadata is. To resolve this, we
>> can
>> > > have
>> > > >> the
>> > > >> >> >> > consumers fetch metadata from the coordinator. We still
>> depend
>> > > on
>> > > >> >> topic
>> > > >> >> >> > metadata not changing frequently, but this should resolve
>> any
>> > > >> >> >> disagreement
>> > > >> >> >> > among the brokers themselves. In fact, since we expect that
>> > > >> >> disagreement
>> > > >> >> >> is
>> > > >> >> >> > relatively rare, we can have the consumers fetch from the
>> > > >> coordinator
>> > > >> >> >> only
>> > > >> >> >> > when when a disagreement occurs. The nice thing about this
>> > > >> proposal is
>> > > >> >> >> that
>> > > >> >> >> > it doesn't affect the join group semantics, so the
>> coordinator
>> > > >> would
>> > > >> >> >> remain
>> > > >> >> >> > oblivious to the metadata used by the group for agreement.
>> > > Also, if
>> > > >> >> >> > metadata churn becomes an issue, it might be possible to
>> have
>> > > the
>> > > >> >> >> > coordinator provide a snapshot for the group to ensure
>> that a
>> > > >> >> generation
>> > > >> >> >> > would be able to reach agreement (this would probably
>> require
>> > > >> adding
>> > > >> >> >> > groupId/generation to the metadata request).
>> > > >> >> >> >
>> > > >> >> >> > 3. We talked briefly about support for multiple protocols
>> in
>> > the
>> > > >> join
>> > > >> >> >> group
>> > > >> >> >> > request in order to allow changing the assignment strategy
>> > > without
>> > > >> >> >> > downtime. I think it's a little doubtful that this would
>> get
>> > > much
>> > > >> use
>> > > >> >> in
>> > > >> >> >> > practice, but I agree it's a nice option to have on the
>> table.
>> > > An
>> > > >> >> >> > alternative, for the sake of argument, is to have each
>> member
>> > > >> provide
>> > > >> >> >> only
>> > > >> >> >> > one version of the protocol, and to let the coordinator
>> choose
>> > > the
>> > > >> >> >> protocol
>> > > >> >> >> > with the largest number of supporters. All members which
>> can't
>> > > >> support
>> > > >> >> >> the
>> > > >> >> >> > selected protocol would be kicked out of the group. The
>> > drawback
>> > > >> in a
>> > > >> >> >> > rolling upgrade is that the total capacity of the group
>> would
>> > be
>> > > >> >> >> > momentarily halved. It would also be a little tricky to
>> handle
>> > > the
>> > > >> >> case
>> > > >> >> >> of
>> > > >> >> >> > retrying when a consumer is kicked out of the group. We
>> > wouldn't
>> > > >> want
>> > > >> >> it
>> > > >> >> >> to
>> > > >> >> >> > be able to effect a rebalance, for example, if it would
>> just
>> > be
>> > > >> kicked
>> > > >> >> >> out
>> > > >> >> >> > again. That would probably complicate the group management
>> > > logic on
>> > > >> >> the
>> > > >> >> >> > coordinator.
>> > > >> >> >> >
>> > > >> >> >> >
>> > > >> >> >> > Thanks,
>> > > >> >> >> > Jason
>> > > >> >> >> >
>> > > >> >> >> >
>> > > >> >> >> > On Tue, Aug 18, 2015 at 11:16 AM, Jiangjie Qin
>> > > >> >> > >> >
>> > > >> >> >> > wrote:
>> > > >> >> >> >
>> > > >> >> >> > > Jun,
>> > > >> >> >> > >
>> > > >> >> >> > > Yes, I agree. If the metadata can be synced quickly there
>> > > should
>> > > >> >> not be
>> > > >> >> >> > an
>> > > >> >> >> > > issue. It just occurred to me that there is a proposal to
>> > > allow
>> > > >> >> >> consuming
>> > > >> >> >> > > from followers in ISR, that could potentially cause more
>> > > frequent
>> > > >> >> >> > metadata
>> > > >> >> >> > > change for consumers. Would that be an issue?
>> > > >> >> >> > >
>> > > >> >> >> > > Thanks,
>> > > >> >> >> > >
>> > > >> >> >> > > Jiangjie (Becket) Qin
>> > > >> >> >> > >
>> > > >> >> >> > > On Tue, Aug 18, 2015 at 10:22 AM, Jason Gustafson <
>> > > >> >> jason@confluent.io>
>> > > >> >> >> > > wrote:
>> > > >> >> >> > >
>> > > >> >> >> > > > Hi Jun,
>> > > >> >> >> > > >
>> > > >> >> >> > > > Answers below:
>> > > >> >> >> > > >
>> > > >> >> >> > > > 1. When there are multiple common protocols in the
>> > > >> >> JoinGroupRequest,
>> > > >> >> >> > > which
>> > > >> >> >> > > > one would the coordinator pick?
>> > > >> >> >> > > >
>> > > >> >> >> > > > I was intending to use the list to indicate
>> preference. If
>> > > all
>> > > >> >> group
>> > > >> >> >> > > > members support protocols ["A", "B"] in that order,
>> then
>> > we
>> > > >> will
>> > > >> >> >> choose
>> > > >> >> >> > > > "A." If some support ["B", "A"], then we would either
>> > choose
>> > > >> >> based on
>> > > >> >> >> > > > respective counts or just randomly. The main use case
>> of
>> > > >> >> supporting
>> > > >> >> >> the
>> > > >> >> >> > > > list is for rolling upgrades when a change is made to
>> the
>> > > >> >> assignment
>> > > >> >> >> > > > strategy. In that case, the new assignment strategy
>> would
>> > be
>> > > >> >> listed
>> > > >> >> >> > first
>> > > >> >> >> > > > in the upgraded client. I think it's debatable whether
>> > this
>> > > >> >> feature
>> > > >> >> >> > would
>> > > >> >> >> > > > get much use in practice, so we might consider dropping
>> > it.
>> > > >> >> >> > > >
>> > > >> >> >> > > > 2. If the protocols don't agree, the group construction
>> > > fails.
>> > > >> >> What
>> > > >> >> >> > > exactly
>> > > >> >> >> > > > does it mean? Do we send an error in every
>> > JoinGroupResponse
>> > > >> and
>> > > >> >> >> remove
>> > > >> >> >> > > all
>> > > >> >> >> > > > members in the group in the coordinator?
>> > > >> >> >> > > >
>> > > >> >> >> > > > Yes, that is right. It would be handled similarly to
>> > > >> inconsistent
>> > > >> >> >> > > > assignment strategies in the current protocol. The
>> > > coordinator
>> > > >> >> >> returns
>> > > >> >> >> > an
>> > > >> >> >> > > > error in each join group response, and the client
>> > propagates
>> > > >> the
>> > > >> >> >> error
>> > > >> >> >> > to
>> > > >> >> >> > > > the user.
>> > > >> >> >> > > >
>> > > >> >> >> > > > 3. Consumer embedded protocol: The proposal has two
>> > > different
>> > > >> >> formats
>> > > >> >> >> > of
>> > > >> >> >> > > > subscription depending on whether wildcards are used or
>> > not.
>> > > >> This
>> > > >> >> >> > seems a
>> > > >> >> >> > > > bit complicated. Would it be better to always use the
>> > > metadata
>> > > >> >> hash?
>> > > >> >> >> > The
>> > > >> >> >> > > > clients know the subscribed topics already. This way,
>> the
>> > > >> client
>> > > >> >> code
>> > > >> >> >> > > > behaves the same whether wildcards are used or not.
>> > > >> >> >> > > >
>> > > >> >> >> > > > Yeah, I think this is possible (Neha also suggested
>> it). I
>> > > >> haven't
>> > > >> >> >> > > updated
>> > > >> >> >> > > > the wiki yet, but the patch I started working on uses
>> only
>> > > the
>> > > >> >> >> metadata
>> > > >> >> >> > > > hash. In the case that an explicit topic list is
>> provided,
>> > > the
>> > > >> >> hash
>> > > >> >> >> > just
>> > > >> >> >> > > > covers the metadata for those topics.
>> > > >> >> >> > > >
>> > > >> >> >> > > >
>> > > >> >> >> > > > Thanks,
>> > > >> >> >> > > > Jason
>> > > >> >> >> > > >
>> > > >> >> >> > > >
>> > > >> >> >> > > >
>> > > >> >> >> > > > On Tue, Aug 18, 2015 at 10:06 AM, Jun Rao
>> > > >> >> wrote:
>> > > >> >> >> > > >
>> > > >> >> >> > > > > Jason,
>> > > >> >> >> > > > >
>> > > >> >> >> > > > > Thanks for the writeup. A few comments below.
>> > > >> >> >> > > > >
>> > > >> >> >> > > > > 1. When there are multiple common protocols in the
>> > > >> >> >> JoinGroupRequest,
>> > > >> >> >> > > > which
>> > > >> >> >> > > > > one would the coordinator pick?
>> > > >> >> >> > > > > 2. If the protocols don't agree, the group
>> construction
>> > > >> fails.
>> > > >> >> What
>> > > >> >> >> > > > exactly
>> > > >> >> >> > > > > does it mean? Do we send an error in every
>> > > JoinGroupResponse
>> > > >> and
>> > > >> >> >> > remove
>> > > >> >> >> > > > all
>> > > >> >> >> > > > > members in the group in the coordinator?
>> > > >> >> >> > > > > 3. Consumer embedded protocol: The proposal has two
>> > > different
>> > > >> >> >> formats
>> > > >> >> >> > > of
>> > > >> >> >> > > > > subscription depending on whether wildcards are used
>> or
>> > > not.
>> > > >> >> This
>> > > >> >> >> > > seems a
>> > > >> >> >> > > > > bit complicated. Would it be better to always use the
>> > > >> metadata
>> > > >> >> >> hash?
>> > > >> >> >> > > The
>> > > >> >> >> > > > > clients know the subscribed topics already. This way,
>> > the
>> > > >> client
>> > > >> >> >> code
>> > > >> >> >> > > > > behaves the same whether wildcards are used or not.
>> > > >> >> >> > > > >
>> > > >> >> >> > > > > Jiangjie,
>> > > >> >> >> > > > >
>> > > >> >> >> > > > > With respect to rebalance churns due to topics being
>> > > >> >> >> created/deleted.
>> > > >> >> >> > > > With
>> > > >> >> >> > > > > the new consumer, the rebalance can probably settle
>> > within
>> > > >> 200ms
>> > > >> >> >> when
>> > > >> >> >> > > > there
>> > > >> >> >> > > > > is a topic change. So, as long as we are not changing
>> > > topic
>> > > >> more
>> > > >> >> >> > than 5
>> > > >> >> >> > > > > times per sec, there shouldn't be constant churns,
>> > right?
>> > > >> >> >> > > > >
>> > > >> >> >> > > > > Thanks,
>> > > >> >> >> > > > >
>> > > >> >> >> > > > > Jun
>> > > >> >> >> > > > >
>> > > >> >> >> > > > >
>> > > >> >> >> > > > >
>> > > >> >> >> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <
>> > > >> >> >> jason@confluent.io
>> > > >> >> >> > >
>> > > >> >> >> > > > > wrote:
>> > > >> >> >> > > > >
>> > > >> >> >> > > > > > Hi Kafka Devs,
>> > > >> >> >> > > > > >
>> > > >> >> >> > > > > > One of the nagging issues in the current design of
>> the
>> > > new
>> > > >> >> >> consumer
>> > > >> >> >> > > has
>> > > >> >> >> > > > > > been the need to support a variety of assignment
>> > > >> strategies.
>> > > >> >> >> We've
>> > > >> >> >> > > > > > encountered this in particular in the design of
>> > copycat
>> > > and
>> > > >> >> the
>> > > >> >> >> > > > > processing
>> > > >> >> >> > > > > > framework (KIP-28). From what I understand, Samza
>> also
>> > > has
>> > > >> a
>> > > >> >> >> number
>> > > >> >> >> > > of
>> > > >> >> >> > > > > use
>> > > >> >> >> > > > > > cases with custom assignment needs. The new
>> consumer
>> > > >> protocol
>> > > >> >> >> > > supports
>> > > >> >> >> > > > > new
>> > > >> >> >> > > > > > assignment strategies by hooking them into the
>> broker.
>> > > For
>> > > >> >> many
>> > > >> >> >> > > > > > environments, this is a major pain and in some
>> cases,
>> > a
>> > > >> >> >> > non-starter.
>> > > >> >> >> > > It
>> > > >> >> >> > > > > > also challenges the validation that the coordinator
>> > can
>> > > >> >> provide.
>> > > >> >> >> > For
>> > > >> >> >> > > > > > example, some assignment strategies call for
>> > partitions
>> > > to
>> > > >> be
>> > > >> >> >> > > assigned
>> > > >> >> >> > > > > > multiple times, which means that the coordinator
>> can
>> > > only
>> > > >> >> check
>> > > >> >> >> > that
>> > > >> >> >> > > > > > partitions have been assigned at least once.
>> > > >> >> >> > > > > >
>> > > >> >> >> > > > > > To solve these issues, we'd like to propose moving
>> > > >> assignment
>> > > >> >> to
>> > > >> >> >> > the
>> > > >> >> >> > > > > > client. I've written a wiki which outlines some
>> > protocol
>> > > >> >> changes
>> > > >> >> >> to
>> > > >> >> >> > > > > achieve
>> > > >> >> >> > > > > > this:
>> > > >> >> >> > > > > >
>> > > >> >> >> > > > > >
>> > > >> >> >> > > > >
>> > > >> >> >> > > >
>> > > >> >> >> > >
>> > > >> >> >> >
>> > > >> >> >>
>> > > >> >>
>> > > >>
>> > >
>> >
>> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
>> > > >> >> >> > > > > > .
>> > > >> >> >> > > > > > To summarize briefly, instead of the coordinator
>> > > assigning
>> > > >> the
>> > > >> >> >> > > > partitions
>> > > >> >> >> > > > > > itself, all subscriptions are forwarded to each
>> member
>> > > of
>> > > >> the
>> > > >> >> >> group
>> > > >> >> >> > > > which
>> > > >> >> >> > > > > > then decides independently which partitions it
>> should
>> > > >> consume.
>> > > >> >> >> The
>> > > >> >> >> > > > > protocol
>> > > >> >> >> > > > > > provides a mechanism for the coordinator to
>> validate
>> > > that
>> > > >> all
>> > > >> >> >> > > consumers
>> > > >> >> >> > > > > use
>> > > >> >> >> > > > > > the same assignment strategy, but it does not
>> ensure
>> > > that
>> > > >> the
>> > > >> >> >> > > resulting
>> > > >> >> >> > > > > > assignment is "correct." This provides a powerful
>> > > >> capability
>> > > >> >> for
>> > > >> >> >> > > users
>> > > >> >> >> > > > to
>> > > >> >> >> > > > > > control the full data flow on the client side. They
>> > > control
>> > > >> >> how
>> > > >> >> >> > data
>> > > >> >> >> > > is
>> > > >> >> >> > > > > > written to partitions through the Partitioner
>> > interface
>> > > and
>> > > >> >> they
>> > > >> >> >> > > > control
>> > > >> >> >> > > > > > how data is consumed through the assignment
>> strategy,
>> > > all
>> > > >> >> without
>> > > >> >> >> > > > > touching
>> > > >> >> >> > > > > > the server.
>> > > >> >> >> > > > > >
>> > > >> >> >> > > > > > Of course nothing comes for free. In particular,
>> this
>> > > >> change
>> > > >> >> >> > removes
>> > > >> >> >> > > > the
>> > > >> >> >> > > > > > ability of the coordinator to validate that commits
>> > are
>> > > >> made
>> > > >> >> by
>> > > >> >> >> > > > consumers
>> > > >> >> >> > > > > > who were assigned the respective partition. This
>> might
>> > > not
>> > > >> be
>> > > >> >> too
>> > > >> >> >> > bad
>> > > >> >> >> > > > > since
>> > > >> >> >> > > > > > we retain the ability to validate the generation
>> id,
>> > > but it
>> > > >> >> is a
>> > > >> >> >> > > > > potential
>> > > >> >> >> > > > > > concern. We have considered alternative protocols
>> > which
>> > > >> add a
>> > > >> >> >> > second
>> > > >> >> >> > > > > > round-trip to the protocol in order to give the
>> > > coordinator
>> > > >> >> the
>> > > >> >> >> > > ability
>> > > >> >> >> > > > > to
>> > > >> >> >> > > > > > confirm the assignment. As mentioned above, the
>> > > >> coordinator is
>> > > >> >> >> > > somewhat
>> > > >> >> >> > > > > > limited in what it can actually validate, but this
>> > would
>> > > >> >> return
>> > > >> >> >> its
>> > > >> >> >> > > > > ability
>> > > >> >> >> > > > > > to validate commits. The tradeoff is that it
>> increases
>> > > the
>> > > >> >> >> > protocol's
>> > > >> >> >> > > > > > complexity which means more ways for the protocol
>> to
>> > > fail
>> > > >> and
>> > > >> >> >> > > > > consequently
>> > > >> >> >> > > > > > more edge cases in the code.
>> > > >> >> >> > > > > >
>> > > >> >> >> > > > > > It also misses an opportunity to generalize the
>> group
>> > > >> >> membership
>> > > >> >> >> > > > protocol
>> > > >> >> >> > > > > > for additional use cases. In fact, after you've
>> gone
>> > to
>> > > the
>> > > >> >> >> trouble
>> > > >> >> >> > > of
>> > > >> >> >> > > > > > moving assignment to the client, the main thing
>> that
>> > is
>> > > >> left
>> > > >> >> in
>> > > >> >> >> > this
>> > > >> >> >> > > > > > protocol is basically a general group management
>> > > >> capability.
>> > > >> >> This
>> > > >> >> >> > is
>> > > >> >> >> > > > > > exactly what is needed for a few cases that are
>> > > currently
>> > > >> >> under
>> > > >> >> >> > > > > discussion
>> > > >> >> >> > > > > > (e.g. copycat or single-writer producer). We've
>> taken
>> > > this
>> > > >> >> >> further
>> > > >> >> >> > > step
>> > > >> >> >> > > > > in
>> > > >> >> >> > > > > > the proposal and attempted to envision what that
>> > general
>> > > >> >> protocol
>> > > >> >> >> > > might
>> > > >> >> >> > > > > > look like and how it could be used both by the
>> > consumer
>> > > and
>> > > >> >> for
>> > > >> >> >> > some
>> > > >> >> >> > > of
>> > > >> >> >> > > > > > these other cases.
>> > > >> >> >> > > > > >
>> > > >> >> >> > > > > > Anyway, since time is running out on the new
>> consumer,
>> > > we
>> > > >> have
>> > > >> >> >> > > perhaps
>> > > >> >> >> > > > > one
>> > > >> >> >> > > > > > last chance to consider a significant change in the
>> > > >> protocol
>> > > >> >> like
>> > > >> >> >> > > this,
>> > > >> >> >> > > > > so
>> > > >> >> >> > > > > > have a look at the wiki and share your thoughts.
>> I've
>> > no
>> > > >> doubt
>> > > >> >> >> that
>> > > >> >> >> > > > some
>> > > >> >> >> > > > > > ideas seem clearer in my mind than they do on
>> paper,
>> > so
>> > > ask
>> > > >> >> >> > questions
>> > > >> >> >> > > > if
>> > > >> >> >> > > > > > there is any confusion.
>> > > >> >> >> > > > > >
>> > > >> >> >> > > > > > Thanks!
>> > > >> >> >> > > > > > Jason
>> > > >> >> >> > > > > >
>> > > >> >> >> > > > >
>> > > >> >> >> > > >
>> > > >> >> >> > >
>> > > >> >> >> >
>> > > >> >> >>
>> > > >> >> >
>> > > >> >> >
>> > > >> >> >
>> > > >> >> > --
>> > > >> >> > Thanks,
>> > > >> >> > Neha
>> > > >> >>
>> > > >>
>> > >
>> >
>>
>>
>>
>> --
>> Thanks,
>> Ewen
>>
>
>

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Jiangjie Qin <jq...@linkedin.com.INVALID>.
Ewen,

1. My concern is for the long subscription set that will be included in the
protocol metadata. Because we are using selective copy with a long
subscription set. 100 topics with 27 avg name length will give a 2.7K for
topic name and 0.4K for the partition number bytes. This gives 3.1K for
each subscription set. For each mirror maker consumer group, the total size
of JoinGroupResponse will be 3.1K * 104 * 104 ~ 33 MB. We have several
other things to think about as well: What happen if the four mirror maker
consumer group have same broker as coordinator (unlikely for a large
cluster but still possible)? What if the number of topics increase to 300
or 500? What if the outbound traffic on the coordinator broker was large?
What if quota is applied to a client (currently quota only applies to fetch
and produce, but if metadata is big, maybe we also need to consider take it
into account)?

2. For the rolling bounce. Are you saying we can send LeaveGroupRequest if
it is a shutdown, and don't send LeaveGroupRequest if it is a bounce? I am
not sure how would that work. But when people do a rolling bounce typically
it is just a stop-then-start operation. When mirror maker shutdown, how can
we know whether there will be a follow up start or not? If we send a
LeaveGroupRequest to trigger a rebalance. In that case, the rebalance
supposedly would be picked up by all the consumers in the group at next
heartbeat. The rebalance would likely finish within a few seconds if the
heartbeat interval is set to 3 seconds. So it seems another round of
rebalance is unavoidable after the shutdown mirror maker node come back.

3. For the metadata inconsistency, I am actually not sure how useful it is
to have all the consumer to fetch from the least used brokers as we are
doing now. The "least used node" is purely based on the client side view,
it does not necessarily mean the broker is actually "least used". It is
totally possible that one of the consume thought a broker is least used
while everyone else are sending data to that broker. Also, the amount of
bytes for topic metadata will only be linear to the number of consumers in
the group. I suppose it will cause big issue. We might get unlucky, for
example the four mirror maker consumer groups are hashed to the same
broker. In that case, the total TopicMetadataResponse sent by that that
broker might be a few MB, but is way less than the total size of
JoinGroupResponse. So that would be the first issue to solve.

Thanks,

Jiangjie (Becket) Qin









On Sat, Aug 29, 2015 at 12:39 AM, Ewen Cheslack-Postava <ew...@confluent.io>
wrote:

> @Onur - I think you reviewed the KAFKA-2464 patch in some detail. wrt the
> specific problem you raised about using largest # of partitions, you're
> right, with the updated proposal this isn't possible because we only send a
> hash of the metadata in order to avoid the overhead of per-member metadata
> being transmitted back to members in the join group response.
>
> However, the KAKFA-2464 patch addresses this by avoiding inconsistencies as
> much as possible by preferring the coordinator for metadata fetches when it
> detects inconsistencies. If metadata is changing fast enough, this can
> still result in another round of inconsistency. However, note that this
> only applies to metadata that would be included in an subscription (i.e.,
> if quickly created/deleted topics were excluded from mirror maker
> consumers, those consumers would not be affected by those metadata changes
> since the hash is computed based on the topics included in the
> subscription). Additionally, it seems based on Becket's numbers that the
> frequency that you *might* hit this is very small and the duration of the
> delay in getting the group to reconverge should be 2 rounds of heartbeats,
> or 6 seconds based on current defaults.
>
> @Becket - these numbers are *really* useful, thanks for including them. The
> average topic name length is actually quite useful it sorting out the
> protocol overhead.
>
> 1. I think the only reason this is a question is because of the metadata?
> Otherwise we always have the standard heartbeat cycle, which is currently
> set at 3 seconds. If metadata mismatches, all clients need to refresh.
> Because of concerns of inconsistency, the patch for KAFKA-2464 has all
> clients in the group hit the coordinator to achieve consistency (only after
> they detect inconsistency, so normal case should be spread across brokers).
> I'm actually not convinced this is a good idea since it centralizes all
> metadata lookups for the group to one host, which seems risky. But it does
> guarantee consistency as long as the metadata doesn't change in that
> window, and any member that can't fetch metadata should just drop out of
> the group anyway. Your numbers seem to suggest it's unlikely to be *that*
> unstable in that window. It seems the bad case is that it takes 9 seconds
> rather than 6 seconds to converge. And those numbers confirm previous
> arguments that the metadata changes slowly enough that a temporary
> inconsistency can be resolved very quickly.
> 2. Rolling bounces are pretty clean regardless of whether assignment is
> server- or client-side. We're following the same basic process either way.
> In the normal case, processes restart cleanly and upon start, they
> immediately try to join the group. There are two cases. If you're the
> *first* node to restart, you'll trigger a join group and everyone will need
> to rejoin at their next heartbeat. It'll take as long as the heartbeat
> interval. If you're not the first node, then there's probably another node
> that was bounced that's already triggered the next generation. In that case
> you're just waiting to join the next generation anyway, and you'll probably
> be done in the next 3 seconds (again, based on current intervals). I think
> the major question here is how you schedule the rolling bounce -- if you do
> too quickly, you might have a long period where lots of nodes aren't doing
> any real work because there's always join groups in progress, which
> requires everyone stopping, committing, then starting again. However, this
> is true with any version of the current protocol -- it has nothing to do
> with client side partition assignment.
> Note that this is clearly affected by the proposal for a LeaveGroup
> message. Rolling bounce is a case where you might not want to trigger a
> LeaveGroup because you actually expect to restart and rejoin the group
> immediately. This is a good argument for not using TCP disconnect as a
> LeaveGroup signal.
> 3. I think this is addressed in the previous two comments. Maybe one thing
> to address again is that metadata hashes can be based only on topics
> matching subscriptions, so any changes in, e.g., test topics that do not
> affect a consumer groups subscriptions should have 0 effect. They never
> trigger any join groups, never affect membership, etc. Re: actual sync, I'd
> be curious if defaulting to the coordinator to ensure consistency has any
> problems that you can think of? It's not strictly a guarantee of
> consistency since the metadata can change between requests from different
> clients, but practically speaking, I don't see a case where metadata would
> change so quickly and so consistently that we'd run into problems.
>
> -Ewen
>
>
>
> On Fri, Aug 28, 2015 at 9:32 PM, Jiangjie Qin <jq...@linkedin.com.invalid>
> wrote:
>
> > Hi Neha,
> >
> > Following are some numbers we have in the pipeline. It would be very
> > helpful to see how it goes with the proposed protocol. We will try to do
> > some tests with the current patch as well. Please also let us know if you
> > want further information.
> >
> > 32 brokers, 1Gbps NIC
> > 547 topics
> > 27 chars average topic name length
> > 2-3 consumers for each topic
> >
> > Four 26-node mirror maker instances (Four different consumer groups).
> Each
> > node has 4 consumers. (Each mirror maker instance has 104 consumers)
> > We are actually using selective copy, so we have a big whitelist for each
> > mirror maker, copying about 100 topics (We expect it to grow to a couple
> of
> > hundreds).
> > The mirror makers are co-located with target cluster, so the consumer
> > traffic go through the WAN.
> >
> > We have 5 to 6 wildcard consumers consuming from all the topics.
> >
> > The topic creation frequency is not high now, roughly about 1 / day.
> >
> > The scenarios we are interested in are:
> > 1. The time for one round of rebalance.
> > 2. The time for a rolling bounce of mirror maker.
> > 3. For wildcard topic, does metadata sync up cause problem.
> >
> > Thanks,
> >
> > Jiangjie (Becket) Qin
> >
> >
> > On Fri, Aug 28, 2015 at 1:24 PM, Joel Koshy <jj...@gmail.com> wrote:
> >
> > > Another use-case I was thinking of was something like rack-aware
> > > assignment of partitions to clients. This would require some
> > > additional topic metadata to be propagated to and from the coordinator
> > > and you would need some way to resolve conflicts for such strategies.
> > > I think that could be addressed by attaching a generation id to the
> > > metadata and use that (i.e., pick the highest) in order to resolve
> > > conflicts without another round of join-group requests.
> > >
> > > Likewise, without delete/recreate, partition counts are a sort of
> > > generation id since they are non-decreasing. If we need to account for
> > > delete/recreate that could perhaps be addressed by an explicit
> > > (per-topic) generation id attached to each topic in the metadata blob.
> > > Does that make sense? I think that covers my concerns wrt the
> > > split-brain issues.
> > >
> > > I'm still a bit wary of the n^2*m sized rebroadcast of all the
> > > metadata - mainly because for various reasons at LinkedIn, we are
> > > actually using large explicit whitelists (and not wildcards) in
> > > several of our mirroring pipelines. At this point I feel that is a
> > > reasonable cost to pay for having all the logic in one place (i.e.,
> > > client side) but I would like to think a bit more on that.
> > >
> > > Joel
> > >
> > >
> > > On Fri, Aug 28, 2015 at 1:02 PM, Onur Karaman
> > > <ok...@linkedin.com.invalid> wrote:
> > > > From what I understand, the "largest number of partitions" trick is
> > based
> > > > on the assumption that topics can only expand their partitions. What
> > > > happens when a topic gets deleted and recreated? This breaks that
> > > > assumption.
> > > >
> > > > On Fri, Aug 28, 2015 at 6:33 AM, Neha Narkhede <ne...@confluent.io>
> > > wrote:
> > > >
> > > >> Thanks for re-reviewing Joel.
> > > >>
> > > >>
> > > >>
> > > >>
> > > >>
> > > >>
> > > >> On Fri, Aug 28, 2015 at 2:51 AM -0700, "Joel Koshy" <
> > > jjkoshy.w@gmail.com>
> > > >> wrote:
> > > >>
> > > >>
> > > >>
> > > >>
> > > >>
> > > >>
> > > >>
> > > >>
> > > >>
> > > >>
> > > >> > I think we think this proposal addresses 100% of the split brain
> > > issues
> > > >> > ever seen in the ZK-based protocol, but I think you think there
> are
> > > still
> > > >> > issues. Can you explain what your thinking of and when you think
> it
> > > would
> > > >> > happen? I want to make sure you aren't assuming
> > > client-side=>split-brain
> > > >> > since I think that is totally not the case.
> > > >>
> > > >> Yes I had concluded that client-side assignment would still result
> in
> > > >> split-brain wrt partition counts, but I overlooked a key sentence in
> > > >> the wiki - i.e., that the assignment algorithm for consumers can
> just
> > > >> use the largest number of partitions for each topic reported by any
> of
> > > >> the consumers. i.e., I assumed that consumers would just fail
> > > >> rebalance if the partition counts were inconsistent but that is not
> > > >> the case since this conflict can be easily resolved as described
> > > >> without further join-group requests. Sorry about that. There is
> still
> > > >> the issue of the coordinator having to send back n*m worth of
> > > >> metadata, but that was not my biggest concern. I'll look over it
> again
> > > >> and reply back tomorrow.
> > > >>
> > > >> Joel
> > > >>
> > > >> On Thu, Aug 27, 2015 at 2:55 PM, Jay Kreps  wrote:
> > > >> > Hey Joel,
> > > >> >
> > > >> > I really don't think we should do both. There are pros and cons
> but
> > we
> > > >> > should make a decision and work on operationalizing one approach.
> > > Much of
> > > >> > really making something like this work is getting all the bugs
> out,
> > > >> getting
> > > >> > monitoring in place, getting rigorous system tests in place.
> Trying
> > > to do
> > > >> > those things twice with the same resources will just mean we do
> them
> > > half
> > > >> > as well. I also think this buys nothing from the user's point of
> > > >> view--they
> > > >> > want co-ordination that works correctly, the debate we are having
> is
> > > >> purely
> > > >> > a "how should we build that" debate. So this is really not the
> kind
> > of
> > > >> > thing we'd want to make pluggable and if we did that would just
> > > >> complicate
> > > >> > life for the user.
> > > >> >
> > > >> > I think we think this proposal addresses 100% of the split brain
> > > issues
> > > >> > ever seen in the ZK-based protocol, but I think you think there
> are
> > > still
> > > >> > issues. Can you explain what your thinking of and when you think
> it
> > > would
> > > >> > happen? I want to make sure you aren't assuming
> > > client-side=>split-brain
> > > >> > since I think that is totally not the case.
> > > >> >
> > > >> > With respect to "herd issues" I actually think all the proposals
> > > address
> > > >> > this by scaling the co-ordinator out to all nodes and making the
> > > >> > co-ordination vastly cheaper. No proposal, of course, gets rid of
> > the
> > > >> fact
> > > >> > that all clients rejoin at once when there is a membership change,
> > but
> > > >> that
> > > >> > is kind of fundamental to the problem.
> > > >> >
> > > >> > -Jay
> > > >> >
> > > >> > On Thu, Aug 27, 2015 at 2:02 PM, Joel Koshy  wrote:
> > > >> >
> > > >> >> I actually feel these set of tests (whatever they may be) are
> > > somewhat
> > > >> >> irrelevant here. My main concern with the current client-side
> > > proposal
> > > >> >> (i.e., without Becket's follow-up suggestions) is that it makes a
> > > >> >> significant compromise to the original charter of the new
> consumer
> > -
> > > >> >> i.e., reduce/eliminate herd and split brain problems in both
> group
> > > >> >> management and partition assignment. I understand the need for
> > > >> >> client-side partition assignment in some use cases (which we are
> > also
> > > >> >> interested in), but I also think we should make every effort to
> > keep
> > > >> >> full server-side coordination for the remaining (majority) of use
> > > >> >> cases especially if it does not complicate the protocol. The
> > proposed
> > > >> >> changes do not complicate the protocol IMO - i.e., there is no
> > > further
> > > >> >> modification to the request/response formats beyond the current
> > > >> >> client-side proposal. It only involves a trivial reinterpretation
> > of
> > > >> >> the content of the protocol metadata field.
> > > >> >>
> > > >> >> Joel
> > > >> >>
> > > >> >> On Wed, Aug 26, 2015 at 9:33 PM, Neha Narkhede  wrote:
> > > >> >> > Hey Becket,
> > > >> >> >
> > > >> >> > In that case, the broker side partition assignment would be
> ideal
> > > >> because
> > > >> >> >> it avoids
> > > >> >> >> issues like metadata inconsistency / split brain / exploding
> > > >> >> subscription
> > > >> >> >> set propagation.
> > > >> >> >
> > > >> >> >
> > > >> >> > As per our previous discussions regarding each of those
> concerns
> > > >> >> (referring
> > > >> >> > to this email thread, KIP calls and JIRA comments), we are
> going
> > to
> > > >> run a
> > > >> >> > set of tests using the LinkedIn deployment numbers that we will
> > > wait
> > > >> for
> > > >> >> > you to share. The purpose is to see if those concerns are
> really
> > > >> valid or
> > > >> >> > not. I'd prefer to see that before making any more changes that
> > > will
> > > >> >> > complicate the protocol.
> > > >> >> >
> > > >> >> > On Wed, Aug 26, 2015 at 4:57 PM, Jiangjie Qin > >
> > > >> >> > wrote:
> > > >> >> >
> > > >> >> >> Hi folks,
> > > >> >> >>
> > > >> >> >> After further discussion in LinkedIn, we found that while
> > having a
> > > >> more
> > > >> >> >> general group management protocol is very useful, the vast
> > > majority
> > > >> of
> > > >> >> the
> > > >> >> >> clients will not use customized partition assignment strategy.
> > In
> > > >> that
> > > >> >> >> case, the broker side partition assignment would be ideal
> > because
> > > it
> > > >> >> avoids
> > > >> >> >> issues like metadata inconsistency / split brain / exploding
> > > >> >> subscription
> > > >> >> >> set propagation.
> > > >> >> >>
> > > >> >> >> So we have the following proposal that satisfies the majority
> of
> > > the
> > > >> >> >> clients' needs without changing the currently proposed binary
> > > >> protocol.
> > > >> >> >> i.e., Continue to support broker-side assignment if the
> > assignment
> > > >> >> strategy
> > > >> >> >> is recognized by the coordinator.
> > > >> >> >>
> > > >> >> >> 1. Keep the binary protocol as currently proposed.
> > > >> >> >>
> > > >> >> >> 2. Change the way we interpret ProtocolMetadata:
> > > >> >> >> 2.1 On consumer side, change partition.assignment.strategy to
> > > >> >> >> partition.assignor.class. Implement the something like the
> > > following
> > > >> >> >> PartitionAssignor Interface:
> > > >> >> >>
> > > >> >> >> public interface PartitionAssignor {
> > > >> >> >>   List protocolTypes();
> > > >> >> >>   byte[] protocolMetadata();
> > > >> >> >>   // return the Topic->List map that are assigned to this
> > > >> >> >> consumer.
> > > >> >> >>   List assignPartitions(String protocolType, byte[]
> > > >> >> >> responseProtocolMetadata);
> > > >> >> >> }
> > > >> >> >>
> > > >> >> >> public abstract class AbstractPartitionAssignor implements
> > > >> >> >> PartitionAssignor {
> > > >> >> >>   protected final KafkaConsumer consumer;
> > > >> >> >>   AbstractPartitionAssignor(KafkaConsumer consumer) {
> > > >> >> >>     this.consumer = consumer;
> > > >> >> >>   }
> > > >> >> >> }
> > > >> >> >>
> > > >> >> >> 2.2 The ProtocolMetadata in JoinGroupRequest will be
> > > >> >> >> partitionAssignor.protocolMetadata(). When
> > > partition.assignor.class
> > > >> is
> > > >> >> >> "range" or "roundrobin", the ProtocolMetadata in
> > JoinGroupRequest
> > > >> will
> > > >> >> be a
> > > >> >> >> JSON subscription set. ("range", "roundrobin" will be reserved
> > > >> words, we
> > > >> >> >> can also consider reserving some Prefix such as "broker-" to
> be
> > > more
> > > >> >> clear)
> > > >> >> >> 2.3 On broker side when ProtocolType is "range" or
> > "roundroubin",
> > > >> >> >> coordinator will parse the ProtocolMetadata in the
> > > JoinGroupRequest
> > > >> and
> > > >> >> >> assign the partitions for consumers. In the JoinGroupResponse,
> > the
> > > >> >> >> ProtocolMetadata will be the global assignment of partitions.
> > > >> >> >> 2.4 On client side, after receiving the JoinGroupResponse,
> > > >> >> >> partitionAssignor.assignPartitions() will be invoked to return
> > the
> > > >> >> actual
> > > >> >> >> assignment. If the assignor is RangeAssignor or
> > > RoundRobinAssignor,
> > > >> they
> > > >> >> >> will parse the assignment from the ProtocolMetadata returned
> by
> > > >> >> >> coordinator.
> > > >> >> >>
> > > >> >> >> This approach has a few merits:
> > > >> >> >> 1. Does not change the proposed binary protocol, which is
> still
> > > >> general.
> > > >> >> >> 2. The majority of the consumers will not suffer from
> > inconsistent
> > > >> >> metadata
> > > >> >> >> / split brain / exploding subscription set propagation. This
> is
> > > >> >> >> specifically to deal with the issue that the current proposal
> > > caters
> > > >> to
> > > >> >> a
> > > >> >> >> 20% use-case while adversely impacting the more common 80%
> > > use-cases.
> > > >> >> >> 3. Easy to implement. The only thing needed is implement a
> > > >> partitioner
> > > >> >> >> class. For most users, the default range and roundrobin
> > > partitioner
> > > >> are
> > > >> >> >> good enough.
> > > >> >> >>
> > > >> >> >> Thoughts?
> > > >> >> >>
> > > >> >> >> Thanks,
> > > >> >> >>
> > > >> >> >> Jiangjie (Becket) Qin
> > > >> >> >>
> > > >> >> >> On Tue, Aug 18, 2015 at 2:51 PM, Jason Gustafson
> > > >> >> >> wrote:
> > > >> >> >>
> > > >> >> >> > Follow-up from the kip call:
> > > >> >> >> >
> > > >> >> >> > 1. Onur brought up the question of whether this protocol
> > > provides
> > > >> >> enough
> > > >> >> >> > coordination capabilities to be generally useful in practice
> > (is
> > > >> that
> > > >> >> >> > accurate, Onur?). If it doesn't, then each use case would
> > > probably
> > > >> >> need a
> > > >> >> >> > dependence on zookeeper anyway, and we haven't really gained
> > > >> anything.
> > > >> >> >> The
> > > >> >> >> > group membership provided by this protocol is a useful
> > primitive
> > > >> for
> > > >> >> >> > coordination, but it's limited in the sense that everything
> > > shared
> > > >> >> among
> > > >> >> >> > the group has to be communicated at the time the group is
> > > created.
> > > >> If
> > > >> >> any
> > > >> >> >> > shared data changes, then the only way the group can ensure
> > > >> agreement
> > > >> >> is
> > > >> >> >> to
> > > >> >> >> > force a rebalance. This is expensive since all members must
> > > stall
> > > >> >> while
> > > >> >> >> the
> > > >> >> >> > rebalancing takes place. As we have also seen, there is a
> > > practical
> > > >> >> limit
> > > >> >> >> > on the amount of metadata that can be sent through this
> > protocol
> > > >> when
> > > >> >> >> > groups get a little larger. This protocol is therefore not
> > > >> suitable to
> > > >> >> >> > cases which require frequent communication or which require
> a
> > > large
> > > >> >> >> amount
> > > >> >> >> > of data to be communicated. For the use cases listed on the
> > > wiki,
> > > >> >> neither
> > > >> >> >> > of these appear to be an issue, but there may be other
> > > limitations
> > > >> >> which
> > > >> >> >> > would limit reuse of the protocol. Perhaps it would be
> > > sufficient
> > > >> to
> > > >> >> >> sketch
> > > >> >> >> > how these cases might work?
> > > >> >> >> >
> > > >> >> >> > 2. We talked a little bit about the issue of metadata churn.
> > > Becket
> > > >> >> >> brought
> > > >> >> >> > up the interesting point that not only do we depend on topic
> > > >> metadata
> > > >> >> >> > changing relatively infrequently, but we also expect timely
> > > >> agreement
> > > >> >> >> among
> > > >> >> >> > the brokers on what that metadata is. To resolve this, we
> can
> > > have
> > > >> the
> > > >> >> >> > consumers fetch metadata from the coordinator. We still
> depend
> > > on
> > > >> >> topic
> > > >> >> >> > metadata not changing frequently, but this should resolve
> any
> > > >> >> >> disagreement
> > > >> >> >> > among the brokers themselves. In fact, since we expect that
> > > >> >> disagreement
> > > >> >> >> is
> > > >> >> >> > relatively rare, we can have the consumers fetch from the
> > > >> coordinator
> > > >> >> >> only
> > > >> >> >> > when when a disagreement occurs. The nice thing about this
> > > >> proposal is
> > > >> >> >> that
> > > >> >> >> > it doesn't affect the join group semantics, so the
> coordinator
> > > >> would
> > > >> >> >> remain
> > > >> >> >> > oblivious to the metadata used by the group for agreement.
> > > Also, if
> > > >> >> >> > metadata churn becomes an issue, it might be possible to
> have
> > > the
> > > >> >> >> > coordinator provide a snapshot for the group to ensure that
> a
> > > >> >> generation
> > > >> >> >> > would be able to reach agreement (this would probably
> require
> > > >> adding
> > > >> >> >> > groupId/generation to the metadata request).
> > > >> >> >> >
> > > >> >> >> > 3. We talked briefly about support for multiple protocols in
> > the
> > > >> join
> > > >> >> >> group
> > > >> >> >> > request in order to allow changing the assignment strategy
> > > without
> > > >> >> >> > downtime. I think it's a little doubtful that this would get
> > > much
> > > >> use
> > > >> >> in
> > > >> >> >> > practice, but I agree it's a nice option to have on the
> table.
> > > An
> > > >> >> >> > alternative, for the sake of argument, is to have each
> member
> > > >> provide
> > > >> >> >> only
> > > >> >> >> > one version of the protocol, and to let the coordinator
> choose
> > > the
> > > >> >> >> protocol
> > > >> >> >> > with the largest number of supporters. All members which
> can't
> > > >> support
> > > >> >> >> the
> > > >> >> >> > selected protocol would be kicked out of the group. The
> > drawback
> > > >> in a
> > > >> >> >> > rolling upgrade is that the total capacity of the group
> would
> > be
> > > >> >> >> > momentarily halved. It would also be a little tricky to
> handle
> > > the
> > > >> >> case
> > > >> >> >> of
> > > >> >> >> > retrying when a consumer is kicked out of the group. We
> > wouldn't
> > > >> want
> > > >> >> it
> > > >> >> >> to
> > > >> >> >> > be able to effect a rebalance, for example, if it would just
> > be
> > > >> kicked
> > > >> >> >> out
> > > >> >> >> > again. That would probably complicate the group management
> > > logic on
> > > >> >> the
> > > >> >> >> > coordinator.
> > > >> >> >> >
> > > >> >> >> >
> > > >> >> >> > Thanks,
> > > >> >> >> > Jason
> > > >> >> >> >
> > > >> >> >> >
> > > >> >> >> > On Tue, Aug 18, 2015 at 11:16 AM, Jiangjie Qin
> > > >> >> > >> >
> > > >> >> >> > wrote:
> > > >> >> >> >
> > > >> >> >> > > Jun,
> > > >> >> >> > >
> > > >> >> >> > > Yes, I agree. If the metadata can be synced quickly there
> > > should
> > > >> >> not be
> > > >> >> >> > an
> > > >> >> >> > > issue. It just occurred to me that there is a proposal to
> > > allow
> > > >> >> >> consuming
> > > >> >> >> > > from followers in ISR, that could potentially cause more
> > > frequent
> > > >> >> >> > metadata
> > > >> >> >> > > change for consumers. Would that be an issue?
> > > >> >> >> > >
> > > >> >> >> > > Thanks,
> > > >> >> >> > >
> > > >> >> >> > > Jiangjie (Becket) Qin
> > > >> >> >> > >
> > > >> >> >> > > On Tue, Aug 18, 2015 at 10:22 AM, Jason Gustafson <
> > > >> >> jason@confluent.io>
> > > >> >> >> > > wrote:
> > > >> >> >> > >
> > > >> >> >> > > > Hi Jun,
> > > >> >> >> > > >
> > > >> >> >> > > > Answers below:
> > > >> >> >> > > >
> > > >> >> >> > > > 1. When there are multiple common protocols in the
> > > >> >> JoinGroupRequest,
> > > >> >> >> > > which
> > > >> >> >> > > > one would the coordinator pick?
> > > >> >> >> > > >
> > > >> >> >> > > > I was intending to use the list to indicate preference.
> If
> > > all
> > > >> >> group
> > > >> >> >> > > > members support protocols ["A", "B"] in that order, then
> > we
> > > >> will
> > > >> >> >> choose
> > > >> >> >> > > > "A." If some support ["B", "A"], then we would either
> > choose
> > > >> >> based on
> > > >> >> >> > > > respective counts or just randomly. The main use case of
> > > >> >> supporting
> > > >> >> >> the
> > > >> >> >> > > > list is for rolling upgrades when a change is made to
> the
> > > >> >> assignment
> > > >> >> >> > > > strategy. In that case, the new assignment strategy
> would
> > be
> > > >> >> listed
> > > >> >> >> > first
> > > >> >> >> > > > in the upgraded client. I think it's debatable whether
> > this
> > > >> >> feature
> > > >> >> >> > would
> > > >> >> >> > > > get much use in practice, so we might consider dropping
> > it.
> > > >> >> >> > > >
> > > >> >> >> > > > 2. If the protocols don't agree, the group construction
> > > fails.
> > > >> >> What
> > > >> >> >> > > exactly
> > > >> >> >> > > > does it mean? Do we send an error in every
> > JoinGroupResponse
> > > >> and
> > > >> >> >> remove
> > > >> >> >> > > all
> > > >> >> >> > > > members in the group in the coordinator?
> > > >> >> >> > > >
> > > >> >> >> > > > Yes, that is right. It would be handled similarly to
> > > >> inconsistent
> > > >> >> >> > > > assignment strategies in the current protocol. The
> > > coordinator
> > > >> >> >> returns
> > > >> >> >> > an
> > > >> >> >> > > > error in each join group response, and the client
> > propagates
> > > >> the
> > > >> >> >> error
> > > >> >> >> > to
> > > >> >> >> > > > the user.
> > > >> >> >> > > >
> > > >> >> >> > > > 3. Consumer embedded protocol: The proposal has two
> > > different
> > > >> >> formats
> > > >> >> >> > of
> > > >> >> >> > > > subscription depending on whether wildcards are used or
> > not.
> > > >> This
> > > >> >> >> > seems a
> > > >> >> >> > > > bit complicated. Would it be better to always use the
> > > metadata
> > > >> >> hash?
> > > >> >> >> > The
> > > >> >> >> > > > clients know the subscribed topics already. This way,
> the
> > > >> client
> > > >> >> code
> > > >> >> >> > > > behaves the same whether wildcards are used or not.
> > > >> >> >> > > >
> > > >> >> >> > > > Yeah, I think this is possible (Neha also suggested
> it). I
> > > >> haven't
> > > >> >> >> > > updated
> > > >> >> >> > > > the wiki yet, but the patch I started working on uses
> only
> > > the
> > > >> >> >> metadata
> > > >> >> >> > > > hash. In the case that an explicit topic list is
> provided,
> > > the
> > > >> >> hash
> > > >> >> >> > just
> > > >> >> >> > > > covers the metadata for those topics.
> > > >> >> >> > > >
> > > >> >> >> > > >
> > > >> >> >> > > > Thanks,
> > > >> >> >> > > > Jason
> > > >> >> >> > > >
> > > >> >> >> > > >
> > > >> >> >> > > >
> > > >> >> >> > > > On Tue, Aug 18, 2015 at 10:06 AM, Jun Rao
> > > >> >> wrote:
> > > >> >> >> > > >
> > > >> >> >> > > > > Jason,
> > > >> >> >> > > > >
> > > >> >> >> > > > > Thanks for the writeup. A few comments below.
> > > >> >> >> > > > >
> > > >> >> >> > > > > 1. When there are multiple common protocols in the
> > > >> >> >> JoinGroupRequest,
> > > >> >> >> > > > which
> > > >> >> >> > > > > one would the coordinator pick?
> > > >> >> >> > > > > 2. If the protocols don't agree, the group
> construction
> > > >> fails.
> > > >> >> What
> > > >> >> >> > > > exactly
> > > >> >> >> > > > > does it mean? Do we send an error in every
> > > JoinGroupResponse
> > > >> and
> > > >> >> >> > remove
> > > >> >> >> > > > all
> > > >> >> >> > > > > members in the group in the coordinator?
> > > >> >> >> > > > > 3. Consumer embedded protocol: The proposal has two
> > > different
> > > >> >> >> formats
> > > >> >> >> > > of
> > > >> >> >> > > > > subscription depending on whether wildcards are used
> or
> > > not.
> > > >> >> This
> > > >> >> >> > > seems a
> > > >> >> >> > > > > bit complicated. Would it be better to always use the
> > > >> metadata
> > > >> >> >> hash?
> > > >> >> >> > > The
> > > >> >> >> > > > > clients know the subscribed topics already. This way,
> > the
> > > >> client
> > > >> >> >> code
> > > >> >> >> > > > > behaves the same whether wildcards are used or not.
> > > >> >> >> > > > >
> > > >> >> >> > > > > Jiangjie,
> > > >> >> >> > > > >
> > > >> >> >> > > > > With respect to rebalance churns due to topics being
> > > >> >> >> created/deleted.
> > > >> >> >> > > > With
> > > >> >> >> > > > > the new consumer, the rebalance can probably settle
> > within
> > > >> 200ms
> > > >> >> >> when
> > > >> >> >> > > > there
> > > >> >> >> > > > > is a topic change. So, as long as we are not changing
> > > topic
> > > >> more
> > > >> >> >> > than 5
> > > >> >> >> > > > > times per sec, there shouldn't be constant churns,
> > right?
> > > >> >> >> > > > >
> > > >> >> >> > > > > Thanks,
> > > >> >> >> > > > >
> > > >> >> >> > > > > Jun
> > > >> >> >> > > > >
> > > >> >> >> > > > >
> > > >> >> >> > > > >
> > > >> >> >> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <
> > > >> >> >> jason@confluent.io
> > > >> >> >> > >
> > > >> >> >> > > > > wrote:
> > > >> >> >> > > > >
> > > >> >> >> > > > > > Hi Kafka Devs,
> > > >> >> >> > > > > >
> > > >> >> >> > > > > > One of the nagging issues in the current design of
> the
> > > new
> > > >> >> >> consumer
> > > >> >> >> > > has
> > > >> >> >> > > > > > been the need to support a variety of assignment
> > > >> strategies.
> > > >> >> >> We've
> > > >> >> >> > > > > > encountered this in particular in the design of
> > copycat
> > > and
> > > >> >> the
> > > >> >> >> > > > > processing
> > > >> >> >> > > > > > framework (KIP-28). From what I understand, Samza
> also
> > > has
> > > >> a
> > > >> >> >> number
> > > >> >> >> > > of
> > > >> >> >> > > > > use
> > > >> >> >> > > > > > cases with custom assignment needs. The new consumer
> > > >> protocol
> > > >> >> >> > > supports
> > > >> >> >> > > > > new
> > > >> >> >> > > > > > assignment strategies by hooking them into the
> broker.
> > > For
> > > >> >> many
> > > >> >> >> > > > > > environments, this is a major pain and in some
> cases,
> > a
> > > >> >> >> > non-starter.
> > > >> >> >> > > It
> > > >> >> >> > > > > > also challenges the validation that the coordinator
> > can
> > > >> >> provide.
> > > >> >> >> > For
> > > >> >> >> > > > > > example, some assignment strategies call for
> > partitions
> > > to
> > > >> be
> > > >> >> >> > > assigned
> > > >> >> >> > > > > > multiple times, which means that the coordinator can
> > > only
> > > >> >> check
> > > >> >> >> > that
> > > >> >> >> > > > > > partitions have been assigned at least once.
> > > >> >> >> > > > > >
> > > >> >> >> > > > > > To solve these issues, we'd like to propose moving
> > > >> assignment
> > > >> >> to
> > > >> >> >> > the
> > > >> >> >> > > > > > client. I've written a wiki which outlines some
> > protocol
> > > >> >> changes
> > > >> >> >> to
> > > >> >> >> > > > > achieve
> > > >> >> >> > > > > > this:
> > > >> >> >> > > > > >
> > > >> >> >> > > > > >
> > > >> >> >> > > > >
> > > >> >> >> > > >
> > > >> >> >> > >
> > > >> >> >> >
> > > >> >> >>
> > > >> >>
> > > >>
> > >
> >
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> > > >> >> >> > > > > > .
> > > >> >> >> > > > > > To summarize briefly, instead of the coordinator
> > > assigning
> > > >> the
> > > >> >> >> > > > partitions
> > > >> >> >> > > > > > itself, all subscriptions are forwarded to each
> member
> > > of
> > > >> the
> > > >> >> >> group
> > > >> >> >> > > > which
> > > >> >> >> > > > > > then decides independently which partitions it
> should
> > > >> consume.
> > > >> >> >> The
> > > >> >> >> > > > > protocol
> > > >> >> >> > > > > > provides a mechanism for the coordinator to validate
> > > that
> > > >> all
> > > >> >> >> > > consumers
> > > >> >> >> > > > > use
> > > >> >> >> > > > > > the same assignment strategy, but it does not ensure
> > > that
> > > >> the
> > > >> >> >> > > resulting
> > > >> >> >> > > > > > assignment is "correct." This provides a powerful
> > > >> capability
> > > >> >> for
> > > >> >> >> > > users
> > > >> >> >> > > > to
> > > >> >> >> > > > > > control the full data flow on the client side. They
> > > control
> > > >> >> how
> > > >> >> >> > data
> > > >> >> >> > > is
> > > >> >> >> > > > > > written to partitions through the Partitioner
> > interface
> > > and
> > > >> >> they
> > > >> >> >> > > > control
> > > >> >> >> > > > > > how data is consumed through the assignment
> strategy,
> > > all
> > > >> >> without
> > > >> >> >> > > > > touching
> > > >> >> >> > > > > > the server.
> > > >> >> >> > > > > >
> > > >> >> >> > > > > > Of course nothing comes for free. In particular,
> this
> > > >> change
> > > >> >> >> > removes
> > > >> >> >> > > > the
> > > >> >> >> > > > > > ability of the coordinator to validate that commits
> > are
> > > >> made
> > > >> >> by
> > > >> >> >> > > > consumers
> > > >> >> >> > > > > > who were assigned the respective partition. This
> might
> > > not
> > > >> be
> > > >> >> too
> > > >> >> >> > bad
> > > >> >> >> > > > > since
> > > >> >> >> > > > > > we retain the ability to validate the generation id,
> > > but it
> > > >> >> is a
> > > >> >> >> > > > > potential
> > > >> >> >> > > > > > concern. We have considered alternative protocols
> > which
> > > >> add a
> > > >> >> >> > second
> > > >> >> >> > > > > > round-trip to the protocol in order to give the
> > > coordinator
> > > >> >> the
> > > >> >> >> > > ability
> > > >> >> >> > > > > to
> > > >> >> >> > > > > > confirm the assignment. As mentioned above, the
> > > >> coordinator is
> > > >> >> >> > > somewhat
> > > >> >> >> > > > > > limited in what it can actually validate, but this
> > would
> > > >> >> return
> > > >> >> >> its
> > > >> >> >> > > > > ability
> > > >> >> >> > > > > > to validate commits. The tradeoff is that it
> increases
> > > the
> > > >> >> >> > protocol's
> > > >> >> >> > > > > > complexity which means more ways for the protocol to
> > > fail
> > > >> and
> > > >> >> >> > > > > consequently
> > > >> >> >> > > > > > more edge cases in the code.
> > > >> >> >> > > > > >
> > > >> >> >> > > > > > It also misses an opportunity to generalize the
> group
> > > >> >> membership
> > > >> >> >> > > > protocol
> > > >> >> >> > > > > > for additional use cases. In fact, after you've gone
> > to
> > > the
> > > >> >> >> trouble
> > > >> >> >> > > of
> > > >> >> >> > > > > > moving assignment to the client, the main thing that
> > is
> > > >> left
> > > >> >> in
> > > >> >> >> > this
> > > >> >> >> > > > > > protocol is basically a general group management
> > > >> capability.
> > > >> >> This
> > > >> >> >> > is
> > > >> >> >> > > > > > exactly what is needed for a few cases that are
> > > currently
> > > >> >> under
> > > >> >> >> > > > > discussion
> > > >> >> >> > > > > > (e.g. copycat or single-writer producer). We've
> taken
> > > this
> > > >> >> >> further
> > > >> >> >> > > step
> > > >> >> >> > > > > in
> > > >> >> >> > > > > > the proposal and attempted to envision what that
> > general
> > > >> >> protocol
> > > >> >> >> > > might
> > > >> >> >> > > > > > look like and how it could be used both by the
> > consumer
> > > and
> > > >> >> for
> > > >> >> >> > some
> > > >> >> >> > > of
> > > >> >> >> > > > > > these other cases.
> > > >> >> >> > > > > >
> > > >> >> >> > > > > > Anyway, since time is running out on the new
> consumer,
> > > we
> > > >> have
> > > >> >> >> > > perhaps
> > > >> >> >> > > > > one
> > > >> >> >> > > > > > last chance to consider a significant change in the
> > > >> protocol
> > > >> >> like
> > > >> >> >> > > this,
> > > >> >> >> > > > > so
> > > >> >> >> > > > > > have a look at the wiki and share your thoughts.
> I've
> > no
> > > >> doubt
> > > >> >> >> that
> > > >> >> >> > > > some
> > > >> >> >> > > > > > ideas seem clearer in my mind than they do on paper,
> > so
> > > ask
> > > >> >> >> > questions
> > > >> >> >> > > > if
> > > >> >> >> > > > > > there is any confusion.
> > > >> >> >> > > > > >
> > > >> >> >> > > > > > Thanks!
> > > >> >> >> > > > > > Jason
> > > >> >> >> > > > > >
> > > >> >> >> > > > >
> > > >> >> >> > > >
> > > >> >> >> > >
> > > >> >> >> >
> > > >> >> >>
> > > >> >> >
> > > >> >> >
> > > >> >> >
> > > >> >> > --
> > > >> >> > Thanks,
> > > >> >> > Neha
> > > >> >>
> > > >>
> > >
> >
>
>
>
> --
> Thanks,
> Ewen
>

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Ewen Cheslack-Postava <ew...@confluent.io>.
@Onur - I think you reviewed the KAFKA-2464 patch in some detail. wrt the
specific problem you raised about using largest # of partitions, you're
right, with the updated proposal this isn't possible because we only send a
hash of the metadata in order to avoid the overhead of per-member metadata
being transmitted back to members in the join group response.

However, the KAKFA-2464 patch addresses this by avoiding inconsistencies as
much as possible by preferring the coordinator for metadata fetches when it
detects inconsistencies. If metadata is changing fast enough, this can
still result in another round of inconsistency. However, note that this
only applies to metadata that would be included in an subscription (i.e.,
if quickly created/deleted topics were excluded from mirror maker
consumers, those consumers would not be affected by those metadata changes
since the hash is computed based on the topics included in the
subscription). Additionally, it seems based on Becket's numbers that the
frequency that you *might* hit this is very small and the duration of the
delay in getting the group to reconverge should be 2 rounds of heartbeats,
or 6 seconds based on current defaults.

@Becket - these numbers are *really* useful, thanks for including them. The
average topic name length is actually quite useful it sorting out the
protocol overhead.

1. I think the only reason this is a question is because of the metadata?
Otherwise we always have the standard heartbeat cycle, which is currently
set at 3 seconds. If metadata mismatches, all clients need to refresh.
Because of concerns of inconsistency, the patch for KAFKA-2464 has all
clients in the group hit the coordinator to achieve consistency (only after
they detect inconsistency, so normal case should be spread across brokers).
I'm actually not convinced this is a good idea since it centralizes all
metadata lookups for the group to one host, which seems risky. But it does
guarantee consistency as long as the metadata doesn't change in that
window, and any member that can't fetch metadata should just drop out of
the group anyway. Your numbers seem to suggest it's unlikely to be *that*
unstable in that window. It seems the bad case is that it takes 9 seconds
rather than 6 seconds to converge. And those numbers confirm previous
arguments that the metadata changes slowly enough that a temporary
inconsistency can be resolved very quickly.
2. Rolling bounces are pretty clean regardless of whether assignment is
server- or client-side. We're following the same basic process either way.
In the normal case, processes restart cleanly and upon start, they
immediately try to join the group. There are two cases. If you're the
*first* node to restart, you'll trigger a join group and everyone will need
to rejoin at their next heartbeat. It'll take as long as the heartbeat
interval. If you're not the first node, then there's probably another node
that was bounced that's already triggered the next generation. In that case
you're just waiting to join the next generation anyway, and you'll probably
be done in the next 3 seconds (again, based on current intervals). I think
the major question here is how you schedule the rolling bounce -- if you do
too quickly, you might have a long period where lots of nodes aren't doing
any real work because there's always join groups in progress, which
requires everyone stopping, committing, then starting again. However, this
is true with any version of the current protocol -- it has nothing to do
with client side partition assignment.
Note that this is clearly affected by the proposal for a LeaveGroup
message. Rolling bounce is a case where you might not want to trigger a
LeaveGroup because you actually expect to restart and rejoin the group
immediately. This is a good argument for not using TCP disconnect as a
LeaveGroup signal.
3. I think this is addressed in the previous two comments. Maybe one thing
to address again is that metadata hashes can be based only on topics
matching subscriptions, so any changes in, e.g., test topics that do not
affect a consumer groups subscriptions should have 0 effect. They never
trigger any join groups, never affect membership, etc. Re: actual sync, I'd
be curious if defaulting to the coordinator to ensure consistency has any
problems that you can think of? It's not strictly a guarantee of
consistency since the metadata can change between requests from different
clients, but practically speaking, I don't see a case where metadata would
change so quickly and so consistently that we'd run into problems.

-Ewen



On Fri, Aug 28, 2015 at 9:32 PM, Jiangjie Qin <jq...@linkedin.com.invalid>
wrote:

> Hi Neha,
>
> Following are some numbers we have in the pipeline. It would be very
> helpful to see how it goes with the proposed protocol. We will try to do
> some tests with the current patch as well. Please also let us know if you
> want further information.
>
> 32 brokers, 1Gbps NIC
> 547 topics
> 27 chars average topic name length
> 2-3 consumers for each topic
>
> Four 26-node mirror maker instances (Four different consumer groups). Each
> node has 4 consumers. (Each mirror maker instance has 104 consumers)
> We are actually using selective copy, so we have a big whitelist for each
> mirror maker, copying about 100 topics (We expect it to grow to a couple of
> hundreds).
> The mirror makers are co-located with target cluster, so the consumer
> traffic go through the WAN.
>
> We have 5 to 6 wildcard consumers consuming from all the topics.
>
> The topic creation frequency is not high now, roughly about 1 / day.
>
> The scenarios we are interested in are:
> 1. The time for one round of rebalance.
> 2. The time for a rolling bounce of mirror maker.
> 3. For wildcard topic, does metadata sync up cause problem.
>
> Thanks,
>
> Jiangjie (Becket) Qin
>
>
> On Fri, Aug 28, 2015 at 1:24 PM, Joel Koshy <jj...@gmail.com> wrote:
>
> > Another use-case I was thinking of was something like rack-aware
> > assignment of partitions to clients. This would require some
> > additional topic metadata to be propagated to and from the coordinator
> > and you would need some way to resolve conflicts for such strategies.
> > I think that could be addressed by attaching a generation id to the
> > metadata and use that (i.e., pick the highest) in order to resolve
> > conflicts without another round of join-group requests.
> >
> > Likewise, without delete/recreate, partition counts are a sort of
> > generation id since they are non-decreasing. If we need to account for
> > delete/recreate that could perhaps be addressed by an explicit
> > (per-topic) generation id attached to each topic in the metadata blob.
> > Does that make sense? I think that covers my concerns wrt the
> > split-brain issues.
> >
> > I'm still a bit wary of the n^2*m sized rebroadcast of all the
> > metadata - mainly because for various reasons at LinkedIn, we are
> > actually using large explicit whitelists (and not wildcards) in
> > several of our mirroring pipelines. At this point I feel that is a
> > reasonable cost to pay for having all the logic in one place (i.e.,
> > client side) but I would like to think a bit more on that.
> >
> > Joel
> >
> >
> > On Fri, Aug 28, 2015 at 1:02 PM, Onur Karaman
> > <ok...@linkedin.com.invalid> wrote:
> > > From what I understand, the "largest number of partitions" trick is
> based
> > > on the assumption that topics can only expand their partitions. What
> > > happens when a topic gets deleted and recreated? This breaks that
> > > assumption.
> > >
> > > On Fri, Aug 28, 2015 at 6:33 AM, Neha Narkhede <ne...@confluent.io>
> > wrote:
> > >
> > >> Thanks for re-reviewing Joel.
> > >>
> > >>
> > >>
> > >>
> > >>
> > >>
> > >> On Fri, Aug 28, 2015 at 2:51 AM -0700, "Joel Koshy" <
> > jjkoshy.w@gmail.com>
> > >> wrote:
> > >>
> > >>
> > >>
> > >>
> > >>
> > >>
> > >>
> > >>
> > >>
> > >>
> > >> > I think we think this proposal addresses 100% of the split brain
> > issues
> > >> > ever seen in the ZK-based protocol, but I think you think there are
> > still
> > >> > issues. Can you explain what your thinking of and when you think it
> > would
> > >> > happen? I want to make sure you aren't assuming
> > client-side=>split-brain
> > >> > since I think that is totally not the case.
> > >>
> > >> Yes I had concluded that client-side assignment would still result in
> > >> split-brain wrt partition counts, but I overlooked a key sentence in
> > >> the wiki - i.e., that the assignment algorithm for consumers can just
> > >> use the largest number of partitions for each topic reported by any of
> > >> the consumers. i.e., I assumed that consumers would just fail
> > >> rebalance if the partition counts were inconsistent but that is not
> > >> the case since this conflict can be easily resolved as described
> > >> without further join-group requests. Sorry about that. There is still
> > >> the issue of the coordinator having to send back n*m worth of
> > >> metadata, but that was not my biggest concern. I'll look over it again
> > >> and reply back tomorrow.
> > >>
> > >> Joel
> > >>
> > >> On Thu, Aug 27, 2015 at 2:55 PM, Jay Kreps  wrote:
> > >> > Hey Joel,
> > >> >
> > >> > I really don't think we should do both. There are pros and cons but
> we
> > >> > should make a decision and work on operationalizing one approach.
> > Much of
> > >> > really making something like this work is getting all the bugs out,
> > >> getting
> > >> > monitoring in place, getting rigorous system tests in place. Trying
> > to do
> > >> > those things twice with the same resources will just mean we do them
> > half
> > >> > as well. I also think this buys nothing from the user's point of
> > >> view--they
> > >> > want co-ordination that works correctly, the debate we are having is
> > >> purely
> > >> > a "how should we build that" debate. So this is really not the kind
> of
> > >> > thing we'd want to make pluggable and if we did that would just
> > >> complicate
> > >> > life for the user.
> > >> >
> > >> > I think we think this proposal addresses 100% of the split brain
> > issues
> > >> > ever seen in the ZK-based protocol, but I think you think there are
> > still
> > >> > issues. Can you explain what your thinking of and when you think it
> > would
> > >> > happen? I want to make sure you aren't assuming
> > client-side=>split-brain
> > >> > since I think that is totally not the case.
> > >> >
> > >> > With respect to "herd issues" I actually think all the proposals
> > address
> > >> > this by scaling the co-ordinator out to all nodes and making the
> > >> > co-ordination vastly cheaper. No proposal, of course, gets rid of
> the
> > >> fact
> > >> > that all clients rejoin at once when there is a membership change,
> but
> > >> that
> > >> > is kind of fundamental to the problem.
> > >> >
> > >> > -Jay
> > >> >
> > >> > On Thu, Aug 27, 2015 at 2:02 PM, Joel Koshy  wrote:
> > >> >
> > >> >> I actually feel these set of tests (whatever they may be) are
> > somewhat
> > >> >> irrelevant here. My main concern with the current client-side
> > proposal
> > >> >> (i.e., without Becket's follow-up suggestions) is that it makes a
> > >> >> significant compromise to the original charter of the new consumer
> -
> > >> >> i.e., reduce/eliminate herd and split brain problems in both group
> > >> >> management and partition assignment. I understand the need for
> > >> >> client-side partition assignment in some use cases (which we are
> also
> > >> >> interested in), but I also think we should make every effort to
> keep
> > >> >> full server-side coordination for the remaining (majority) of use
> > >> >> cases especially if it does not complicate the protocol. The
> proposed
> > >> >> changes do not complicate the protocol IMO - i.e., there is no
> > further
> > >> >> modification to the request/response formats beyond the current
> > >> >> client-side proposal. It only involves a trivial reinterpretation
> of
> > >> >> the content of the protocol metadata field.
> > >> >>
> > >> >> Joel
> > >> >>
> > >> >> On Wed, Aug 26, 2015 at 9:33 PM, Neha Narkhede  wrote:
> > >> >> > Hey Becket,
> > >> >> >
> > >> >> > In that case, the broker side partition assignment would be ideal
> > >> because
> > >> >> >> it avoids
> > >> >> >> issues like metadata inconsistency / split brain / exploding
> > >> >> subscription
> > >> >> >> set propagation.
> > >> >> >
> > >> >> >
> > >> >> > As per our previous discussions regarding each of those concerns
> > >> >> (referring
> > >> >> > to this email thread, KIP calls and JIRA comments), we are going
> to
> > >> run a
> > >> >> > set of tests using the LinkedIn deployment numbers that we will
> > wait
> > >> for
> > >> >> > you to share. The purpose is to see if those concerns are really
> > >> valid or
> > >> >> > not. I'd prefer to see that before making any more changes that
> > will
> > >> >> > complicate the protocol.
> > >> >> >
> > >> >> > On Wed, Aug 26, 2015 at 4:57 PM, Jiangjie Qin > >
> > >> >> > wrote:
> > >> >> >
> > >> >> >> Hi folks,
> > >> >> >>
> > >> >> >> After further discussion in LinkedIn, we found that while
> having a
> > >> more
> > >> >> >> general group management protocol is very useful, the vast
> > majority
> > >> of
> > >> >> the
> > >> >> >> clients will not use customized partition assignment strategy.
> In
> > >> that
> > >> >> >> case, the broker side partition assignment would be ideal
> because
> > it
> > >> >> avoids
> > >> >> >> issues like metadata inconsistency / split brain / exploding
> > >> >> subscription
> > >> >> >> set propagation.
> > >> >> >>
> > >> >> >> So we have the following proposal that satisfies the majority of
> > the
> > >> >> >> clients' needs without changing the currently proposed binary
> > >> protocol.
> > >> >> >> i.e., Continue to support broker-side assignment if the
> assignment
> > >> >> strategy
> > >> >> >> is recognized by the coordinator.
> > >> >> >>
> > >> >> >> 1. Keep the binary protocol as currently proposed.
> > >> >> >>
> > >> >> >> 2. Change the way we interpret ProtocolMetadata:
> > >> >> >> 2.1 On consumer side, change partition.assignment.strategy to
> > >> >> >> partition.assignor.class. Implement the something like the
> > following
> > >> >> >> PartitionAssignor Interface:
> > >> >> >>
> > >> >> >> public interface PartitionAssignor {
> > >> >> >>   List protocolTypes();
> > >> >> >>   byte[] protocolMetadata();
> > >> >> >>   // return the Topic->List map that are assigned to this
> > >> >> >> consumer.
> > >> >> >>   List assignPartitions(String protocolType, byte[]
> > >> >> >> responseProtocolMetadata);
> > >> >> >> }
> > >> >> >>
> > >> >> >> public abstract class AbstractPartitionAssignor implements
> > >> >> >> PartitionAssignor {
> > >> >> >>   protected final KafkaConsumer consumer;
> > >> >> >>   AbstractPartitionAssignor(KafkaConsumer consumer) {
> > >> >> >>     this.consumer = consumer;
> > >> >> >>   }
> > >> >> >> }
> > >> >> >>
> > >> >> >> 2.2 The ProtocolMetadata in JoinGroupRequest will be
> > >> >> >> partitionAssignor.protocolMetadata(). When
> > partition.assignor.class
> > >> is
> > >> >> >> "range" or "roundrobin", the ProtocolMetadata in
> JoinGroupRequest
> > >> will
> > >> >> be a
> > >> >> >> JSON subscription set. ("range", "roundrobin" will be reserved
> > >> words, we
> > >> >> >> can also consider reserving some Prefix such as "broker-" to be
> > more
> > >> >> clear)
> > >> >> >> 2.3 On broker side when ProtocolType is "range" or
> "roundroubin",
> > >> >> >> coordinator will parse the ProtocolMetadata in the
> > JoinGroupRequest
> > >> and
> > >> >> >> assign the partitions for consumers. In the JoinGroupResponse,
> the
> > >> >> >> ProtocolMetadata will be the global assignment of partitions.
> > >> >> >> 2.4 On client side, after receiving the JoinGroupResponse,
> > >> >> >> partitionAssignor.assignPartitions() will be invoked to return
> the
> > >> >> actual
> > >> >> >> assignment. If the assignor is RangeAssignor or
> > RoundRobinAssignor,
> > >> they
> > >> >> >> will parse the assignment from the ProtocolMetadata returned by
> > >> >> >> coordinator.
> > >> >> >>
> > >> >> >> This approach has a few merits:
> > >> >> >> 1. Does not change the proposed binary protocol, which is still
> > >> general.
> > >> >> >> 2. The majority of the consumers will not suffer from
> inconsistent
> > >> >> metadata
> > >> >> >> / split brain / exploding subscription set propagation. This is
> > >> >> >> specifically to deal with the issue that the current proposal
> > caters
> > >> to
> > >> >> a
> > >> >> >> 20% use-case while adversely impacting the more common 80%
> > use-cases.
> > >> >> >> 3. Easy to implement. The only thing needed is implement a
> > >> partitioner
> > >> >> >> class. For most users, the default range and roundrobin
> > partitioner
> > >> are
> > >> >> >> good enough.
> > >> >> >>
> > >> >> >> Thoughts?
> > >> >> >>
> > >> >> >> Thanks,
> > >> >> >>
> > >> >> >> Jiangjie (Becket) Qin
> > >> >> >>
> > >> >> >> On Tue, Aug 18, 2015 at 2:51 PM, Jason Gustafson
> > >> >> >> wrote:
> > >> >> >>
> > >> >> >> > Follow-up from the kip call:
> > >> >> >> >
> > >> >> >> > 1. Onur brought up the question of whether this protocol
> > provides
> > >> >> enough
> > >> >> >> > coordination capabilities to be generally useful in practice
> (is
> > >> that
> > >> >> >> > accurate, Onur?). If it doesn't, then each use case would
> > probably
> > >> >> need a
> > >> >> >> > dependence on zookeeper anyway, and we haven't really gained
> > >> anything.
> > >> >> >> The
> > >> >> >> > group membership provided by this protocol is a useful
> primitive
> > >> for
> > >> >> >> > coordination, but it's limited in the sense that everything
> > shared
> > >> >> among
> > >> >> >> > the group has to be communicated at the time the group is
> > created.
> > >> If
> > >> >> any
> > >> >> >> > shared data changes, then the only way the group can ensure
> > >> agreement
> > >> >> is
> > >> >> >> to
> > >> >> >> > force a rebalance. This is expensive since all members must
> > stall
> > >> >> while
> > >> >> >> the
> > >> >> >> > rebalancing takes place. As we have also seen, there is a
> > practical
> > >> >> limit
> > >> >> >> > on the amount of metadata that can be sent through this
> protocol
> > >> when
> > >> >> >> > groups get a little larger. This protocol is therefore not
> > >> suitable to
> > >> >> >> > cases which require frequent communication or which require a
> > large
> > >> >> >> amount
> > >> >> >> > of data to be communicated. For the use cases listed on the
> > wiki,
> > >> >> neither
> > >> >> >> > of these appear to be an issue, but there may be other
> > limitations
> > >> >> which
> > >> >> >> > would limit reuse of the protocol. Perhaps it would be
> > sufficient
> > >> to
> > >> >> >> sketch
> > >> >> >> > how these cases might work?
> > >> >> >> >
> > >> >> >> > 2. We talked a little bit about the issue of metadata churn.
> > Becket
> > >> >> >> brought
> > >> >> >> > up the interesting point that not only do we depend on topic
> > >> metadata
> > >> >> >> > changing relatively infrequently, but we also expect timely
> > >> agreement
> > >> >> >> among
> > >> >> >> > the brokers on what that metadata is. To resolve this, we can
> > have
> > >> the
> > >> >> >> > consumers fetch metadata from the coordinator. We still depend
> > on
> > >> >> topic
> > >> >> >> > metadata not changing frequently, but this should resolve any
> > >> >> >> disagreement
> > >> >> >> > among the brokers themselves. In fact, since we expect that
> > >> >> disagreement
> > >> >> >> is
> > >> >> >> > relatively rare, we can have the consumers fetch from the
> > >> coordinator
> > >> >> >> only
> > >> >> >> > when when a disagreement occurs. The nice thing about this
> > >> proposal is
> > >> >> >> that
> > >> >> >> > it doesn't affect the join group semantics, so the coordinator
> > >> would
> > >> >> >> remain
> > >> >> >> > oblivious to the metadata used by the group for agreement.
> > Also, if
> > >> >> >> > metadata churn becomes an issue, it might be possible to have
> > the
> > >> >> >> > coordinator provide a snapshot for the group to ensure that a
> > >> >> generation
> > >> >> >> > would be able to reach agreement (this would probably require
> > >> adding
> > >> >> >> > groupId/generation to the metadata request).
> > >> >> >> >
> > >> >> >> > 3. We talked briefly about support for multiple protocols in
> the
> > >> join
> > >> >> >> group
> > >> >> >> > request in order to allow changing the assignment strategy
> > without
> > >> >> >> > downtime. I think it's a little doubtful that this would get
> > much
> > >> use
> > >> >> in
> > >> >> >> > practice, but I agree it's a nice option to have on the table.
> > An
> > >> >> >> > alternative, for the sake of argument, is to have each member
> > >> provide
> > >> >> >> only
> > >> >> >> > one version of the protocol, and to let the coordinator choose
> > the
> > >> >> >> protocol
> > >> >> >> > with the largest number of supporters. All members which can't
> > >> support
> > >> >> >> the
> > >> >> >> > selected protocol would be kicked out of the group. The
> drawback
> > >> in a
> > >> >> >> > rolling upgrade is that the total capacity of the group would
> be
> > >> >> >> > momentarily halved. It would also be a little tricky to handle
> > the
> > >> >> case
> > >> >> >> of
> > >> >> >> > retrying when a consumer is kicked out of the group. We
> wouldn't
> > >> want
> > >> >> it
> > >> >> >> to
> > >> >> >> > be able to effect a rebalance, for example, if it would just
> be
> > >> kicked
> > >> >> >> out
> > >> >> >> > again. That would probably complicate the group management
> > logic on
> > >> >> the
> > >> >> >> > coordinator.
> > >> >> >> >
> > >> >> >> >
> > >> >> >> > Thanks,
> > >> >> >> > Jason
> > >> >> >> >
> > >> >> >> >
> > >> >> >> > On Tue, Aug 18, 2015 at 11:16 AM, Jiangjie Qin
> > >> >> > >> >
> > >> >> >> > wrote:
> > >> >> >> >
> > >> >> >> > > Jun,
> > >> >> >> > >
> > >> >> >> > > Yes, I agree. If the metadata can be synced quickly there
> > should
> > >> >> not be
> > >> >> >> > an
> > >> >> >> > > issue. It just occurred to me that there is a proposal to
> > allow
> > >> >> >> consuming
> > >> >> >> > > from followers in ISR, that could potentially cause more
> > frequent
> > >> >> >> > metadata
> > >> >> >> > > change for consumers. Would that be an issue?
> > >> >> >> > >
> > >> >> >> > > Thanks,
> > >> >> >> > >
> > >> >> >> > > Jiangjie (Becket) Qin
> > >> >> >> > >
> > >> >> >> > > On Tue, Aug 18, 2015 at 10:22 AM, Jason Gustafson <
> > >> >> jason@confluent.io>
> > >> >> >> > > wrote:
> > >> >> >> > >
> > >> >> >> > > > Hi Jun,
> > >> >> >> > > >
> > >> >> >> > > > Answers below:
> > >> >> >> > > >
> > >> >> >> > > > 1. When there are multiple common protocols in the
> > >> >> JoinGroupRequest,
> > >> >> >> > > which
> > >> >> >> > > > one would the coordinator pick?
> > >> >> >> > > >
> > >> >> >> > > > I was intending to use the list to indicate preference. If
> > all
> > >> >> group
> > >> >> >> > > > members support protocols ["A", "B"] in that order, then
> we
> > >> will
> > >> >> >> choose
> > >> >> >> > > > "A." If some support ["B", "A"], then we would either
> choose
> > >> >> based on
> > >> >> >> > > > respective counts or just randomly. The main use case of
> > >> >> supporting
> > >> >> >> the
> > >> >> >> > > > list is for rolling upgrades when a change is made to the
> > >> >> assignment
> > >> >> >> > > > strategy. In that case, the new assignment strategy would
> be
> > >> >> listed
> > >> >> >> > first
> > >> >> >> > > > in the upgraded client. I think it's debatable whether
> this
> > >> >> feature
> > >> >> >> > would
> > >> >> >> > > > get much use in practice, so we might consider dropping
> it.
> > >> >> >> > > >
> > >> >> >> > > > 2. If the protocols don't agree, the group construction
> > fails.
> > >> >> What
> > >> >> >> > > exactly
> > >> >> >> > > > does it mean? Do we send an error in every
> JoinGroupResponse
> > >> and
> > >> >> >> remove
> > >> >> >> > > all
> > >> >> >> > > > members in the group in the coordinator?
> > >> >> >> > > >
> > >> >> >> > > > Yes, that is right. It would be handled similarly to
> > >> inconsistent
> > >> >> >> > > > assignment strategies in the current protocol. The
> > coordinator
> > >> >> >> returns
> > >> >> >> > an
> > >> >> >> > > > error in each join group response, and the client
> propagates
> > >> the
> > >> >> >> error
> > >> >> >> > to
> > >> >> >> > > > the user.
> > >> >> >> > > >
> > >> >> >> > > > 3. Consumer embedded protocol: The proposal has two
> > different
> > >> >> formats
> > >> >> >> > of
> > >> >> >> > > > subscription depending on whether wildcards are used or
> not.
> > >> This
> > >> >> >> > seems a
> > >> >> >> > > > bit complicated. Would it be better to always use the
> > metadata
> > >> >> hash?
> > >> >> >> > The
> > >> >> >> > > > clients know the subscribed topics already. This way, the
> > >> client
> > >> >> code
> > >> >> >> > > > behaves the same whether wildcards are used or not.
> > >> >> >> > > >
> > >> >> >> > > > Yeah, I think this is possible (Neha also suggested it). I
> > >> haven't
> > >> >> >> > > updated
> > >> >> >> > > > the wiki yet, but the patch I started working on uses only
> > the
> > >> >> >> metadata
> > >> >> >> > > > hash. In the case that an explicit topic list is provided,
> > the
> > >> >> hash
> > >> >> >> > just
> > >> >> >> > > > covers the metadata for those topics.
> > >> >> >> > > >
> > >> >> >> > > >
> > >> >> >> > > > Thanks,
> > >> >> >> > > > Jason
> > >> >> >> > > >
> > >> >> >> > > >
> > >> >> >> > > >
> > >> >> >> > > > On Tue, Aug 18, 2015 at 10:06 AM, Jun Rao
> > >> >> wrote:
> > >> >> >> > > >
> > >> >> >> > > > > Jason,
> > >> >> >> > > > >
> > >> >> >> > > > > Thanks for the writeup. A few comments below.
> > >> >> >> > > > >
> > >> >> >> > > > > 1. When there are multiple common protocols in the
> > >> >> >> JoinGroupRequest,
> > >> >> >> > > > which
> > >> >> >> > > > > one would the coordinator pick?
> > >> >> >> > > > > 2. If the protocols don't agree, the group construction
> > >> fails.
> > >> >> What
> > >> >> >> > > > exactly
> > >> >> >> > > > > does it mean? Do we send an error in every
> > JoinGroupResponse
> > >> and
> > >> >> >> > remove
> > >> >> >> > > > all
> > >> >> >> > > > > members in the group in the coordinator?
> > >> >> >> > > > > 3. Consumer embedded protocol: The proposal has two
> > different
> > >> >> >> formats
> > >> >> >> > > of
> > >> >> >> > > > > subscription depending on whether wildcards are used or
> > not.
> > >> >> This
> > >> >> >> > > seems a
> > >> >> >> > > > > bit complicated. Would it be better to always use the
> > >> metadata
> > >> >> >> hash?
> > >> >> >> > > The
> > >> >> >> > > > > clients know the subscribed topics already. This way,
> the
> > >> client
> > >> >> >> code
> > >> >> >> > > > > behaves the same whether wildcards are used or not.
> > >> >> >> > > > >
> > >> >> >> > > > > Jiangjie,
> > >> >> >> > > > >
> > >> >> >> > > > > With respect to rebalance churns due to topics being
> > >> >> >> created/deleted.
> > >> >> >> > > > With
> > >> >> >> > > > > the new consumer, the rebalance can probably settle
> within
> > >> 200ms
> > >> >> >> when
> > >> >> >> > > > there
> > >> >> >> > > > > is a topic change. So, as long as we are not changing
> > topic
> > >> more
> > >> >> >> > than 5
> > >> >> >> > > > > times per sec, there shouldn't be constant churns,
> right?
> > >> >> >> > > > >
> > >> >> >> > > > > Thanks,
> > >> >> >> > > > >
> > >> >> >> > > > > Jun
> > >> >> >> > > > >
> > >> >> >> > > > >
> > >> >> >> > > > >
> > >> >> >> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <
> > >> >> >> jason@confluent.io
> > >> >> >> > >
> > >> >> >> > > > > wrote:
> > >> >> >> > > > >
> > >> >> >> > > > > > Hi Kafka Devs,
> > >> >> >> > > > > >
> > >> >> >> > > > > > One of the nagging issues in the current design of the
> > new
> > >> >> >> consumer
> > >> >> >> > > has
> > >> >> >> > > > > > been the need to support a variety of assignment
> > >> strategies.
> > >> >> >> We've
> > >> >> >> > > > > > encountered this in particular in the design of
> copycat
> > and
> > >> >> the
> > >> >> >> > > > > processing
> > >> >> >> > > > > > framework (KIP-28). From what I understand, Samza also
> > has
> > >> a
> > >> >> >> number
> > >> >> >> > > of
> > >> >> >> > > > > use
> > >> >> >> > > > > > cases with custom assignment needs. The new consumer
> > >> protocol
> > >> >> >> > > supports
> > >> >> >> > > > > new
> > >> >> >> > > > > > assignment strategies by hooking them into the broker.
> > For
> > >> >> many
> > >> >> >> > > > > > environments, this is a major pain and in some cases,
> a
> > >> >> >> > non-starter.
> > >> >> >> > > It
> > >> >> >> > > > > > also challenges the validation that the coordinator
> can
> > >> >> provide.
> > >> >> >> > For
> > >> >> >> > > > > > example, some assignment strategies call for
> partitions
> > to
> > >> be
> > >> >> >> > > assigned
> > >> >> >> > > > > > multiple times, which means that the coordinator can
> > only
> > >> >> check
> > >> >> >> > that
> > >> >> >> > > > > > partitions have been assigned at least once.
> > >> >> >> > > > > >
> > >> >> >> > > > > > To solve these issues, we'd like to propose moving
> > >> assignment
> > >> >> to
> > >> >> >> > the
> > >> >> >> > > > > > client. I've written a wiki which outlines some
> protocol
> > >> >> changes
> > >> >> >> to
> > >> >> >> > > > > achieve
> > >> >> >> > > > > > this:
> > >> >> >> > > > > >
> > >> >> >> > > > > >
> > >> >> >> > > > >
> > >> >> >> > > >
> > >> >> >> > >
> > >> >> >> >
> > >> >> >>
> > >> >>
> > >>
> >
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> > >> >> >> > > > > > .
> > >> >> >> > > > > > To summarize briefly, instead of the coordinator
> > assigning
> > >> the
> > >> >> >> > > > partitions
> > >> >> >> > > > > > itself, all subscriptions are forwarded to each member
> > of
> > >> the
> > >> >> >> group
> > >> >> >> > > > which
> > >> >> >> > > > > > then decides independently which partitions it should
> > >> consume.
> > >> >> >> The
> > >> >> >> > > > > protocol
> > >> >> >> > > > > > provides a mechanism for the coordinator to validate
> > that
> > >> all
> > >> >> >> > > consumers
> > >> >> >> > > > > use
> > >> >> >> > > > > > the same assignment strategy, but it does not ensure
> > that
> > >> the
> > >> >> >> > > resulting
> > >> >> >> > > > > > assignment is "correct." This provides a powerful
> > >> capability
> > >> >> for
> > >> >> >> > > users
> > >> >> >> > > > to
> > >> >> >> > > > > > control the full data flow on the client side. They
> > control
> > >> >> how
> > >> >> >> > data
> > >> >> >> > > is
> > >> >> >> > > > > > written to partitions through the Partitioner
> interface
> > and
> > >> >> they
> > >> >> >> > > > control
> > >> >> >> > > > > > how data is consumed through the assignment strategy,
> > all
> > >> >> without
> > >> >> >> > > > > touching
> > >> >> >> > > > > > the server.
> > >> >> >> > > > > >
> > >> >> >> > > > > > Of course nothing comes for free. In particular, this
> > >> change
> > >> >> >> > removes
> > >> >> >> > > > the
> > >> >> >> > > > > > ability of the coordinator to validate that commits
> are
> > >> made
> > >> >> by
> > >> >> >> > > > consumers
> > >> >> >> > > > > > who were assigned the respective partition. This might
> > not
> > >> be
> > >> >> too
> > >> >> >> > bad
> > >> >> >> > > > > since
> > >> >> >> > > > > > we retain the ability to validate the generation id,
> > but it
> > >> >> is a
> > >> >> >> > > > > potential
> > >> >> >> > > > > > concern. We have considered alternative protocols
> which
> > >> add a
> > >> >> >> > second
> > >> >> >> > > > > > round-trip to the protocol in order to give the
> > coordinator
> > >> >> the
> > >> >> >> > > ability
> > >> >> >> > > > > to
> > >> >> >> > > > > > confirm the assignment. As mentioned above, the
> > >> coordinator is
> > >> >> >> > > somewhat
> > >> >> >> > > > > > limited in what it can actually validate, but this
> would
> > >> >> return
> > >> >> >> its
> > >> >> >> > > > > ability
> > >> >> >> > > > > > to validate commits. The tradeoff is that it increases
> > the
> > >> >> >> > protocol's
> > >> >> >> > > > > > complexity which means more ways for the protocol to
> > fail
> > >> and
> > >> >> >> > > > > consequently
> > >> >> >> > > > > > more edge cases in the code.
> > >> >> >> > > > > >
> > >> >> >> > > > > > It also misses an opportunity to generalize the group
> > >> >> membership
> > >> >> >> > > > protocol
> > >> >> >> > > > > > for additional use cases. In fact, after you've gone
> to
> > the
> > >> >> >> trouble
> > >> >> >> > > of
> > >> >> >> > > > > > moving assignment to the client, the main thing that
> is
> > >> left
> > >> >> in
> > >> >> >> > this
> > >> >> >> > > > > > protocol is basically a general group management
> > >> capability.
> > >> >> This
> > >> >> >> > is
> > >> >> >> > > > > > exactly what is needed for a few cases that are
> > currently
> > >> >> under
> > >> >> >> > > > > discussion
> > >> >> >> > > > > > (e.g. copycat or single-writer producer). We've taken
> > this
> > >> >> >> further
> > >> >> >> > > step
> > >> >> >> > > > > in
> > >> >> >> > > > > > the proposal and attempted to envision what that
> general
> > >> >> protocol
> > >> >> >> > > might
> > >> >> >> > > > > > look like and how it could be used both by the
> consumer
> > and
> > >> >> for
> > >> >> >> > some
> > >> >> >> > > of
> > >> >> >> > > > > > these other cases.
> > >> >> >> > > > > >
> > >> >> >> > > > > > Anyway, since time is running out on the new consumer,
> > we
> > >> have
> > >> >> >> > > perhaps
> > >> >> >> > > > > one
> > >> >> >> > > > > > last chance to consider a significant change in the
> > >> protocol
> > >> >> like
> > >> >> >> > > this,
> > >> >> >> > > > > so
> > >> >> >> > > > > > have a look at the wiki and share your thoughts. I've
> no
> > >> doubt
> > >> >> >> that
> > >> >> >> > > > some
> > >> >> >> > > > > > ideas seem clearer in my mind than they do on paper,
> so
> > ask
> > >> >> >> > questions
> > >> >> >> > > > if
> > >> >> >> > > > > > there is any confusion.
> > >> >> >> > > > > >
> > >> >> >> > > > > > Thanks!
> > >> >> >> > > > > > Jason
> > >> >> >> > > > > >
> > >> >> >> > > > >
> > >> >> >> > > >
> > >> >> >> > >
> > >> >> >> >
> > >> >> >>
> > >> >> >
> > >> >> >
> > >> >> >
> > >> >> > --
> > >> >> > Thanks,
> > >> >> > Neha
> > >> >>
> > >>
> >
>



-- 
Thanks,
Ewen

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Jiangjie Qin <jq...@linkedin.com.INVALID>.
Sorry about the format... It seems apache mail list does not suppor table.
Please refer to the following sheet.

https://docs.google.com/spreadsheets/d/1eKlQC1Ty74qVrIDH9vk7S6hEs_eJAyOufFUZaIU-k28/edit?usp=sharing

Thanks,

Jiangjie (Becket) Qin

On Tue, Sep 1, 2015 at 1:01 PM, Aditya Auradkar <aa...@linkedin.com>
wrote:

> Hey -
>
> So what is remaining here? Becket did you send a followup email regarding
> the data volume. For some reason, I dont receive emails sent by you.
>
> Aditya
>
> On Mon, Aug 31, 2015 at 9:52 AM, Joel Koshy <jj...@gmail.com> wrote:
>
>> Thanks Becket - I think your follow-up email to the thread states our
>> concerns and positions clearly. I would really like to make sure we
>> are very clear and firm on the practical aspects of the changes they
>> are pushing for. We should continue to stay on top of this and make
>> sure they don't push in changes to the consumer in a hurry for 0.8.3
>> without due diligence.
>>
>> Joel
>>
>> On Sun, Aug 30, 2015 at 12:00 AM, Jiangjie Qin <jq...@linkedin.com> wrote:
>> > Hi Joel,
>> >
>> > I was trying to calculate the number but found it might be better to run
>> > some actual tests because of the following reasons:
>> > 1. cross-colo network bandwidth usage is not clear to me yet.
>> > 2. The coordinators of the four mirror maker consumer group may or may
>> not
>> > reside on the same brokers. So the impact would be different.
>> > 3. I am not sure about the network bandwidth usage of normal traffic on
>> > broker. i.e. how much bandwidth is actually available for consumer
>> > rebalance. Currently the outbound traffic on broker are not balanced.
>> >
>> > The above factors can impact the actual rebalance time significantly.
>> So I
>> > just put a quick reply to the mail thread with some actual numbers we
>> have
>> > and wanted to update the test result later. But I agree we should do it
>> > soon.
>> >
>> > Thanks,
>> >
>> >  Jiangjie (Becket) Qin
>> >
>> > On Sat, Aug 29, 2015 at 9:40 PM, Joel Koshy <jj...@gmail.com>
>> wrote:
>> >>
>> >> No - I thought we agreed we would calculate the exact bandwidth (bytes)
>> >> required for a rebalance, its duration and thus whether it makes sense
>> or
>> >> not. I.e that we would come up with exact numbers for the scenarios of
>> >> interest in the email that becket sent
>> >>
>> >>
>> >> On Saturday, August 29, 2015, Kartik Paramasivam
>> >> <kp...@linkedin.com> wrote:
>> >>>
>> >>> Isn't that what becket is also saying ?
>> >>>
>> >>> On Aug 28, 2015, at 10:12 PM, Joel Koshy <jj...@gmail.com> wrote:
>> >>>
>> >>> I thought we were going to run the numbers ourselves and tell them if
>> we
>> >>> are okay with it or not?
>> >>>
>> >>> ---------- Forwarded message ----------
>> >>> From: Jiangjie Qin <jq...@linkedin.com.invalid>
>> >>> Date: Friday, August 28, 2015
>> >>> Subject: [DISCUSS] Client-side Assignment for New Consumer
>> >>> To: dev@kafka.apache.org
>> >>>
>> >>>
>> >>> Hi Neha,
>> >>>
>> >>> Following are some numbers we have in the pipeline. It would be very
>> >>> helpful to see how it goes with the proposed protocol. We will try to
>> do
>> >>> some tests with the current patch as well. Please also let us know if
>> you
>> >>> want further information.
>> >>>
>> >>> 32 brokers, 1Gbps NIC
>> >>> 547 topics
>> >>> 27 chars average topic name length
>> >>> 2-3 consumers for each topic
>> >>>
>> >>> Four 26-node mirror maker instances (Four different consumer groups).
>> >>> Each
>> >>> node has 4 consumers. (Each mirror maker instance has 104 consumers)
>> >>> We are actually using selective copy, so we have a big whitelist for
>> each
>> >>> mirror maker, copying about 100 topics (We expect it to grow to a
>> couple
>> >>> of
>> >>> hundreds).
>> >>> The mirror makers are co-located with target cluster, so the consumer
>> >>> traffic go through the WAN.
>> >>>
>> >>> We have 5 to 6 wildcard consumers consuming from all the topics.
>> >>>
>> >>> The topic creation frequency is not high now, roughly about 1 / day.
>> >>>
>> >>> The scenarios we are interested in are:
>> >>> 1. The time for one round of rebalance.
>> >>> 2. The time for a rolling bounce of mirror maker.
>> >>> 3. For wildcard topic, does metadata sync up cause problem.
>> >>>
>> >>> Thanks,
>> >>>
>> >>> Jiangjie (Becket) Qin
>> >>>
>> >>>
>> >>> On Fri, Aug 28, 2015 at 1:24 PM, Joel Koshy <jj...@gmail.com>
>> wrote:
>> >>>
>> >>> > Another use-case I was thinking of was something like rack-aware
>> >>> > assignment of partitions to clients. This would require some
>> >>> > additional topic metadata to be propagated to and from the
>> coordinator
>> >>> > and you would need some way to resolve conflicts for such
>> strategies.
>> >>> > I think that could be addressed by attaching a generation id to the
>> >>> > metadata and use that (i.e., pick the highest) in order to resolve
>> >>> > conflicts without another round of join-group requests.
>> >>> >
>> >>> > Likewise, without delete/recreate, partition counts are a sort of
>> >>> > generation id since they are non-decreasing. If we need to account
>> for
>> >>> > delete/recreate that could perhaps be addressed by an explicit
>> >>> > (per-topic) generation id attached to each topic in the metadata
>> blob.
>> >>> > Does that make sense? I think that covers my concerns wrt the
>> >>> > split-brain issues.
>> >>> >
>> >>> > I'm still a bit wary of the n^2*m sized rebroadcast of all the
>> >>> > metadata - mainly because for various reasons at LinkedIn, we are
>> >>> > actually using large explicit whitelists (and not wildcards) in
>> >>> > several of our mirroring pipelines. At this point I feel that is a
>> >>> > reasonable cost to pay for having all the logic in one place (i.e.,
>> >>> > client side) but I would like to think a bit more on that.
>> >>> >
>> >>> > Joel
>> >>> >
>> >>> >
>> >>> > On Fri, Aug 28, 2015 at 1:02 PM, Onur Karaman
>> >>> > <ok...@linkedin.com.invalid> wrote:
>> >>> > > From what I understand, the "largest number of partitions" trick
>> is
>> >>> > > based
>> >>> > > on the assumption that topics can only expand their partitions.
>> What
>> >>> > > happens when a topic gets deleted and recreated? This breaks that
>> >>> > > assumption.
>> >>> > >
>> >>> > > On Fri, Aug 28, 2015 at 6:33 AM, Neha Narkhede <neha@confluent.io
>> >
>> >>> > wrote:
>> >>> > >
>> >>> > >> Thanks for re-reviewing Joel.
>> >>> > >>
>> >>> > >>
>> >>> > >>
>> >>> > >>
>> >>> > >>
>> >>> > >>
>> >>> > >> On Fri, Aug 28, 2015 at 2:51 AM -0700, "Joel Koshy" <
>> >>> > jjkoshy.w@gmail.com>
>> >>> > >> wrote:
>> >>> > >>
>> >>> > >>
>> >>> > >>
>> >>> > >>
>> >>> > >>
>> >>> > >>
>> >>> > >>
>> >>> > >>
>> >>> > >>
>> >>> > >>
>> >>> > >> > I think we think this proposal addresses 100% of the split
>> brain
>> >>> > issues
>> >>> > >> > ever seen in the ZK-based protocol, but I think you think there
>> >>> > >> > are
>> >>> > still
>> >>> > >> > issues. Can you explain what your thinking of and when you
>> think
>> >>> > >> > it
>> >>> > would
>> >>> > >> > happen? I want to make sure you aren't assuming
>> >>> > client-side=>split-brain
>> >>> > >> > since I think that is totally not the case.
>> >>> > >>
>> >>> > >> Yes I had concluded that client-side assignment would still
>> result
>> >>> > >> in
>> >>> > >> split-brain wrt partition counts, but I overlooked a key
>> sentence in
>> >>> > >> the wiki - i.e., that the assignment algorithm for consumers can
>> >>> > >> just
>> >>> > >> use the largest number of partitions for each topic reported by
>> any
>> >>> > >> of
>> >>> > >> the consumers. i.e., I assumed that consumers would just fail
>> >>> > >> rebalance if the partition counts were inconsistent but that is
>> not
>> >>> > >> the case since this conflict can be easily resolved as described
>> >>> > >> without further join-group requests. Sorry about that. There is
>> >>> > >> still
>> >>> > >> the issue of the coordinator having to send back n*m worth of
>> >>> > >> metadata, but that was not my biggest concern. I'll look over it
>> >>> > >> again
>> >>> > >> and reply back tomorrow.
>> >>> > >>
>> >>> > >> Joel
>> >>> > >>
>> >>> > >> On Thu, Aug 27, 2015 at 2:55 PM, Jay Kreps  wrote:
>> >>> > >> > Hey Joel,
>> >>> > >> >
>> >>> > >> > I really don't think we should do both. There are pros and cons
>> >>> > >> > but we
>> >>> > >> > should make a decision and work on operationalizing one
>> approach.
>> >>> > Much of
>> >>> > >> > really making something like this work is getting all the bugs
>> >>> > >> > out,
>> >>> > >> getting
>> >>> > >> > monitoring in place, getting rigorous system tests in place.
>> >>> > >> > Trying
>> >>> > to do
>> >>> > >> > those things twice with the same resources will just mean we do
>> >>> > >> > them
>> >>> > half
>> >>> > >> > as well. I also think this buys nothing from the user's point
>> of
>> >>> > >> view--they
>> >>> > >> > want co-ordination that works correctly, the debate we are
>> having
>> >>> > >> > is
>> >>> > >> purely
>> >>> > >> > a "how should we build that" debate. So this is really not the
>> >>> > >> > kind of
>> >>> > >> > thing we'd want to make pluggable and if we did that would just
>> >>> > >> complicate
>> >>> > >> > life for the user.
>> >>> > >> >
>> >>> > >> > I think we think this proposal addresses 100% of the split
>> brain
>> >>> > issues
>> >>> > >> > ever seen in the ZK-based protocol, but I think you think there
>> >>> > >> > are
>> >>> > still
>> >>> > >> > issues. Can you explain what your thinking of and when you
>> think
>> >>> > >> > it
>> >>> > would
>> >>> > >> > happen? I want to make sure you aren't assuming
>> >>> > client-side=>split-brain
>> >>> > >> > since I think that is totally not the case.
>> >>> > >> >
>> >>> > >> > With respect to "herd issues" I actually think all the
>> proposals
>> >>> > address
>> >>> > >> > this by scaling the co-ordinator out to all nodes and making
>> the
>> >>> > >> > co-ordination vastly cheaper. No proposal, of course, gets rid
>> of
>> >>> > >> > the
>> >>> > >> fact
>> >>> > >> > that all clients rejoin at once when there is a membership
>> change,
>> >>> > >> > but
>> >>> > >> that
>> >>> > >> > is kind of fundamental to the problem.
>> >>> > >> >
>> >>> > >> > -Jay
>> >>> > >> >
>> >>> > >> > On Thu, Aug 27, 2015 at 2:02 PM, Joel Koshy  wrote:
>> >>> > >> >
>> >>> > >> >> I actually feel these set of tests (whatever they may be) are
>> >>> > somewhat
>> >>> > >> >> irrelevant here. My main concern with the current client-side
>> >>> > proposal
>> >>> > >> >> (i.e., without Becket's follow-up suggestions) is that it
>> makes a
>> >>> > >> >> significant compromise to the original charter of the new
>> >>> > >> >> consumer -
>> >>> > >> >> i.e., reduce/eliminate herd and split brain problems in both
>> >>> > >> >> group
>> >>> > >> >> management and partition assignment. I understand the need for
>> >>> > >> >> client-side partition assignment in some use cases (which we
>> are
>> >>> > >> >> also
>> >>> > >> >> interested in), but I also think we should make every effort
>> to
>> >>> > >> >> keep
>> >>> > >> >> full server-side coordination for the remaining (majority) of
>> use
>> >>> > >> >> cases especially if it does not complicate the protocol. The
>> >>> > >> >> proposed
>> >>> > >> >> changes do not complicate the protocol IMO - i.e., there is no
>> >>> > further
>> >>> > >> >> modification to the request/response formats beyond the
>> current
>> >>> > >> >> client-side proposal. It only involves a trivial
>> reinterpretation
>> >>> > >> >> of
>> >>> > >> >> the content of the protocol metadata field.
>> >>> > >> >>
>> >>> > >> >> Joel
>> >>> > >> >>
>> >>> > >> >> On Wed, Aug 26, 2015 at 9:33 PM, Neha Narkhede  wrote:
>> >>> > >> >> > Hey Becket,
>> >>> > >> >> >
>> >>> > >> >> > In that case, the broker side partition assignment would be
>> >>> > >> >> > ideal
>> >>> > >> because
>> >>> > >> >> >> it avoids
>> >>> > >> >> >> issues like metadata inconsistency / split brain /
>> exploding
>> >>> > >> >> subscription
>> >>> > >> >> >> set propagation.
>> >>> > >> >> >
>> >>> > >> >> >
>> >>> > >> >> > As per our previous discussions regarding each of those
>> >>> > >> >> > concerns
>> >>> > >> >> (referring
>> >>> > >> >> > to this email thread, KIP calls and JIRA comments), we are
>> >>> > >> >> > going to
>> >>> > >> run a
>> >>> > >> >> > set of tests using the LinkedIn deployment numbers that we
>> will
>> >>> > wait
>> >>> > >> for
>> >>> > >> >> > you to share. The purpose is to see if those concerns are
>> >>> > >> >> > really
>> >>> > >> valid or
>> >>> > >> >> > not. I'd prefer to see that before making any more changes
>> that
>> >>> > will
>> >>> > >> >> > complicate the protocol.
>> >>> > >> >> >
>> >>> > >> >> > On Wed, Aug 26, 2015 at 4:57 PM, Jiangjie Qin > >
>> >>> > >> >> > wrote:
>> >>> > >> >> >
>> >>> > >> >> >> Hi folks,
>> >>> > >> >> >>
>> >>> > >> >> >> After further discussion in LinkedIn, we found that while
>> >>> > >> >> >> having a
>> >>> > >> more
>> >>> > >> >> >> general group management protocol is very useful, the vast
>> >>> > majority
>> >>> > >> of
>> >>> > >> >> the
>> >>> > >> >> >> clients will not use customized partition assignment
>> strategy.
>> >>> > >> >> >> In
>> >>> > >> that
>> >>> > >> >> >> case, the broker side partition assignment would be ideal
>> >>> > >> >> >> because
>> >>> > it
>> >>> > >> >> avoids
>> >>> > >> >> >> issues like metadata inconsistency / split brain /
>> exploding
>> >>> > >> >> subscription
>> >>> > >> >> >> set propagation.
>> >>> > >> >> >>
>> >>> > >> >> >> So we have the following proposal that satisfies the
>> majority
>> >>> > >> >> >> of
>> >>> > the
>> >>> > >> >> >> clients' needs without changing the currently proposed
>> binary
>> >>> > >> protocol.
>> >>> > >> >> >> i.e., Continue to support broker-side assignment if the
>> >>> > >> >> >> assignment
>> >>> > >> >> strategy
>> >>> > >> >> >> is recognized by the coordinator.
>> >>> > >> >> >>
>> >>> > >> >> >> 1. Keep the binary protocol as currently proposed.
>> >>> > >> >> >>
>> >>> > >> >> >> 2. Change the way we interpret ProtocolMetadata:
>> >>> > >> >> >> 2.1 On consumer side, change partition.assignment.strategy
>> to
>> >>> > >> >> >> partition.assignor.class. Implement the something like the
>> >>> > following
>> >>> > >> >> >> PartitionAssignor Interface:
>> >>> > >> >> >>
>> >>> > >> >> >> public interface PartitionAssignor {
>> >>> > >> >> >>   List protocolTypes();
>> >>> > >> >> >>   byte[] protocolMetadata();
>> >>> > >> >> >>   // return the Topic->List map that are assigned to this
>> >>> > >> >> >> consumer.
>> >>> > >> >> >>   List assignPartitions(String protocolType, byte[]
>> >>> > >> >> >> responseProtocolMetadata);
>> >>> > >> >> >> }
>> >>> > >> >> >>
>> >>> > >> >> >> public abstract class AbstractPartitionAssignor implements
>> >>> > >> >> >> PartitionAssignor {
>> >>> > >> >> >>   protected final KafkaConsumer consumer;
>> >>> > >> >> >>   AbstractPartitionAssignor(KafkaConsumer consumer) {
>> >>> > >> >> >>     this.consumer = consumer;
>> >>> > >> >> >>   }
>> >>> > >> >> >> }
>> >>> > >> >> >>
>> >>> > >> >> >> 2.2 The ProtocolMetadata in JoinGroupRequest will be
>> >>> > >> >> >> partitionAssignor.protocolMetadata(). When
>> >>> > partition.assignor.class
>> >>> > >> is
>> >>> > >> >> >> "range" or "roundrobin", the ProtocolMetadata in
>> >>> > >> >> >> JoinGroupRequest
>> >>> > >> will
>> >>> > >> >> be a
>> >>> > >> >> >> JSON subscription set. ("range", "roundrobin" will be
>> reserved
>> >>> > >> words, we
>> >>> > >> >> >> can also consider reserving some Prefix such as "broker-"
>> to
>> >>> > >> >> >> be
>> >>> > more
>> >>> > >> >> clear)
>> >>> > >> >> >> 2.3 On broker side when ProtocolType is "range" or
>> >>> > >> >> >> "roundroubin",
>> >>> > >> >> >> coordinator will parse the ProtocolMetadata in the
>> >>> > JoinGroupRequest
>> >>> > >> and
>> >>> > >> >> >> assign the partitions for consumers. In the
>> JoinGroupResponse,
>> >>> > >> >> >> the
>> >>> > >> >> >> ProtocolMetadata will be the global assignment of
>> partitions.
>> >>> > >> >> >> 2.4 On client side, after receiving the JoinGroupResponse,
>> >>> > >> >> >> partitionAssignor.assignPartitions() will be invoked to
>> return
>> >>> > >> >> >> the
>> >>> > >> >> actual
>> >>> > >> >> >> assignment. If the assignor is RangeAssignor or
>> >>> > RoundRobinAssignor,
>> >>> > >> they
>> >>> > >> >> >> will parse the assignment from the ProtocolMetadata
>> returned
>> >>> > >> >> >> by
>> >>> > >> >> >> coordinator.
>> >>> > >> >> >>
>> >>> > >> >> >> This approach has a few merits:
>> >>> > >> >> >> 1. Does not change the proposed binary protocol, which is
>> >>> > >> >> >> still
>> >>> > >> general.
>> >>> > >> >> >> 2. The majority of the consumers will not suffer from
>> >>> > >> >> >> inconsistent
>> >>> > >> >> metadata
>> >>> > >> >> >> / split brain / exploding subscription set propagation.
>> This
>> >>> > >> >> >> is
>> >>> > >> >> >> specifically to deal with the issue that the current
>> proposal
>> >>> > caters
>> >>> > >> to
>> >>> > >> >> a
>> >>> > >> >> >> 20% use-case while adversely impacting the more common 80%
>> >>> > use-cases.
>> >>> > >> >> >> 3. Easy to implement. The only thing needed is implement a
>> >>> > >> partitioner
>> >>> > >> >> >> class. For most users, the default range and roundrobin
>> >>> > partitioner
>> >>> > >> are
>> >>> > >> >> >> good enough.
>> >>> > >> >> >>
>> >>> > >> >> >> Thoughts?
>> >>> > >> >> >>
>> >>> > >> >> >> Thanks,
>> >>> > >> >> >>
>> >>> > >> >> >> Jiangjie (Becket) Qin
>> >>> > >> >> >>
>> >>> > >> >> >> On Tue, Aug 18, 2015 at 2:51 PM, Jason Gustafson
>> >>> > >> >> >> wrote:
>> >>> > >> >> >>
>> >>> > >> >> >> > Follow-up from the kip call:
>> >>> > >> >> >> >
>> >>> > >> >> >> > 1. Onur brought up the question of whether this protocol
>> >>> > provides
>> >>> > >> >> enough
>> >>> > >> >> >> > coordination capabilities to be generally useful in
>> practice
>> >>> > >> >> >> > (is
>> >>> > >> that
>> >>> > >> >> >> > accurate, Onur?). If it doesn't, then each use case would
>> >>> > probably
>> >>> > >> >> need a
>> >>> > >> >> >> > dependence on zookeeper anyway, and we haven't really
>> gained
>> >>> > >> anything.
>> >>> > >> >> >> The
>> >>> > >> >> >> > group membership provided by this protocol is a useful
>> >>> > >> >> >> > primitive
>> >>> > >> for
>> >>> > >> >> >> > coordination, but it's limited in the sense that
>> everything
>> >>> > shared
>> >>> > >> >> among
>> >>> > >> >> >> > the group has to be communicated at the time the group is
>> >>> > created.
>> >>> > >> If
>> >>> > >> >> any
>> >>> > >> >> >> > shared data changes, then the only way the group can
>> ensure
>> >>> > >> agreement
>> >>> > >> >> is
>> >>> > >> >> >> to
>> >>> > >> >> >> > force a rebalance. This is expensive since all members
>> must
>> >>> > stall
>> >>> > >> >> while
>> >>> > >> >> >> the
>> >>> > >> >> >> > rebalancing takes place. As we have also seen, there is a
>> >>> > practical
>> >>> > >> >> limit
>> >>> > >> >> >> > on the amount of metadata that can be sent through this
>> >>> > >> >> >> > protocol
>> >>> > >> when
>> >>> > >> >> >> > groups get a little larger. This protocol is therefore
>> not
>> >>> > >> suitable to
>> >>> > >> >> >> > cases which require frequent communication or which
>> require
>> >>> > >> >> >> > a
>> >>> > large
>> >>> > >> >> >> amount
>> >>> > >> >> >> > of data to be communicated. For the use cases listed on
>> the
>> >>> > wiki,
>> >>> > >> >> neither
>> >>> > >> >> >> > of these appear to be an issue, but there may be other
>> >>> > limitations
>> >>> > >> >> which
>> >>> > >> >> >> > would limit reuse of the protocol. Perhaps it would be
>> >>> > sufficient
>> >>> > >> to
>> >>> > >> >> >> sketch
>> >>> > >> >> >> > how these cases might work?
>> >>> > >> >> >> >
>> >>> > >> >> >> > 2. We talked a little bit about the issue of metadata
>> churn.
>> >>> > Becket
>> >>> > >> >> >> brought
>> >>> > >> >> >> > up the interesting point that not only do we depend on
>> topic
>> >>> > >> metadata
>> >>> > >> >> >> > changing relatively infrequently, but we also expect
>> timely
>> >>> > >> agreement
>> >>> > >> >> >> among
>> >>> > >> >> >> > the brokers on what that metadata is. To resolve this, we
>> >>> > >> >> >> > can
>> >>> > have
>> >>> > >> the
>> >>> > >> >> >> > consumers fetch metadata from the coordinator. We still
>> >>> > >> >> >> > depend
>> >>> > on
>> >>> > >> >> topic
>> >>> > >> >> >> > metadata not changing frequently, but this should resolve
>> >>> > >> >> >> > any
>> >>> > >> >> >> disagreement
>> >>> > >> >> >> > among the brokers themselves. In fact, since we expect
>> that
>> >>> > >> >> disagreement
>> >>> > >> >> >> is
>> >>> > >> >> >> > relatively rare, we can have the consumers fetch from the
>> >>> > >> coordinator
>> >>> > >> >> >> only
>> >>> > >> >> >> > when when a disagreement occurs. The nice thing about
>> this
>> >>> > >> proposal is
>> >>> > >> >> >> that
>> >>> > >> >> >> > it doesn't affect the join group semantics, so the
>> >>> > >> >> >> > coordinator
>> >>> > >> would
>> >>> > >> >> >> remain
>> >>> > >> >> >> > oblivious to the metadata used by the group for
>> agreement.
>> >>> > Also, if
>> >>> > >> >> >> > metadata churn becomes an issue, it might be possible to
>> >>> > >> >> >> > have
>> >>> > the
>> >>> > >> >> >> > coordinator provide a snapshot for the group to ensure
>> that
>> >>> > >> >> >> > a
>> >>> > >> >> generation
>> >>> > >> >> >> > would be able to reach agreement (this would probably
>> >>> > >> >> >> > require
>> >>> > >> adding
>> >>> > >> >> >> > groupId/generation to the metadata request).
>> >>> > >> >> >> >
>> >>> > >> >> >> > 3. We talked briefly about support for multiple
>> protocols in
>> >>> > >> >> >> > the
>> >>> > >> join
>> >>> > >> >> >> group
>> >>> > >> >> >> > request in order to allow changing the assignment
>> strategy
>> >>> > without
>> >>> > >> >> >> > downtime. I think it's a little doubtful that this would
>> get
>> >>> > much
>> >>> > >> use
>> >>> > >> >> in
>> >>> > >> >> >> > practice, but I agree it's a nice option to have on the
>> >>> > >> >> >> > table.
>> >>> > An
>> >>> > >> >> >> > alternative, for the sake of argument, is to have each
>> >>> > >> >> >> > member
>> >>> > >> provide
>> >>> > >> >> >> only
>> >>> > >> >> >> > one version of the protocol, and to let the coordinator
>> >>> > >> >> >> > choose
>> >>> > the
>> >>> > >> >> >> protocol
>> >>> > >> >> >> > with the largest number of supporters. All members which
>> >>> > >> >> >> > can't
>> >>> > >> support
>> >>> > >> >> >> the
>> >>> > >> >> >> > selected protocol would be kicked out of the group. The
>> >>> > >> >> >> > drawback
>> >>> > >> in a
>> >>> > >> >> >> > rolling upgrade is that the total capacity of the group
>> >>> > >> >> >> > would be
>> >>> > >> >> >> > momentarily halved. It would also be a little tricky to
>> >>> > >> >> >> > handle
>> >>> > the
>> >>> > >> >> case
>> >>> > >> >> >> of
>> >>> > >> >> >> > retrying when a consumer is kicked out of the group. We
>> >>> > >> >> >> > wouldn't
>> >>> > >> want
>> >>> > >> >> it
>> >>> > >> >> >> to
>> >>> > >> >> >> > be able to effect a rebalance, for example, if it would
>> just
>> >>> > >> >> >> > be
>> >>> > >> kicked
>> >>> > >> >> >> out
>> >>> > >> >> >> > again. That would probably complicate the group
>> management
>> >>> > logic on
>> >>> > >> >> the
>> >>> > >> >> >> > coordinator.
>> >>> > >> >> >> >
>> >>> > >> >> >> >
>> >>> > >> >> >> > Thanks,
>> >>> > >> >> >> > Jason
>> >>> > >> >> >> >
>> >>> > >> >> >> >
>> >>> > >> >> >> > On Tue, Aug 18, 2015 at 11:16 AM, Jiangjie Qin
>> >>> > >> >> > >> >
>> >>> > >> >> >> > wrote:
>> >>> > >> >> >> >
>> >>> > >> >> >> > > Jun,
>> >>> > >> >> >> > >
>> >>> > >> >> >> > > Yes, I agree. If the metadata can be synced quickly
>> there
>> >>> > should
>> >>> > >> >> not be
>> >>> > >> >> >> > an
>> >>> > >> >> >> > > issue. It just occurred to me that there is a proposal
>> to
>> >>> > allow
>> >>> > >> >> >> consuming
>> >>> > >> >> >> > > from followers in ISR, that could potentially cause
>> more
>> >>> > frequent
>> >>> > >> >> >> > metadata
>> >>> > >> >> >> > > change for consumers. Would that be an issue?
>> >>> > >> >> >> > >
>> >>> > >> >> >> > > Thanks,
>> >>> > >> >> >> > >
>> >>> > >> >> >> > > Jiangjie (Becket) Qin
>> >>> > >> >> >> > >
>> >>> > >> >> >> > > On Tue, Aug 18, 2015 at 10:22 AM, Jason Gustafson <
>> >>> > >> >> jason@confluent.io>
>> >>> > >> >> >> > > wrote:
>> >>> > >> >> >> > >
>> >>> > >> >> >> > > > Hi Jun,
>> >>> > >> >> >> > > >
>> >>> > >> >> >> > > > Answers below:
>> >>> > >> >> >> > > >
>> >>> > >> >> >> > > > 1. When there are multiple common protocols in the
>> >>> > >> >> JoinGroupRequest,
>> >>> > >> >> >> > > which
>> >>> > >> >> >> > > > one would the coordinator pick?
>> >>> > >> >> >> > > >
>> >>> > >> >> >> > > > I was intending to use the list to indicate
>> preference.
>> >>> > >> >> >> > > > If
>> >>> > all
>> >>> > >> >> group
>> >>> > >> >> >> > > > members support protocols ["A", "B"] in that order,
>> then
>> >>> > >> >> >> > > > we
>> >>> > >> will
>> >>> > >> >> >> choose
>> >>> > >> >> >> > > > "A." If some support ["B", "A"], then we would either
>> >>> > >> >> >> > > > choose
>> >>> > >> >> based on
>> >>> > >> >> >> > > > respective counts or just randomly. The main use
>> case of
>> >>> > >> >> supporting
>> >>> > >> >> >> the
>> >>> > >> >> >> > > > list is for rolling upgrades when a change is made to
>> >>> > >> >> >> > > > the
>> >>> > >> >> assignment
>> >>> > >> >> >> > > > strategy. In that case, the new assignment strategy
>> >>> > >> >> >> > > > would be
>> >>> > >> >> listed
>> >>> > >> >> >> > first
>> >>> > >> >> >> > > > in the upgraded client. I think it's debatable
>> whether
>> >>> > >> >> >> > > > this
>> >>> > >> >> feature
>> >>> > >> >> >> > would
>> >>> > >> >> >> > > > get much use in practice, so we might consider
>> dropping
>> >>> > >> >> >> > > > it.
>> >>> > >> >> >> > > >
>> >>> > >> >> >> > > > 2. If the protocols don't agree, the group
>> construction
>> >>> > fails.
>> >>> > >> >> What
>> >>> > >> >> >> > > exactly
>> >>> > >> >> >> > > > does it mean? Do we send an error in every
>> >>> > >> >> >> > > > JoinGroupResponse
>> >>> > >> and
>> >>> > >> >> >> remove
>> >>> > >> >> >> > > all
>> >>> > >> >> >> > > > members in the group in the coordinator?
>> >>> > >> >> >> > > >
>> >>> > >> >> >> > > > Yes, that is right. It would be handled similarly to
>> >>> > >> inconsistent
>> >>> > >> >> >> > > > assignment strategies in the current protocol. The
>> >>> > coordinator
>> >>> > >> >> >> returns
>> >>> > >> >> >> > an
>> >>> > >> >> >> > > > error in each join group response, and the client
>> >>> > >> >> >> > > > propagates
>> >>> > >> the
>> >>> > >> >> >> error
>> >>> > >> >> >> > to
>> >>> > >> >> >> > > > the user.
>> >>> > >> >> >> > > >
>> >>> > >> >> >> > > > 3. Consumer embedded protocol: The proposal has two
>> >>> > different
>> >>> > >> >> formats
>> >>> > >> >> >> > of
>> >>> > >> >> >> > > > subscription depending on whether wildcards are used
>> or
>> >>> > >> >> >> > > > not.
>> >>> > >> This
>> >>> > >> >> >> > seems a
>> >>> > >> >> >> > > > bit complicated. Would it be better to always use the
>> >>> > metadata
>> >>> > >> >> hash?
>> >>> > >> >> >> > The
>> >>> > >> >> >> > > > clients know the subscribed topics already. This way,
>> >>> > >> >> >> > > > the
>> >>> > >> client
>> >>> > >> >> code
>> >>> > >> >> >> > > > behaves the same whether wildcards are used or not.
>> >>> > >> >> >> > > >
>> >>> > >> >> >> > > > Yeah, I think this is possible (Neha also suggested
>> it).
>> >>> > >> >> >> > > > I
>> >>> > >> haven't
>> >>> > >> >> >> > > updated
>> >>> > >> >> >> > > > the wiki yet, but the patch I started working on uses
>> >>> > >> >> >> > > > only
>> >>> > the
>> >>> > >> >> >> metadata
>> >>> > >> >> >> > > > hash. In the case that an explicit topic list is
>> >>> > >> >> >> > > > provided,
>> >>> > the
>> >>> > >> >> hash
>> >>> > >> >> >> > just
>> >>> > >> >> >> > > > covers the metadata for those topics.
>> >>> > >> >> >> > > >
>> >>> > >> >> >> > > >
>> >>> > >> >> >> > > > Thanks,
>> >>> > >> >> >> > > > Jason
>> >>> > >> >> >> > > >
>> >>> > >> >> >> > > >
>> >>> > >> >> >> > > >
>> >>> > >> >> >> > > > On Tue, Aug 18, 2015 at 10:06 AM, Jun Rao
>> >>> > >> >> wrote:
>> >>> > >> >> >> > > >
>> >>> > >> >> >> > > > > Jason,
>> >>> > >> >> >> > > > >
>> >>> > >> >> >> > > > > Thanks for the writeup. A few comments below.
>> >>> > >> >> >> > > > >
>> >>> > >> >> >> > > > > 1. When there are multiple common protocols in the
>> >>> > >> >> >> JoinGroupRequest,
>> >>> > >> >> >> > > > which
>> >>> > >> >> >> > > > > one would the coordinator pick?
>> >>> > >> >> >> > > > > 2. If the protocols don't agree, the group
>> >>> > >> >> >> > > > > construction
>> >>> > >> fails.
>> >>> > >> >> What
>> >>> > >> >> >> > > > exactly
>> >>> > >> >> >> > > > > does it mean? Do we send an error in every
>> >>> > JoinGroupResponse
>> >>> > >> and
>> >>> > >> >> >> > remove
>> >>> > >> >> >> > > > all
>> >>> > >> >> >> > > > > members in the group in the coordinator?
>> >>> > >> >> >> > > > > 3. Consumer embedded protocol: The proposal has two
>> >>> > different
>> >>> > >> >> >> formats
>> >>> > >> >> >> > > of
>> >>> > >> >> >> > > > > subscription depending on whether wildcards are
>> used
>> >>> > >> >> >> > > > > or
>> >>> > not.
>> >>> > >> >> This
>> >>> > >> >> >> > > seems a
>> >>> > >> >> >> > > > > bit complicated. Would it be better to always use
>> the
>> >>> > >> metadata
>> >>> > >> >> >> hash?
>> >>> > >> >> >> > > The
>> >>> > >> >> >> > > > > clients know the subscribed topics already. This
>> way,
>> >>> > >> >> >> > > > > the
>> >>> > >> client
>> >>> > >> >> >> code
>> >>> > >> >> >> > > > > behaves the same whether wildcards are used or not.
>> >>> > >> >> >> > > > >
>> >>> > >> >> >> > > > > Jiangjie,
>> >>> > >> >> >> > > > >
>> >>> > >> >> >> > > > > With respect to rebalance churns due to topics
>> being
>> >>> > >> >> >> created/deleted.
>> >>> > >> >> >> > > > With
>> >>> > >> >> >> > > > > the new consumer, the rebalance can probably settle
>> >>> > >> >> >> > > > > within
>> >>> > >> 200ms
>> >>> > >> >> >> when
>> >>> > >> >> >> > > > there
>> >>> > >> >> >> > > > > is a topic change. So, as long as we are not
>> changing
>> >>> > topic
>> >>> > >> more
>> >>> > >> >> >> > than 5
>> >>> > >> >> >> > > > > times per sec, there shouldn't be constant churns,
>> >>> > >> >> >> > > > > right?
>> >>> > >> >> >> > > > >
>> >>> > >> >> >> > > > > Thanks,
>> >>> > >> >> >> > > > >
>> >>> > >> >> >> > > > > Jun
>> >>> > >> >> >> > > > >
>> >>> > >> >> >> > > > >
>> >>> > >> >> >> > > > >
>> >>> > >> >> >> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <
>> >>> > >> >> >> jason@confluent.io
>> >>> > >> >> >> > >
>> >>> > >> >> >> > > > > wrote:
>> >>> > >> >> >> > > > >
>> >>> > >> >> >> > > > > > Hi Kafka Devs,
>> >>> > >> >> >> > > > > >
>> >>> > >> >> >> > > > > > One of the nagging issues in the current design
>> of
>> >>> > >> >> >> > > > > > the
>> >>> > new
>> >>> > >> >> >> consumer
>> >>> > >> >> >> > > has
>> >>> > >> >> >> > > > > > been the need to support a variety of assignment
>> >>> > >> strategies.
>> >>> > >> >> >> We've
>> >>> > >> >> >> > > > > > encountered this in particular in the design of
>> >>> > >> >> >> > > > > > copycat
>> >>> > and
>> >>> > >> >> the
>> >>> > >> >> >> > > > > processing
>> >>> > >> >> >> > > > > > framework (KIP-28). From what I understand, Samza
>> >>> > >> >> >> > > > > > also
>> >>> > has
>> >>> > >> a
>> >>> > >> >> >> number
>> >>> > >> >> >> > > of
>> >>> > >> >> >> > > > > use
>> >>> > >> >> >> > > > > > cases with custom assignment needs. The new
>> consumer
>> >>> > >> protocol
>> >>> > >> >> >> > > supports
>> >>> > >> >> >> > > > > new
>> >>> > >> >> >> > > > > > assignment strategies by hooking them into the
>> >>> > >> >> >> > > > > > broker.
>> >>> > For
>> >>> > >> >> many
>> >>> > >> >> >> > > > > > environments, this is a major pain and in some
>> >>> > >> >> >> > > > > > cases, a
>> >>> > >> >> >> > non-starter.
>> >>> > >> >> >> > > It
>> >>> > >> >> >> > > > > > also challenges the validation that the
>> coordinator
>> >>> > >> >> >> > > > > > can
>> >>> > >> >> provide.
>> >>> > >> >> >> > For
>> >>> > >> >> >> > > > > > example, some assignment strategies call for
>> >>> > >> >> >> > > > > > partitions
>> >>> > to
>> >>> > >> be
>> >>> > >> >> >> > > assigned
>> >>> > >> >> >> > > > > > multiple times, which means that the coordinator
>> can
>> >>> > only
>> >>> > >> >> check
>> >>> > >> >> >> > that
>> >>> > >> >> >> > > > > > partitions have been assigned at least once.
>> >>> > >> >> >> > > > > >
>> >>> > >> >> >> > > > > > To solve these issues, we'd like to propose
>> moving
>> >>> > >> assignment
>> >>> > >> >> to
>> >>> > >> >> >> > the
>> >>> > >> >> >> > > > > > client. I've written a wiki which outlines some
>> >>> > >> >> >> > > > > > protocol
>> >>> > >> >> changes
>> >>> > >> >> >> to
>> >>> > >> >> >> > > > > achieve
>> >>> > >> >> >> > > > > > this:
>> >>> > >> >> >> > > > > >
>> >>> > >> >> >> > > > > >
>> >>> > >> >> >> > > > >
>> >>> > >> >> >> > > >
>> >>> > >> >> >> > >
>> >>> > >> >> >> >
>> >>> > >> >> >>
>> >>> > >> >>
>> >>> > >>
>> >>> >
>> >>> >
>> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
>> >>> > >> >> >> > > > > > .
>> >>> > >> >> >> > > > > > To summarize briefly, instead of the coordinator
>> >>> > assigning
>> >>> > >> the
>> >>> > >> >> >> > > > partitions
>> >>> > >> >> >> > > > > > itself, all subscriptions are forwarded to each
>> >>> > >> >> >> > > > > > member
>> >>> > of
>> >>> > >> the
>> >>> > >> >> >> group
>> >>> > >> >> >> > > > which
>> >>> > >> >> >> > > > > > then decides independently which partitions it
>> >>> > >> >> >> > > > > > should
>> >>> > >> consume.
>> >>> > >> >> >> The
>> >>> > >> >> >> > > > > protocol
>> >>> > >> >> >> > > > > > provides a mechanism for the coordinator to
>> validate
>> >>> > that
>> >>> > >> all
>> >>> > >> >> >> > > consumers
>> >>> > >> >> >> > > > > use
>> >>> > >> >> >> > > > > > the same assignment strategy, but it does not
>> ensure
>> >>> > that
>> >>> > >> the
>> >>> > >> >> >> > > resulting
>> >>> > >> >> >> > > > > > assignment is "correct." This provides a powerful
>> >>> > >> capability
>> >>> > >> >> for
>> >>> > >> >> >> > > users
>> >>> > >> >> >> > > > to
>> >>> > >> >> >> > > > > > control the full data flow on the client side.
>> They
>> >>> > control
>> >>> > >> >> how
>> >>> > >> >> >> > data
>> >>> > >> >> >> > > is
>> >>> > >> >> >> > > > > > written to partitions through the Partitioner
>> >>> > >> >> >> > > > > > interface
>> >>> > and
>> >>> > >> >> they
>> >>> > >> >> >> > > > control
>> >>> > >> >> >> > > > > > how data is consumed through the assignment
>> >>> > >> >> >> > > > > > strategy,
>> >>> > all
>> >>> > >> >> without
>> >>> > >> >> >> > > > > touching
>> >>> > >> >> >> > > > > > the server.
>> >>> > >> >> >> > > > > >
>> >>> > >> >> >> > > > > > Of course nothing comes for free. In particular,
>> >>> > >> >> >> > > > > > this
>> >>> > >> change
>> >>> > >> >> >> > removes
>> >>> > >> >> >> > > > the
>> >>> > >> >> >> > > > > > ability of the coordinator to validate that
>> commits
>> >>> > >> >> >> > > > > > are
>> >>> > >> made
>> >>> > >> >> by
>> >>> > >> >> >> > > > consumers
>> >>> > >> >> >> > > > > > who were assigned the respective partition. This
>> >>> > >> >> >> > > > > > might
>> >>> > not
>> >>> > >> be
>> >>> > >> >> too
>> >>> > >> >> >> > bad
>> >>> > >> >> >> > > > > since
>> >>> > >> >> >> > > > > > we retain the ability to validate the generation
>> id,
>> >>> > but it
>> >>> > >> >> is a
>> >>> > >> >> >> > > > > potential
>> >>> > >> >> >> > > > > > concern. We have considered alternative protocols
>> >>> > >> >> >> > > > > > which
>> >>> > >> add a
>> >>> > >> >> >> > second
>> >>> > >> >> >> > > > > > round-trip to the protocol in order to give the
>> >>> > coordinator
>> >>> > >> >> the
>> >>> > >> >> >> > > ability
>> >>> > >> >> >> > > > > to
>> >>> > >> >> >> > > > > > confirm the assignment. As mentioned above, the
>> >>> > >> coordinator is
>> >>> > >> >> >> > > somewhat
>> >>> > >> >> >> > > > > > limited in what it can actually validate, but
>> this
>> >>> > >> >> >> > > > > > would
>> >>> > >> >> return
>> >>> > >> >> >> its
>> >>> > >> >> >> > > > > ability
>> >>> > >> >> >> > > > > > to validate commits. The tradeoff is that it
>> >>> > >> >> >> > > > > > increases
>> >>> > the
>> >>> > >> >> >> > protocol's
>> >>> > >> >> >> > > > > > complexity which means more ways for the
>> protocol to
>> >>> > fail
>> >>> > >> and
>> >>> > >> >> >> > > > > consequently
>> >>> > >> >> >> > > > > > more edge cases in the code.
>> >>> > >> >> >> > > > > >
>> >>> > >> >> >> > > > > > It also misses an opportunity to generalize the
>> >>> > >> >> >> > > > > > group
>> >>> > >> >> membership
>> >>> > >> >> >> > > > protocol
>> >>> > >> >> >> > > > > > for additional use cases. In fact, after you've
>> gone
>> >>> > >> >> >> > > > > > to
>> >>> > the
>> >>> > >> >> >> trouble
>> >>> > >> >> >> > > of
>> >>> > >> >> >> > > > > > moving assignment to the client, the main thing
>> that
>> >>> > >> >> >> > > > > > is
>> >>> > >> left
>> >>> > >> >> in
>> >>> > >> >> >> > this
>> >>> > >> >> >> > > > > > protocol is basically a general group management
>> >>> > >> capability.
>> >>> > >> >> This
>> >>> > >> >> >> > is
>> >>> > >> >> >> > > > > > exactly what is needed for a few cases that are
>> >>> > currently
>> >>> > >> >> under
>> >>> > >> >> >> > > > > discussion
>> >>> > >> >> >> > > > > > (e.g. copycat or single-writer producer). We've
>> >>> > >> >> >> > > > > > taken
>> >>> > this
>> >>> > >> >> >> further
>> >>> > >> >> >> > > step
>> >>> > >> >> >> > > > > in
>> >>> > >> >> >> > > > > > the proposal and attempted to envision what that
>> >>> > >> >> >> > > > > > general
>> >>> > >> >> protocol
>> >>> > >> >> >> > > might
>> >>> > >> >> >> > > > > > look like and how it could be used both by the
>> >>> > >> >> >> > > > > > consumer
>> >>> > and
>> >>> > >> >> for
>> >>> > >> >> >> > some
>> >>> > >> >> >> > > of
>> >>> > >> >> >> > > > > > these other cases.
>> >>> > >> >> >> > > > > >
>> >>> > >> >> >> > > > > > Anyway, since time is running out on the new
>> >>> > >> >> >> > > > > > consumer,
>> >>> > we
>> >>> > >> have
>> >>> > >> >> >> > > perhaps
>> >>> > >> >> >> > > > > one
>> >>> > >> >> >> > > > > > last chance to consider a significant change in
>> the
>> >>> > >> protocol
>> >>> > >> >> like
>> >>> > >> >> >> > > this,
>> >>> > >> >> >> > > > > so
>> >>> > >> >> >> > > > > > have a look at the wiki and share your thoughts.
>> >>> > >> >> >> > > > > > I've no
>> >>> > >> doubt
>> >>> > >> >> >> that
>> >>> > >> >> >> > > > some
>> >>> > >> >> >> > > > > > ideas seem clearer in my mind than they do on
>> paper,
>> >>> > >> >> >> > > > > > so
>> >>> > ask
>> >>> > >> >> >> > questions
>> >>> > >> >> >> > > > if
>> >>> > >> >> >> > > > > > there is any confusion.
>> >>> > >> >> >> > > > > >
>> >>> > >> >> >> > > > > > Thanks!
>> >>> > >> >> >> > > > > > Jason
>> >>> > >> >> >> > > > > >
>> >>> > >> >> >> > > > >
>> >>> > >> >> >> > > >
>> >>> > >> >> >> > >
>> >>> > >> >> >> >
>> >>> > >> >> >>
>> >>> > >> >> >
>> >>> > >> >> >
>> >>> > >> >> >
>> >>> > >> >> > --
>> >>> > >> >> > Thanks,
>> >>> > >> >> > Neha
>> >>> > >> >>
>> >>> > >>
>> >>> >
>> >>>
>> >>>
>> >>>
>> >>> --
>> >>> Sent from Gmail Mobile
>> >>
>> >>
>> >>
>> >> --
>> >> Sent from Gmail Mobile
>> >
>> >
>>
>
>

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Jiangjie Qin <jq...@linkedin.com.INVALID>.
Hi Neha,

Following are some numbers we have in the pipeline. It would be very
helpful to see how it goes with the proposed protocol. We will try to do
some tests with the current patch as well. Please also let us know if you
want further information.

32 brokers, 1Gbps NIC
547 topics
27 chars average topic name length
2-3 consumers for each topic

Four 26-node mirror maker instances (Four different consumer groups). Each
node has 4 consumers. (Each mirror maker instance has 104 consumers)
We are actually using selective copy, so we have a big whitelist for each
mirror maker, copying about 100 topics (We expect it to grow to a couple of
hundreds).
The mirror makers are co-located with target cluster, so the consumer
traffic go through the WAN.

We have 5 to 6 wildcard consumers consuming from all the topics.

The topic creation frequency is not high now, roughly about 1 / day.

The scenarios we are interested in are:
1. The time for one round of rebalance.
2. The time for a rolling bounce of mirror maker.
3. For wildcard topic, does metadata sync up cause problem.

Thanks,

Jiangjie (Becket) Qin


On Fri, Aug 28, 2015 at 1:24 PM, Joel Koshy <jj...@gmail.com> wrote:

> Another use-case I was thinking of was something like rack-aware
> assignment of partitions to clients. This would require some
> additional topic metadata to be propagated to and from the coordinator
> and you would need some way to resolve conflicts for such strategies.
> I think that could be addressed by attaching a generation id to the
> metadata and use that (i.e., pick the highest) in order to resolve
> conflicts without another round of join-group requests.
>
> Likewise, without delete/recreate, partition counts are a sort of
> generation id since they are non-decreasing. If we need to account for
> delete/recreate that could perhaps be addressed by an explicit
> (per-topic) generation id attached to each topic in the metadata blob.
> Does that make sense? I think that covers my concerns wrt the
> split-brain issues.
>
> I'm still a bit wary of the n^2*m sized rebroadcast of all the
> metadata - mainly because for various reasons at LinkedIn, we are
> actually using large explicit whitelists (and not wildcards) in
> several of our mirroring pipelines. At this point I feel that is a
> reasonable cost to pay for having all the logic in one place (i.e.,
> client side) but I would like to think a bit more on that.
>
> Joel
>
>
> On Fri, Aug 28, 2015 at 1:02 PM, Onur Karaman
> <ok...@linkedin.com.invalid> wrote:
> > From what I understand, the "largest number of partitions" trick is based
> > on the assumption that topics can only expand their partitions. What
> > happens when a topic gets deleted and recreated? This breaks that
> > assumption.
> >
> > On Fri, Aug 28, 2015 at 6:33 AM, Neha Narkhede <ne...@confluent.io>
> wrote:
> >
> >> Thanks for re-reviewing Joel.
> >>
> >>
> >>
> >>
> >>
> >>
> >> On Fri, Aug 28, 2015 at 2:51 AM -0700, "Joel Koshy" <
> jjkoshy.w@gmail.com>
> >> wrote:
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> > I think we think this proposal addresses 100% of the split brain
> issues
> >> > ever seen in the ZK-based protocol, but I think you think there are
> still
> >> > issues. Can you explain what your thinking of and when you think it
> would
> >> > happen? I want to make sure you aren't assuming
> client-side=>split-brain
> >> > since I think that is totally not the case.
> >>
> >> Yes I had concluded that client-side assignment would still result in
> >> split-brain wrt partition counts, but I overlooked a key sentence in
> >> the wiki - i.e., that the assignment algorithm for consumers can just
> >> use the largest number of partitions for each topic reported by any of
> >> the consumers. i.e., I assumed that consumers would just fail
> >> rebalance if the partition counts were inconsistent but that is not
> >> the case since this conflict can be easily resolved as described
> >> without further join-group requests. Sorry about that. There is still
> >> the issue of the coordinator having to send back n*m worth of
> >> metadata, but that was not my biggest concern. I'll look over it again
> >> and reply back tomorrow.
> >>
> >> Joel
> >>
> >> On Thu, Aug 27, 2015 at 2:55 PM, Jay Kreps  wrote:
> >> > Hey Joel,
> >> >
> >> > I really don't think we should do both. There are pros and cons but we
> >> > should make a decision and work on operationalizing one approach.
> Much of
> >> > really making something like this work is getting all the bugs out,
> >> getting
> >> > monitoring in place, getting rigorous system tests in place. Trying
> to do
> >> > those things twice with the same resources will just mean we do them
> half
> >> > as well. I also think this buys nothing from the user's point of
> >> view--they
> >> > want co-ordination that works correctly, the debate we are having is
> >> purely
> >> > a "how should we build that" debate. So this is really not the kind of
> >> > thing we'd want to make pluggable and if we did that would just
> >> complicate
> >> > life for the user.
> >> >
> >> > I think we think this proposal addresses 100% of the split brain
> issues
> >> > ever seen in the ZK-based protocol, but I think you think there are
> still
> >> > issues. Can you explain what your thinking of and when you think it
> would
> >> > happen? I want to make sure you aren't assuming
> client-side=>split-brain
> >> > since I think that is totally not the case.
> >> >
> >> > With respect to "herd issues" I actually think all the proposals
> address
> >> > this by scaling the co-ordinator out to all nodes and making the
> >> > co-ordination vastly cheaper. No proposal, of course, gets rid of the
> >> fact
> >> > that all clients rejoin at once when there is a membership change, but
> >> that
> >> > is kind of fundamental to the problem.
> >> >
> >> > -Jay
> >> >
> >> > On Thu, Aug 27, 2015 at 2:02 PM, Joel Koshy  wrote:
> >> >
> >> >> I actually feel these set of tests (whatever they may be) are
> somewhat
> >> >> irrelevant here. My main concern with the current client-side
> proposal
> >> >> (i.e., without Becket's follow-up suggestions) is that it makes a
> >> >> significant compromise to the original charter of the new consumer -
> >> >> i.e., reduce/eliminate herd and split brain problems in both group
> >> >> management and partition assignment. I understand the need for
> >> >> client-side partition assignment in some use cases (which we are also
> >> >> interested in), but I also think we should make every effort to keep
> >> >> full server-side coordination for the remaining (majority) of use
> >> >> cases especially if it does not complicate the protocol. The proposed
> >> >> changes do not complicate the protocol IMO - i.e., there is no
> further
> >> >> modification to the request/response formats beyond the current
> >> >> client-side proposal. It only involves a trivial reinterpretation of
> >> >> the content of the protocol metadata field.
> >> >>
> >> >> Joel
> >> >>
> >> >> On Wed, Aug 26, 2015 at 9:33 PM, Neha Narkhede  wrote:
> >> >> > Hey Becket,
> >> >> >
> >> >> > In that case, the broker side partition assignment would be ideal
> >> because
> >> >> >> it avoids
> >> >> >> issues like metadata inconsistency / split brain / exploding
> >> >> subscription
> >> >> >> set propagation.
> >> >> >
> >> >> >
> >> >> > As per our previous discussions regarding each of those concerns
> >> >> (referring
> >> >> > to this email thread, KIP calls and JIRA comments), we are going to
> >> run a
> >> >> > set of tests using the LinkedIn deployment numbers that we will
> wait
> >> for
> >> >> > you to share. The purpose is to see if those concerns are really
> >> valid or
> >> >> > not. I'd prefer to see that before making any more changes that
> will
> >> >> > complicate the protocol.
> >> >> >
> >> >> > On Wed, Aug 26, 2015 at 4:57 PM, Jiangjie Qin > >
> >> >> > wrote:
> >> >> >
> >> >> >> Hi folks,
> >> >> >>
> >> >> >> After further discussion in LinkedIn, we found that while having a
> >> more
> >> >> >> general group management protocol is very useful, the vast
> majority
> >> of
> >> >> the
> >> >> >> clients will not use customized partition assignment strategy. In
> >> that
> >> >> >> case, the broker side partition assignment would be ideal because
> it
> >> >> avoids
> >> >> >> issues like metadata inconsistency / split brain / exploding
> >> >> subscription
> >> >> >> set propagation.
> >> >> >>
> >> >> >> So we have the following proposal that satisfies the majority of
> the
> >> >> >> clients' needs without changing the currently proposed binary
> >> protocol.
> >> >> >> i.e., Continue to support broker-side assignment if the assignment
> >> >> strategy
> >> >> >> is recognized by the coordinator.
> >> >> >>
> >> >> >> 1. Keep the binary protocol as currently proposed.
> >> >> >>
> >> >> >> 2. Change the way we interpret ProtocolMetadata:
> >> >> >> 2.1 On consumer side, change partition.assignment.strategy to
> >> >> >> partition.assignor.class. Implement the something like the
> following
> >> >> >> PartitionAssignor Interface:
> >> >> >>
> >> >> >> public interface PartitionAssignor {
> >> >> >>   List protocolTypes();
> >> >> >>   byte[] protocolMetadata();
> >> >> >>   // return the Topic->List map that are assigned to this
> >> >> >> consumer.
> >> >> >>   List assignPartitions(String protocolType, byte[]
> >> >> >> responseProtocolMetadata);
> >> >> >> }
> >> >> >>
> >> >> >> public abstract class AbstractPartitionAssignor implements
> >> >> >> PartitionAssignor {
> >> >> >>   protected final KafkaConsumer consumer;
> >> >> >>   AbstractPartitionAssignor(KafkaConsumer consumer) {
> >> >> >>     this.consumer = consumer;
> >> >> >>   }
> >> >> >> }
> >> >> >>
> >> >> >> 2.2 The ProtocolMetadata in JoinGroupRequest will be
> >> >> >> partitionAssignor.protocolMetadata(). When
> partition.assignor.class
> >> is
> >> >> >> "range" or "roundrobin", the ProtocolMetadata in JoinGroupRequest
> >> will
> >> >> be a
> >> >> >> JSON subscription set. ("range", "roundrobin" will be reserved
> >> words, we
> >> >> >> can also consider reserving some Prefix such as "broker-" to be
> more
> >> >> clear)
> >> >> >> 2.3 On broker side when ProtocolType is "range" or "roundroubin",
> >> >> >> coordinator will parse the ProtocolMetadata in the
> JoinGroupRequest
> >> and
> >> >> >> assign the partitions for consumers. In the JoinGroupResponse, the
> >> >> >> ProtocolMetadata will be the global assignment of partitions.
> >> >> >> 2.4 On client side, after receiving the JoinGroupResponse,
> >> >> >> partitionAssignor.assignPartitions() will be invoked to return the
> >> >> actual
> >> >> >> assignment. If the assignor is RangeAssignor or
> RoundRobinAssignor,
> >> they
> >> >> >> will parse the assignment from the ProtocolMetadata returned by
> >> >> >> coordinator.
> >> >> >>
> >> >> >> This approach has a few merits:
> >> >> >> 1. Does not change the proposed binary protocol, which is still
> >> general.
> >> >> >> 2. The majority of the consumers will not suffer from inconsistent
> >> >> metadata
> >> >> >> / split brain / exploding subscription set propagation. This is
> >> >> >> specifically to deal with the issue that the current proposal
> caters
> >> to
> >> >> a
> >> >> >> 20% use-case while adversely impacting the more common 80%
> use-cases.
> >> >> >> 3. Easy to implement. The only thing needed is implement a
> >> partitioner
> >> >> >> class. For most users, the default range and roundrobin
> partitioner
> >> are
> >> >> >> good enough.
> >> >> >>
> >> >> >> Thoughts?
> >> >> >>
> >> >> >> Thanks,
> >> >> >>
> >> >> >> Jiangjie (Becket) Qin
> >> >> >>
> >> >> >> On Tue, Aug 18, 2015 at 2:51 PM, Jason Gustafson
> >> >> >> wrote:
> >> >> >>
> >> >> >> > Follow-up from the kip call:
> >> >> >> >
> >> >> >> > 1. Onur brought up the question of whether this protocol
> provides
> >> >> enough
> >> >> >> > coordination capabilities to be generally useful in practice (is
> >> that
> >> >> >> > accurate, Onur?). If it doesn't, then each use case would
> probably
> >> >> need a
> >> >> >> > dependence on zookeeper anyway, and we haven't really gained
> >> anything.
> >> >> >> The
> >> >> >> > group membership provided by this protocol is a useful primitive
> >> for
> >> >> >> > coordination, but it's limited in the sense that everything
> shared
> >> >> among
> >> >> >> > the group has to be communicated at the time the group is
> created.
> >> If
> >> >> any
> >> >> >> > shared data changes, then the only way the group can ensure
> >> agreement
> >> >> is
> >> >> >> to
> >> >> >> > force a rebalance. This is expensive since all members must
> stall
> >> >> while
> >> >> >> the
> >> >> >> > rebalancing takes place. As we have also seen, there is a
> practical
> >> >> limit
> >> >> >> > on the amount of metadata that can be sent through this protocol
> >> when
> >> >> >> > groups get a little larger. This protocol is therefore not
> >> suitable to
> >> >> >> > cases which require frequent communication or which require a
> large
> >> >> >> amount
> >> >> >> > of data to be communicated. For the use cases listed on the
> wiki,
> >> >> neither
> >> >> >> > of these appear to be an issue, but there may be other
> limitations
> >> >> which
> >> >> >> > would limit reuse of the protocol. Perhaps it would be
> sufficient
> >> to
> >> >> >> sketch
> >> >> >> > how these cases might work?
> >> >> >> >
> >> >> >> > 2. We talked a little bit about the issue of metadata churn.
> Becket
> >> >> >> brought
> >> >> >> > up the interesting point that not only do we depend on topic
> >> metadata
> >> >> >> > changing relatively infrequently, but we also expect timely
> >> agreement
> >> >> >> among
> >> >> >> > the brokers on what that metadata is. To resolve this, we can
> have
> >> the
> >> >> >> > consumers fetch metadata from the coordinator. We still depend
> on
> >> >> topic
> >> >> >> > metadata not changing frequently, but this should resolve any
> >> >> >> disagreement
> >> >> >> > among the brokers themselves. In fact, since we expect that
> >> >> disagreement
> >> >> >> is
> >> >> >> > relatively rare, we can have the consumers fetch from the
> >> coordinator
> >> >> >> only
> >> >> >> > when when a disagreement occurs. The nice thing about this
> >> proposal is
> >> >> >> that
> >> >> >> > it doesn't affect the join group semantics, so the coordinator
> >> would
> >> >> >> remain
> >> >> >> > oblivious to the metadata used by the group for agreement.
> Also, if
> >> >> >> > metadata churn becomes an issue, it might be possible to have
> the
> >> >> >> > coordinator provide a snapshot for the group to ensure that a
> >> >> generation
> >> >> >> > would be able to reach agreement (this would probably require
> >> adding
> >> >> >> > groupId/generation to the metadata request).
> >> >> >> >
> >> >> >> > 3. We talked briefly about support for multiple protocols in the
> >> join
> >> >> >> group
> >> >> >> > request in order to allow changing the assignment strategy
> without
> >> >> >> > downtime. I think it's a little doubtful that this would get
> much
> >> use
> >> >> in
> >> >> >> > practice, but I agree it's a nice option to have on the table.
> An
> >> >> >> > alternative, for the sake of argument, is to have each member
> >> provide
> >> >> >> only
> >> >> >> > one version of the protocol, and to let the coordinator choose
> the
> >> >> >> protocol
> >> >> >> > with the largest number of supporters. All members which can't
> >> support
> >> >> >> the
> >> >> >> > selected protocol would be kicked out of the group. The drawback
> >> in a
> >> >> >> > rolling upgrade is that the total capacity of the group would be
> >> >> >> > momentarily halved. It would also be a little tricky to handle
> the
> >> >> case
> >> >> >> of
> >> >> >> > retrying when a consumer is kicked out of the group. We wouldn't
> >> want
> >> >> it
> >> >> >> to
> >> >> >> > be able to effect a rebalance, for example, if it would just be
> >> kicked
> >> >> >> out
> >> >> >> > again. That would probably complicate the group management
> logic on
> >> >> the
> >> >> >> > coordinator.
> >> >> >> >
> >> >> >> >
> >> >> >> > Thanks,
> >> >> >> > Jason
> >> >> >> >
> >> >> >> >
> >> >> >> > On Tue, Aug 18, 2015 at 11:16 AM, Jiangjie Qin
> >> >> > >> >
> >> >> >> > wrote:
> >> >> >> >
> >> >> >> > > Jun,
> >> >> >> > >
> >> >> >> > > Yes, I agree. If the metadata can be synced quickly there
> should
> >> >> not be
> >> >> >> > an
> >> >> >> > > issue. It just occurred to me that there is a proposal to
> allow
> >> >> >> consuming
> >> >> >> > > from followers in ISR, that could potentially cause more
> frequent
> >> >> >> > metadata
> >> >> >> > > change for consumers. Would that be an issue?
> >> >> >> > >
> >> >> >> > > Thanks,
> >> >> >> > >
> >> >> >> > > Jiangjie (Becket) Qin
> >> >> >> > >
> >> >> >> > > On Tue, Aug 18, 2015 at 10:22 AM, Jason Gustafson <
> >> >> jason@confluent.io>
> >> >> >> > > wrote:
> >> >> >> > >
> >> >> >> > > > Hi Jun,
> >> >> >> > > >
> >> >> >> > > > Answers below:
> >> >> >> > > >
> >> >> >> > > > 1. When there are multiple common protocols in the
> >> >> JoinGroupRequest,
> >> >> >> > > which
> >> >> >> > > > one would the coordinator pick?
> >> >> >> > > >
> >> >> >> > > > I was intending to use the list to indicate preference. If
> all
> >> >> group
> >> >> >> > > > members support protocols ["A", "B"] in that order, then we
> >> will
> >> >> >> choose
> >> >> >> > > > "A." If some support ["B", "A"], then we would either choose
> >> >> based on
> >> >> >> > > > respective counts or just randomly. The main use case of
> >> >> supporting
> >> >> >> the
> >> >> >> > > > list is for rolling upgrades when a change is made to the
> >> >> assignment
> >> >> >> > > > strategy. In that case, the new assignment strategy would be
> >> >> listed
> >> >> >> > first
> >> >> >> > > > in the upgraded client. I think it's debatable whether this
> >> >> feature
> >> >> >> > would
> >> >> >> > > > get much use in practice, so we might consider dropping it.
> >> >> >> > > >
> >> >> >> > > > 2. If the protocols don't agree, the group construction
> fails.
> >> >> What
> >> >> >> > > exactly
> >> >> >> > > > does it mean? Do we send an error in every JoinGroupResponse
> >> and
> >> >> >> remove
> >> >> >> > > all
> >> >> >> > > > members in the group in the coordinator?
> >> >> >> > > >
> >> >> >> > > > Yes, that is right. It would be handled similarly to
> >> inconsistent
> >> >> >> > > > assignment strategies in the current protocol. The
> coordinator
> >> >> >> returns
> >> >> >> > an
> >> >> >> > > > error in each join group response, and the client propagates
> >> the
> >> >> >> error
> >> >> >> > to
> >> >> >> > > > the user.
> >> >> >> > > >
> >> >> >> > > > 3. Consumer embedded protocol: The proposal has two
> different
> >> >> formats
> >> >> >> > of
> >> >> >> > > > subscription depending on whether wildcards are used or not.
> >> This
> >> >> >> > seems a
> >> >> >> > > > bit complicated. Would it be better to always use the
> metadata
> >> >> hash?
> >> >> >> > The
> >> >> >> > > > clients know the subscribed topics already. This way, the
> >> client
> >> >> code
> >> >> >> > > > behaves the same whether wildcards are used or not.
> >> >> >> > > >
> >> >> >> > > > Yeah, I think this is possible (Neha also suggested it). I
> >> haven't
> >> >> >> > > updated
> >> >> >> > > > the wiki yet, but the patch I started working on uses only
> the
> >> >> >> metadata
> >> >> >> > > > hash. In the case that an explicit topic list is provided,
> the
> >> >> hash
> >> >> >> > just
> >> >> >> > > > covers the metadata for those topics.
> >> >> >> > > >
> >> >> >> > > >
> >> >> >> > > > Thanks,
> >> >> >> > > > Jason
> >> >> >> > > >
> >> >> >> > > >
> >> >> >> > > >
> >> >> >> > > > On Tue, Aug 18, 2015 at 10:06 AM, Jun Rao
> >> >> wrote:
> >> >> >> > > >
> >> >> >> > > > > Jason,
> >> >> >> > > > >
> >> >> >> > > > > Thanks for the writeup. A few comments below.
> >> >> >> > > > >
> >> >> >> > > > > 1. When there are multiple common protocols in the
> >> >> >> JoinGroupRequest,
> >> >> >> > > > which
> >> >> >> > > > > one would the coordinator pick?
> >> >> >> > > > > 2. If the protocols don't agree, the group construction
> >> fails.
> >> >> What
> >> >> >> > > > exactly
> >> >> >> > > > > does it mean? Do we send an error in every
> JoinGroupResponse
> >> and
> >> >> >> > remove
> >> >> >> > > > all
> >> >> >> > > > > members in the group in the coordinator?
> >> >> >> > > > > 3. Consumer embedded protocol: The proposal has two
> different
> >> >> >> formats
> >> >> >> > > of
> >> >> >> > > > > subscription depending on whether wildcards are used or
> not.
> >> >> This
> >> >> >> > > seems a
> >> >> >> > > > > bit complicated. Would it be better to always use the
> >> metadata
> >> >> >> hash?
> >> >> >> > > The
> >> >> >> > > > > clients know the subscribed topics already. This way, the
> >> client
> >> >> >> code
> >> >> >> > > > > behaves the same whether wildcards are used or not.
> >> >> >> > > > >
> >> >> >> > > > > Jiangjie,
> >> >> >> > > > >
> >> >> >> > > > > With respect to rebalance churns due to topics being
> >> >> >> created/deleted.
> >> >> >> > > > With
> >> >> >> > > > > the new consumer, the rebalance can probably settle within
> >> 200ms
> >> >> >> when
> >> >> >> > > > there
> >> >> >> > > > > is a topic change. So, as long as we are not changing
> topic
> >> more
> >> >> >> > than 5
> >> >> >> > > > > times per sec, there shouldn't be constant churns, right?
> >> >> >> > > > >
> >> >> >> > > > > Thanks,
> >> >> >> > > > >
> >> >> >> > > > > Jun
> >> >> >> > > > >
> >> >> >> > > > >
> >> >> >> > > > >
> >> >> >> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <
> >> >> >> jason@confluent.io
> >> >> >> > >
> >> >> >> > > > > wrote:
> >> >> >> > > > >
> >> >> >> > > > > > Hi Kafka Devs,
> >> >> >> > > > > >
> >> >> >> > > > > > One of the nagging issues in the current design of the
> new
> >> >> >> consumer
> >> >> >> > > has
> >> >> >> > > > > > been the need to support a variety of assignment
> >> strategies.
> >> >> >> We've
> >> >> >> > > > > > encountered this in particular in the design of copycat
> and
> >> >> the
> >> >> >> > > > > processing
> >> >> >> > > > > > framework (KIP-28). From what I understand, Samza also
> has
> >> a
> >> >> >> number
> >> >> >> > > of
> >> >> >> > > > > use
> >> >> >> > > > > > cases with custom assignment needs. The new consumer
> >> protocol
> >> >> >> > > supports
> >> >> >> > > > > new
> >> >> >> > > > > > assignment strategies by hooking them into the broker.
> For
> >> >> many
> >> >> >> > > > > > environments, this is a major pain and in some cases, a
> >> >> >> > non-starter.
> >> >> >> > > It
> >> >> >> > > > > > also challenges the validation that the coordinator can
> >> >> provide.
> >> >> >> > For
> >> >> >> > > > > > example, some assignment strategies call for partitions
> to
> >> be
> >> >> >> > > assigned
> >> >> >> > > > > > multiple times, which means that the coordinator can
> only
> >> >> check
> >> >> >> > that
> >> >> >> > > > > > partitions have been assigned at least once.
> >> >> >> > > > > >
> >> >> >> > > > > > To solve these issues, we'd like to propose moving
> >> assignment
> >> >> to
> >> >> >> > the
> >> >> >> > > > > > client. I've written a wiki which outlines some protocol
> >> >> changes
> >> >> >> to
> >> >> >> > > > > achieve
> >> >> >> > > > > > this:
> >> >> >> > > > > >
> >> >> >> > > > > >
> >> >> >> > > > >
> >> >> >> > > >
> >> >> >> > >
> >> >> >> >
> >> >> >>
> >> >>
> >>
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> >> >> >> > > > > > .
> >> >> >> > > > > > To summarize briefly, instead of the coordinator
> assigning
> >> the
> >> >> >> > > > partitions
> >> >> >> > > > > > itself, all subscriptions are forwarded to each member
> of
> >> the
> >> >> >> group
> >> >> >> > > > which
> >> >> >> > > > > > then decides independently which partitions it should
> >> consume.
> >> >> >> The
> >> >> >> > > > > protocol
> >> >> >> > > > > > provides a mechanism for the coordinator to validate
> that
> >> all
> >> >> >> > > consumers
> >> >> >> > > > > use
> >> >> >> > > > > > the same assignment strategy, but it does not ensure
> that
> >> the
> >> >> >> > > resulting
> >> >> >> > > > > > assignment is "correct." This provides a powerful
> >> capability
> >> >> for
> >> >> >> > > users
> >> >> >> > > > to
> >> >> >> > > > > > control the full data flow on the client side. They
> control
> >> >> how
> >> >> >> > data
> >> >> >> > > is
> >> >> >> > > > > > written to partitions through the Partitioner interface
> and
> >> >> they
> >> >> >> > > > control
> >> >> >> > > > > > how data is consumed through the assignment strategy,
> all
> >> >> without
> >> >> >> > > > > touching
> >> >> >> > > > > > the server.
> >> >> >> > > > > >
> >> >> >> > > > > > Of course nothing comes for free. In particular, this
> >> change
> >> >> >> > removes
> >> >> >> > > > the
> >> >> >> > > > > > ability of the coordinator to validate that commits are
> >> made
> >> >> by
> >> >> >> > > > consumers
> >> >> >> > > > > > who were assigned the respective partition. This might
> not
> >> be
> >> >> too
> >> >> >> > bad
> >> >> >> > > > > since
> >> >> >> > > > > > we retain the ability to validate the generation id,
> but it
> >> >> is a
> >> >> >> > > > > potential
> >> >> >> > > > > > concern. We have considered alternative protocols which
> >> add a
> >> >> >> > second
> >> >> >> > > > > > round-trip to the protocol in order to give the
> coordinator
> >> >> the
> >> >> >> > > ability
> >> >> >> > > > > to
> >> >> >> > > > > > confirm the assignment. As mentioned above, the
> >> coordinator is
> >> >> >> > > somewhat
> >> >> >> > > > > > limited in what it can actually validate, but this would
> >> >> return
> >> >> >> its
> >> >> >> > > > > ability
> >> >> >> > > > > > to validate commits. The tradeoff is that it increases
> the
> >> >> >> > protocol's
> >> >> >> > > > > > complexity which means more ways for the protocol to
> fail
> >> and
> >> >> >> > > > > consequently
> >> >> >> > > > > > more edge cases in the code.
> >> >> >> > > > > >
> >> >> >> > > > > > It also misses an opportunity to generalize the group
> >> >> membership
> >> >> >> > > > protocol
> >> >> >> > > > > > for additional use cases. In fact, after you've gone to
> the
> >> >> >> trouble
> >> >> >> > > of
> >> >> >> > > > > > moving assignment to the client, the main thing that is
> >> left
> >> >> in
> >> >> >> > this
> >> >> >> > > > > > protocol is basically a general group management
> >> capability.
> >> >> This
> >> >> >> > is
> >> >> >> > > > > > exactly what is needed for a few cases that are
> currently
> >> >> under
> >> >> >> > > > > discussion
> >> >> >> > > > > > (e.g. copycat or single-writer producer). We've taken
> this
> >> >> >> further
> >> >> >> > > step
> >> >> >> > > > > in
> >> >> >> > > > > > the proposal and attempted to envision what that general
> >> >> protocol
> >> >> >> > > might
> >> >> >> > > > > > look like and how it could be used both by the consumer
> and
> >> >> for
> >> >> >> > some
> >> >> >> > > of
> >> >> >> > > > > > these other cases.
> >> >> >> > > > > >
> >> >> >> > > > > > Anyway, since time is running out on the new consumer,
> we
> >> have
> >> >> >> > > perhaps
> >> >> >> > > > > one
> >> >> >> > > > > > last chance to consider a significant change in the
> >> protocol
> >> >> like
> >> >> >> > > this,
> >> >> >> > > > > so
> >> >> >> > > > > > have a look at the wiki and share your thoughts. I've no
> >> doubt
> >> >> >> that
> >> >> >> > > > some
> >> >> >> > > > > > ideas seem clearer in my mind than they do on paper, so
> ask
> >> >> >> > questions
> >> >> >> > > > if
> >> >> >> > > > > > there is any confusion.
> >> >> >> > > > > >
> >> >> >> > > > > > Thanks!
> >> >> >> > > > > > Jason
> >> >> >> > > > > >
> >> >> >> > > > >
> >> >> >> > > >
> >> >> >> > >
> >> >> >> >
> >> >> >>
> >> >> >
> >> >> >
> >> >> >
> >> >> > --
> >> >> > Thanks,
> >> >> > Neha
> >> >>
> >>
>

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Onur Karaman <ok...@linkedin.com.INVALID>.
Yeah I think I brought this up earlier, but I think delete/recreate with
respect to clients will never be right until we introduce the concept of
versioned topics.

On Fri, Aug 28, 2015 at 1:24 PM, Joel Koshy <jj...@gmail.com> wrote:

> Another use-case I was thinking of was something like rack-aware
> assignment of partitions to clients. This would require some
> additional topic metadata to be propagated to and from the coordinator
> and you would need some way to resolve conflicts for such strategies.
> I think that could be addressed by attaching a generation id to the
> metadata and use that (i.e., pick the highest) in order to resolve
> conflicts without another round of join-group requests.
>
> Likewise, without delete/recreate, partition counts are a sort of
> generation id since they are non-decreasing. If we need to account for
> delete/recreate that could perhaps be addressed by an explicit
> (per-topic) generation id attached to each topic in the metadata blob.
> Does that make sense? I think that covers my concerns wrt the
> split-brain issues.
>
> I'm still a bit wary of the n^2*m sized rebroadcast of all the
> metadata - mainly because for various reasons at LinkedIn, we are
> actually using large explicit whitelists (and not wildcards) in
> several of our mirroring pipelines. At this point I feel that is a
> reasonable cost to pay for having all the logic in one place (i.e.,
> client side) but I would like to think a bit more on that.
>
> Joel
>
>
> On Fri, Aug 28, 2015 at 1:02 PM, Onur Karaman
> <ok...@linkedin.com.invalid> wrote:
> > From what I understand, the "largest number of partitions" trick is based
> > on the assumption that topics can only expand their partitions. What
> > happens when a topic gets deleted and recreated? This breaks that
> > assumption.
> >
> > On Fri, Aug 28, 2015 at 6:33 AM, Neha Narkhede <ne...@confluent.io>
> wrote:
> >
> >> Thanks for re-reviewing Joel.
> >>
> >>
> >>
> >>
> >>
> >>
> >> On Fri, Aug 28, 2015 at 2:51 AM -0700, "Joel Koshy" <
> jjkoshy.w@gmail.com>
> >> wrote:
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> > I think we think this proposal addresses 100% of the split brain
> issues
> >> > ever seen in the ZK-based protocol, but I think you think there are
> still
> >> > issues. Can you explain what your thinking of and when you think it
> would
> >> > happen? I want to make sure you aren't assuming
> client-side=>split-brain
> >> > since I think that is totally not the case.
> >>
> >> Yes I had concluded that client-side assignment would still result in
> >> split-brain wrt partition counts, but I overlooked a key sentence in
> >> the wiki - i.e., that the assignment algorithm for consumers can just
> >> use the largest number of partitions for each topic reported by any of
> >> the consumers. i.e., I assumed that consumers would just fail
> >> rebalance if the partition counts were inconsistent but that is not
> >> the case since this conflict can be easily resolved as described
> >> without further join-group requests. Sorry about that. There is still
> >> the issue of the coordinator having to send back n*m worth of
> >> metadata, but that was not my biggest concern. I'll look over it again
> >> and reply back tomorrow.
> >>
> >> Joel
> >>
> >> On Thu, Aug 27, 2015 at 2:55 PM, Jay Kreps  wrote:
> >> > Hey Joel,
> >> >
> >> > I really don't think we should do both. There are pros and cons but we
> >> > should make a decision and work on operationalizing one approach.
> Much of
> >> > really making something like this work is getting all the bugs out,
> >> getting
> >> > monitoring in place, getting rigorous system tests in place. Trying
> to do
> >> > those things twice with the same resources will just mean we do them
> half
> >> > as well. I also think this buys nothing from the user's point of
> >> view--they
> >> > want co-ordination that works correctly, the debate we are having is
> >> purely
> >> > a "how should we build that" debate. So this is really not the kind of
> >> > thing we'd want to make pluggable and if we did that would just
> >> complicate
> >> > life for the user.
> >> >
> >> > I think we think this proposal addresses 100% of the split brain
> issues
> >> > ever seen in the ZK-based protocol, but I think you think there are
> still
> >> > issues. Can you explain what your thinking of and when you think it
> would
> >> > happen? I want to make sure you aren't assuming
> client-side=>split-brain
> >> > since I think that is totally not the case.
> >> >
> >> > With respect to "herd issues" I actually think all the proposals
> address
> >> > this by scaling the co-ordinator out to all nodes and making the
> >> > co-ordination vastly cheaper. No proposal, of course, gets rid of the
> >> fact
> >> > that all clients rejoin at once when there is a membership change, but
> >> that
> >> > is kind of fundamental to the problem.
> >> >
> >> > -Jay
> >> >
> >> > On Thu, Aug 27, 2015 at 2:02 PM, Joel Koshy  wrote:
> >> >
> >> >> I actually feel these set of tests (whatever they may be) are
> somewhat
> >> >> irrelevant here. My main concern with the current client-side
> proposal
> >> >> (i.e., without Becket's follow-up suggestions) is that it makes a
> >> >> significant compromise to the original charter of the new consumer -
> >> >> i.e., reduce/eliminate herd and split brain problems in both group
> >> >> management and partition assignment. I understand the need for
> >> >> client-side partition assignment in some use cases (which we are also
> >> >> interested in), but I also think we should make every effort to keep
> >> >> full server-side coordination for the remaining (majority) of use
> >> >> cases especially if it does not complicate the protocol. The proposed
> >> >> changes do not complicate the protocol IMO - i.e., there is no
> further
> >> >> modification to the request/response formats beyond the current
> >> >> client-side proposal. It only involves a trivial reinterpretation of
> >> >> the content of the protocol metadata field.
> >> >>
> >> >> Joel
> >> >>
> >> >> On Wed, Aug 26, 2015 at 9:33 PM, Neha Narkhede  wrote:
> >> >> > Hey Becket,
> >> >> >
> >> >> > In that case, the broker side partition assignment would be ideal
> >> because
> >> >> >> it avoids
> >> >> >> issues like metadata inconsistency / split brain / exploding
> >> >> subscription
> >> >> >> set propagation.
> >> >> >
> >> >> >
> >> >> > As per our previous discussions regarding each of those concerns
> >> >> (referring
> >> >> > to this email thread, KIP calls and JIRA comments), we are going to
> >> run a
> >> >> > set of tests using the LinkedIn deployment numbers that we will
> wait
> >> for
> >> >> > you to share. The purpose is to see if those concerns are really
> >> valid or
> >> >> > not. I'd prefer to see that before making any more changes that
> will
> >> >> > complicate the protocol.
> >> >> >
> >> >> > On Wed, Aug 26, 2015 at 4:57 PM, Jiangjie Qin > >
> >> >> > wrote:
> >> >> >
> >> >> >> Hi folks,
> >> >> >>
> >> >> >> After further discussion in LinkedIn, we found that while having a
> >> more
> >> >> >> general group management protocol is very useful, the vast
> majority
> >> of
> >> >> the
> >> >> >> clients will not use customized partition assignment strategy. In
> >> that
> >> >> >> case, the broker side partition assignment would be ideal because
> it
> >> >> avoids
> >> >> >> issues like metadata inconsistency / split brain / exploding
> >> >> subscription
> >> >> >> set propagation.
> >> >> >>
> >> >> >> So we have the following proposal that satisfies the majority of
> the
> >> >> >> clients' needs without changing the currently proposed binary
> >> protocol.
> >> >> >> i.e., Continue to support broker-side assignment if the assignment
> >> >> strategy
> >> >> >> is recognized by the coordinator.
> >> >> >>
> >> >> >> 1. Keep the binary protocol as currently proposed.
> >> >> >>
> >> >> >> 2. Change the way we interpret ProtocolMetadata:
> >> >> >> 2.1 On consumer side, change partition.assignment.strategy to
> >> >> >> partition.assignor.class. Implement the something like the
> following
> >> >> >> PartitionAssignor Interface:
> >> >> >>
> >> >> >> public interface PartitionAssignor {
> >> >> >>   List protocolTypes();
> >> >> >>   byte[] protocolMetadata();
> >> >> >>   // return the Topic->List map that are assigned to this
> >> >> >> consumer.
> >> >> >>   List assignPartitions(String protocolType, byte[]
> >> >> >> responseProtocolMetadata);
> >> >> >> }
> >> >> >>
> >> >> >> public abstract class AbstractPartitionAssignor implements
> >> >> >> PartitionAssignor {
> >> >> >>   protected final KafkaConsumer consumer;
> >> >> >>   AbstractPartitionAssignor(KafkaConsumer consumer) {
> >> >> >>     this.consumer = consumer;
> >> >> >>   }
> >> >> >> }
> >> >> >>
> >> >> >> 2.2 The ProtocolMetadata in JoinGroupRequest will be
> >> >> >> partitionAssignor.protocolMetadata(). When
> partition.assignor.class
> >> is
> >> >> >> "range" or "roundrobin", the ProtocolMetadata in JoinGroupRequest
> >> will
> >> >> be a
> >> >> >> JSON subscription set. ("range", "roundrobin" will be reserved
> >> words, we
> >> >> >> can also consider reserving some Prefix such as "broker-" to be
> more
> >> >> clear)
> >> >> >> 2.3 On broker side when ProtocolType is "range" or "roundroubin",
> >> >> >> coordinator will parse the ProtocolMetadata in the
> JoinGroupRequest
> >> and
> >> >> >> assign the partitions for consumers. In the JoinGroupResponse, the
> >> >> >> ProtocolMetadata will be the global assignment of partitions.
> >> >> >> 2.4 On client side, after receiving the JoinGroupResponse,
> >> >> >> partitionAssignor.assignPartitions() will be invoked to return the
> >> >> actual
> >> >> >> assignment. If the assignor is RangeAssignor or
> RoundRobinAssignor,
> >> they
> >> >> >> will parse the assignment from the ProtocolMetadata returned by
> >> >> >> coordinator.
> >> >> >>
> >> >> >> This approach has a few merits:
> >> >> >> 1. Does not change the proposed binary protocol, which is still
> >> general.
> >> >> >> 2. The majority of the consumers will not suffer from inconsistent
> >> >> metadata
> >> >> >> / split brain / exploding subscription set propagation. This is
> >> >> >> specifically to deal with the issue that the current proposal
> caters
> >> to
> >> >> a
> >> >> >> 20% use-case while adversely impacting the more common 80%
> use-cases.
> >> >> >> 3. Easy to implement. The only thing needed is implement a
> >> partitioner
> >> >> >> class. For most users, the default range and roundrobin
> partitioner
> >> are
> >> >> >> good enough.
> >> >> >>
> >> >> >> Thoughts?
> >> >> >>
> >> >> >> Thanks,
> >> >> >>
> >> >> >> Jiangjie (Becket) Qin
> >> >> >>
> >> >> >> On Tue, Aug 18, 2015 at 2:51 PM, Jason Gustafson
> >> >> >> wrote:
> >> >> >>
> >> >> >> > Follow-up from the kip call:
> >> >> >> >
> >> >> >> > 1. Onur brought up the question of whether this protocol
> provides
> >> >> enough
> >> >> >> > coordination capabilities to be generally useful in practice (is
> >> that
> >> >> >> > accurate, Onur?). If it doesn't, then each use case would
> probably
> >> >> need a
> >> >> >> > dependence on zookeeper anyway, and we haven't really gained
> >> anything.
> >> >> >> The
> >> >> >> > group membership provided by this protocol is a useful primitive
> >> for
> >> >> >> > coordination, but it's limited in the sense that everything
> shared
> >> >> among
> >> >> >> > the group has to be communicated at the time the group is
> created.
> >> If
> >> >> any
> >> >> >> > shared data changes, then the only way the group can ensure
> >> agreement
> >> >> is
> >> >> >> to
> >> >> >> > force a rebalance. This is expensive since all members must
> stall
> >> >> while
> >> >> >> the
> >> >> >> > rebalancing takes place. As we have also seen, there is a
> practical
> >> >> limit
> >> >> >> > on the amount of metadata that can be sent through this protocol
> >> when
> >> >> >> > groups get a little larger. This protocol is therefore not
> >> suitable to
> >> >> >> > cases which require frequent communication or which require a
> large
> >> >> >> amount
> >> >> >> > of data to be communicated. For the use cases listed on the
> wiki,
> >> >> neither
> >> >> >> > of these appear to be an issue, but there may be other
> limitations
> >> >> which
> >> >> >> > would limit reuse of the protocol. Perhaps it would be
> sufficient
> >> to
> >> >> >> sketch
> >> >> >> > how these cases might work?
> >> >> >> >
> >> >> >> > 2. We talked a little bit about the issue of metadata churn.
> Becket
> >> >> >> brought
> >> >> >> > up the interesting point that not only do we depend on topic
> >> metadata
> >> >> >> > changing relatively infrequently, but we also expect timely
> >> agreement
> >> >> >> among
> >> >> >> > the brokers on what that metadata is. To resolve this, we can
> have
> >> the
> >> >> >> > consumers fetch metadata from the coordinator. We still depend
> on
> >> >> topic
> >> >> >> > metadata not changing frequently, but this should resolve any
> >> >> >> disagreement
> >> >> >> > among the brokers themselves. In fact, since we expect that
> >> >> disagreement
> >> >> >> is
> >> >> >> > relatively rare, we can have the consumers fetch from the
> >> coordinator
> >> >> >> only
> >> >> >> > when when a disagreement occurs. The nice thing about this
> >> proposal is
> >> >> >> that
> >> >> >> > it doesn't affect the join group semantics, so the coordinator
> >> would
> >> >> >> remain
> >> >> >> > oblivious to the metadata used by the group for agreement.
> Also, if
> >> >> >> > metadata churn becomes an issue, it might be possible to have
> the
> >> >> >> > coordinator provide a snapshot for the group to ensure that a
> >> >> generation
> >> >> >> > would be able to reach agreement (this would probably require
> >> adding
> >> >> >> > groupId/generation to the metadata request).
> >> >> >> >
> >> >> >> > 3. We talked briefly about support for multiple protocols in the
> >> join
> >> >> >> group
> >> >> >> > request in order to allow changing the assignment strategy
> without
> >> >> >> > downtime. I think it's a little doubtful that this would get
> much
> >> use
> >> >> in
> >> >> >> > practice, but I agree it's a nice option to have on the table.
> An
> >> >> >> > alternative, for the sake of argument, is to have each member
> >> provide
> >> >> >> only
> >> >> >> > one version of the protocol, and to let the coordinator choose
> the
> >> >> >> protocol
> >> >> >> > with the largest number of supporters. All members which can't
> >> support
> >> >> >> the
> >> >> >> > selected protocol would be kicked out of the group. The drawback
> >> in a
> >> >> >> > rolling upgrade is that the total capacity of the group would be
> >> >> >> > momentarily halved. It would also be a little tricky to handle
> the
> >> >> case
> >> >> >> of
> >> >> >> > retrying when a consumer is kicked out of the group. We wouldn't
> >> want
> >> >> it
> >> >> >> to
> >> >> >> > be able to effect a rebalance, for example, if it would just be
> >> kicked
> >> >> >> out
> >> >> >> > again. That would probably complicate the group management
> logic on
> >> >> the
> >> >> >> > coordinator.
> >> >> >> >
> >> >> >> >
> >> >> >> > Thanks,
> >> >> >> > Jason
> >> >> >> >
> >> >> >> >
> >> >> >> > On Tue, Aug 18, 2015 at 11:16 AM, Jiangjie Qin
> >> >> > >> >
> >> >> >> > wrote:
> >> >> >> >
> >> >> >> > > Jun,
> >> >> >> > >
> >> >> >> > > Yes, I agree. If the metadata can be synced quickly there
> should
> >> >> not be
> >> >> >> > an
> >> >> >> > > issue. It just occurred to me that there is a proposal to
> allow
> >> >> >> consuming
> >> >> >> > > from followers in ISR, that could potentially cause more
> frequent
> >> >> >> > metadata
> >> >> >> > > change for consumers. Would that be an issue?
> >> >> >> > >
> >> >> >> > > Thanks,
> >> >> >> > >
> >> >> >> > > Jiangjie (Becket) Qin
> >> >> >> > >
> >> >> >> > > On Tue, Aug 18, 2015 at 10:22 AM, Jason Gustafson <
> >> >> jason@confluent.io>
> >> >> >> > > wrote:
> >> >> >> > >
> >> >> >> > > > Hi Jun,
> >> >> >> > > >
> >> >> >> > > > Answers below:
> >> >> >> > > >
> >> >> >> > > > 1. When there are multiple common protocols in the
> >> >> JoinGroupRequest,
> >> >> >> > > which
> >> >> >> > > > one would the coordinator pick?
> >> >> >> > > >
> >> >> >> > > > I was intending to use the list to indicate preference. If
> all
> >> >> group
> >> >> >> > > > members support protocols ["A", "B"] in that order, then we
> >> will
> >> >> >> choose
> >> >> >> > > > "A." If some support ["B", "A"], then we would either choose
> >> >> based on
> >> >> >> > > > respective counts or just randomly. The main use case of
> >> >> supporting
> >> >> >> the
> >> >> >> > > > list is for rolling upgrades when a change is made to the
> >> >> assignment
> >> >> >> > > > strategy. In that case, the new assignment strategy would be
> >> >> listed
> >> >> >> > first
> >> >> >> > > > in the upgraded client. I think it's debatable whether this
> >> >> feature
> >> >> >> > would
> >> >> >> > > > get much use in practice, so we might consider dropping it.
> >> >> >> > > >
> >> >> >> > > > 2. If the protocols don't agree, the group construction
> fails.
> >> >> What
> >> >> >> > > exactly
> >> >> >> > > > does it mean? Do we send an error in every JoinGroupResponse
> >> and
> >> >> >> remove
> >> >> >> > > all
> >> >> >> > > > members in the group in the coordinator?
> >> >> >> > > >
> >> >> >> > > > Yes, that is right. It would be handled similarly to
> >> inconsistent
> >> >> >> > > > assignment strategies in the current protocol. The
> coordinator
> >> >> >> returns
> >> >> >> > an
> >> >> >> > > > error in each join group response, and the client propagates
> >> the
> >> >> >> error
> >> >> >> > to
> >> >> >> > > > the user.
> >> >> >> > > >
> >> >> >> > > > 3. Consumer embedded protocol: The proposal has two
> different
> >> >> formats
> >> >> >> > of
> >> >> >> > > > subscription depending on whether wildcards are used or not.
> >> This
> >> >> >> > seems a
> >> >> >> > > > bit complicated. Would it be better to always use the
> metadata
> >> >> hash?
> >> >> >> > The
> >> >> >> > > > clients know the subscribed topics already. This way, the
> >> client
> >> >> code
> >> >> >> > > > behaves the same whether wildcards are used or not.
> >> >> >> > > >
> >> >> >> > > > Yeah, I think this is possible (Neha also suggested it). I
> >> haven't
> >> >> >> > > updated
> >> >> >> > > > the wiki yet, but the patch I started working on uses only
> the
> >> >> >> metadata
> >> >> >> > > > hash. In the case that an explicit topic list is provided,
> the
> >> >> hash
> >> >> >> > just
> >> >> >> > > > covers the metadata for those topics.
> >> >> >> > > >
> >> >> >> > > >
> >> >> >> > > > Thanks,
> >> >> >> > > > Jason
> >> >> >> > > >
> >> >> >> > > >
> >> >> >> > > >
> >> >> >> > > > On Tue, Aug 18, 2015 at 10:06 AM, Jun Rao
> >> >> wrote:
> >> >> >> > > >
> >> >> >> > > > > Jason,
> >> >> >> > > > >
> >> >> >> > > > > Thanks for the writeup. A few comments below.
> >> >> >> > > > >
> >> >> >> > > > > 1. When there are multiple common protocols in the
> >> >> >> JoinGroupRequest,
> >> >> >> > > > which
> >> >> >> > > > > one would the coordinator pick?
> >> >> >> > > > > 2. If the protocols don't agree, the group construction
> >> fails.
> >> >> What
> >> >> >> > > > exactly
> >> >> >> > > > > does it mean? Do we send an error in every
> JoinGroupResponse
> >> and
> >> >> >> > remove
> >> >> >> > > > all
> >> >> >> > > > > members in the group in the coordinator?
> >> >> >> > > > > 3. Consumer embedded protocol: The proposal has two
> different
> >> >> >> formats
> >> >> >> > > of
> >> >> >> > > > > subscription depending on whether wildcards are used or
> not.
> >> >> This
> >> >> >> > > seems a
> >> >> >> > > > > bit complicated. Would it be better to always use the
> >> metadata
> >> >> >> hash?
> >> >> >> > > The
> >> >> >> > > > > clients know the subscribed topics already. This way, the
> >> client
> >> >> >> code
> >> >> >> > > > > behaves the same whether wildcards are used or not.
> >> >> >> > > > >
> >> >> >> > > > > Jiangjie,
> >> >> >> > > > >
> >> >> >> > > > > With respect to rebalance churns due to topics being
> >> >> >> created/deleted.
> >> >> >> > > > With
> >> >> >> > > > > the new consumer, the rebalance can probably settle within
> >> 200ms
> >> >> >> when
> >> >> >> > > > there
> >> >> >> > > > > is a topic change. So, as long as we are not changing
> topic
> >> more
> >> >> >> > than 5
> >> >> >> > > > > times per sec, there shouldn't be constant churns, right?
> >> >> >> > > > >
> >> >> >> > > > > Thanks,
> >> >> >> > > > >
> >> >> >> > > > > Jun
> >> >> >> > > > >
> >> >> >> > > > >
> >> >> >> > > > >
> >> >> >> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <
> >> >> >> jason@confluent.io
> >> >> >> > >
> >> >> >> > > > > wrote:
> >> >> >> > > > >
> >> >> >> > > > > > Hi Kafka Devs,
> >> >> >> > > > > >
> >> >> >> > > > > > One of the nagging issues in the current design of the
> new
> >> >> >> consumer
> >> >> >> > > has
> >> >> >> > > > > > been the need to support a variety of assignment
> >> strategies.
> >> >> >> We've
> >> >> >> > > > > > encountered this in particular in the design of copycat
> and
> >> >> the
> >> >> >> > > > > processing
> >> >> >> > > > > > framework (KIP-28). From what I understand, Samza also
> has
> >> a
> >> >> >> number
> >> >> >> > > of
> >> >> >> > > > > use
> >> >> >> > > > > > cases with custom assignment needs. The new consumer
> >> protocol
> >> >> >> > > supports
> >> >> >> > > > > new
> >> >> >> > > > > > assignment strategies by hooking them into the broker.
> For
> >> >> many
> >> >> >> > > > > > environments, this is a major pain and in some cases, a
> >> >> >> > non-starter.
> >> >> >> > > It
> >> >> >> > > > > > also challenges the validation that the coordinator can
> >> >> provide.
> >> >> >> > For
> >> >> >> > > > > > example, some assignment strategies call for partitions
> to
> >> be
> >> >> >> > > assigned
> >> >> >> > > > > > multiple times, which means that the coordinator can
> only
> >> >> check
> >> >> >> > that
> >> >> >> > > > > > partitions have been assigned at least once.
> >> >> >> > > > > >
> >> >> >> > > > > > To solve these issues, we'd like to propose moving
> >> assignment
> >> >> to
> >> >> >> > the
> >> >> >> > > > > > client. I've written a wiki which outlines some protocol
> >> >> changes
> >> >> >> to
> >> >> >> > > > > achieve
> >> >> >> > > > > > this:
> >> >> >> > > > > >
> >> >> >> > > > > >
> >> >> >> > > > >
> >> >> >> > > >
> >> >> >> > >
> >> >> >> >
> >> >> >>
> >> >>
> >>
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> >> >> >> > > > > > .
> >> >> >> > > > > > To summarize briefly, instead of the coordinator
> assigning
> >> the
> >> >> >> > > > partitions
> >> >> >> > > > > > itself, all subscriptions are forwarded to each member
> of
> >> the
> >> >> >> group
> >> >> >> > > > which
> >> >> >> > > > > > then decides independently which partitions it should
> >> consume.
> >> >> >> The
> >> >> >> > > > > protocol
> >> >> >> > > > > > provides a mechanism for the coordinator to validate
> that
> >> all
> >> >> >> > > consumers
> >> >> >> > > > > use
> >> >> >> > > > > > the same assignment strategy, but it does not ensure
> that
> >> the
> >> >> >> > > resulting
> >> >> >> > > > > > assignment is "correct." This provides a powerful
> >> capability
> >> >> for
> >> >> >> > > users
> >> >> >> > > > to
> >> >> >> > > > > > control the full data flow on the client side. They
> control
> >> >> how
> >> >> >> > data
> >> >> >> > > is
> >> >> >> > > > > > written to partitions through the Partitioner interface
> and
> >> >> they
> >> >> >> > > > control
> >> >> >> > > > > > how data is consumed through the assignment strategy,
> all
> >> >> without
> >> >> >> > > > > touching
> >> >> >> > > > > > the server.
> >> >> >> > > > > >
> >> >> >> > > > > > Of course nothing comes for free. In particular, this
> >> change
> >> >> >> > removes
> >> >> >> > > > the
> >> >> >> > > > > > ability of the coordinator to validate that commits are
> >> made
> >> >> by
> >> >> >> > > > consumers
> >> >> >> > > > > > who were assigned the respective partition. This might
> not
> >> be
> >> >> too
> >> >> >> > bad
> >> >> >> > > > > since
> >> >> >> > > > > > we retain the ability to validate the generation id,
> but it
> >> >> is a
> >> >> >> > > > > potential
> >> >> >> > > > > > concern. We have considered alternative protocols which
> >> add a
> >> >> >> > second
> >> >> >> > > > > > round-trip to the protocol in order to give the
> coordinator
> >> >> the
> >> >> >> > > ability
> >> >> >> > > > > to
> >> >> >> > > > > > confirm the assignment. As mentioned above, the
> >> coordinator is
> >> >> >> > > somewhat
> >> >> >> > > > > > limited in what it can actually validate, but this would
> >> >> return
> >> >> >> its
> >> >> >> > > > > ability
> >> >> >> > > > > > to validate commits. The tradeoff is that it increases
> the
> >> >> >> > protocol's
> >> >> >> > > > > > complexity which means more ways for the protocol to
> fail
> >> and
> >> >> >> > > > > consequently
> >> >> >> > > > > > more edge cases in the code.
> >> >> >> > > > > >
> >> >> >> > > > > > It also misses an opportunity to generalize the group
> >> >> membership
> >> >> >> > > > protocol
> >> >> >> > > > > > for additional use cases. In fact, after you've gone to
> the
> >> >> >> trouble
> >> >> >> > > of
> >> >> >> > > > > > moving assignment to the client, the main thing that is
> >> left
> >> >> in
> >> >> >> > this
> >> >> >> > > > > > protocol is basically a general group management
> >> capability.
> >> >> This
> >> >> >> > is
> >> >> >> > > > > > exactly what is needed for a few cases that are
> currently
> >> >> under
> >> >> >> > > > > discussion
> >> >> >> > > > > > (e.g. copycat or single-writer producer). We've taken
> this
> >> >> >> further
> >> >> >> > > step
> >> >> >> > > > > in
> >> >> >> > > > > > the proposal and attempted to envision what that general
> >> >> protocol
> >> >> >> > > might
> >> >> >> > > > > > look like and how it could be used both by the consumer
> and
> >> >> for
> >> >> >> > some
> >> >> >> > > of
> >> >> >> > > > > > these other cases.
> >> >> >> > > > > >
> >> >> >> > > > > > Anyway, since time is running out on the new consumer,
> we
> >> have
> >> >> >> > > perhaps
> >> >> >> > > > > one
> >> >> >> > > > > > last chance to consider a significant change in the
> >> protocol
> >> >> like
> >> >> >> > > this,
> >> >> >> > > > > so
> >> >> >> > > > > > have a look at the wiki and share your thoughts. I've no
> >> doubt
> >> >> >> that
> >> >> >> > > > some
> >> >> >> > > > > > ideas seem clearer in my mind than they do on paper, so
> ask
> >> >> >> > questions
> >> >> >> > > > if
> >> >> >> > > > > > there is any confusion.
> >> >> >> > > > > >
> >> >> >> > > > > > Thanks!
> >> >> >> > > > > > Jason
> >> >> >> > > > > >
> >> >> >> > > > >
> >> >> >> > > >
> >> >> >> > >
> >> >> >> >
> >> >> >>
> >> >> >
> >> >> >
> >> >> >
> >> >> > --
> >> >> > Thanks,
> >> >> > Neha
> >> >>
> >>
>

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Joel Koshy <jj...@gmail.com>.
Another use-case I was thinking of was something like rack-aware
assignment of partitions to clients. This would require some
additional topic metadata to be propagated to and from the coordinator
and you would need some way to resolve conflicts for such strategies.
I think that could be addressed by attaching a generation id to the
metadata and use that (i.e., pick the highest) in order to resolve
conflicts without another round of join-group requests.

Likewise, without delete/recreate, partition counts are a sort of
generation id since they are non-decreasing. If we need to account for
delete/recreate that could perhaps be addressed by an explicit
(per-topic) generation id attached to each topic in the metadata blob.
Does that make sense? I think that covers my concerns wrt the
split-brain issues.

I'm still a bit wary of the n^2*m sized rebroadcast of all the
metadata - mainly because for various reasons at LinkedIn, we are
actually using large explicit whitelists (and not wildcards) in
several of our mirroring pipelines. At this point I feel that is a
reasonable cost to pay for having all the logic in one place (i.e.,
client side) but I would like to think a bit more on that.

Joel


On Fri, Aug 28, 2015 at 1:02 PM, Onur Karaman
<ok...@linkedin.com.invalid> wrote:
> From what I understand, the "largest number of partitions" trick is based
> on the assumption that topics can only expand their partitions. What
> happens when a topic gets deleted and recreated? This breaks that
> assumption.
>
> On Fri, Aug 28, 2015 at 6:33 AM, Neha Narkhede <ne...@confluent.io> wrote:
>
>> Thanks for re-reviewing Joel.
>>
>>
>>
>>
>>
>>
>> On Fri, Aug 28, 2015 at 2:51 AM -0700, "Joel Koshy" <jj...@gmail.com>
>> wrote:
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> > I think we think this proposal addresses 100% of the split brain issues
>> > ever seen in the ZK-based protocol, but I think you think there are still
>> > issues. Can you explain what your thinking of and when you think it would
>> > happen? I want to make sure you aren't assuming client-side=>split-brain
>> > since I think that is totally not the case.
>>
>> Yes I had concluded that client-side assignment would still result in
>> split-brain wrt partition counts, but I overlooked a key sentence in
>> the wiki - i.e., that the assignment algorithm for consumers can just
>> use the largest number of partitions for each topic reported by any of
>> the consumers. i.e., I assumed that consumers would just fail
>> rebalance if the partition counts were inconsistent but that is not
>> the case since this conflict can be easily resolved as described
>> without further join-group requests. Sorry about that. There is still
>> the issue of the coordinator having to send back n*m worth of
>> metadata, but that was not my biggest concern. I'll look over it again
>> and reply back tomorrow.
>>
>> Joel
>>
>> On Thu, Aug 27, 2015 at 2:55 PM, Jay Kreps  wrote:
>> > Hey Joel,
>> >
>> > I really don't think we should do both. There are pros and cons but we
>> > should make a decision and work on operationalizing one approach. Much of
>> > really making something like this work is getting all the bugs out,
>> getting
>> > monitoring in place, getting rigorous system tests in place. Trying to do
>> > those things twice with the same resources will just mean we do them half
>> > as well. I also think this buys nothing from the user's point of
>> view--they
>> > want co-ordination that works correctly, the debate we are having is
>> purely
>> > a "how should we build that" debate. So this is really not the kind of
>> > thing we'd want to make pluggable and if we did that would just
>> complicate
>> > life for the user.
>> >
>> > I think we think this proposal addresses 100% of the split brain issues
>> > ever seen in the ZK-based protocol, but I think you think there are still
>> > issues. Can you explain what your thinking of and when you think it would
>> > happen? I want to make sure you aren't assuming client-side=>split-brain
>> > since I think that is totally not the case.
>> >
>> > With respect to "herd issues" I actually think all the proposals address
>> > this by scaling the co-ordinator out to all nodes and making the
>> > co-ordination vastly cheaper. No proposal, of course, gets rid of the
>> fact
>> > that all clients rejoin at once when there is a membership change, but
>> that
>> > is kind of fundamental to the problem.
>> >
>> > -Jay
>> >
>> > On Thu, Aug 27, 2015 at 2:02 PM, Joel Koshy  wrote:
>> >
>> >> I actually feel these set of tests (whatever they may be) are somewhat
>> >> irrelevant here. My main concern with the current client-side proposal
>> >> (i.e., without Becket's follow-up suggestions) is that it makes a
>> >> significant compromise to the original charter of the new consumer -
>> >> i.e., reduce/eliminate herd and split brain problems in both group
>> >> management and partition assignment. I understand the need for
>> >> client-side partition assignment in some use cases (which we are also
>> >> interested in), but I also think we should make every effort to keep
>> >> full server-side coordination for the remaining (majority) of use
>> >> cases especially if it does not complicate the protocol. The proposed
>> >> changes do not complicate the protocol IMO - i.e., there is no further
>> >> modification to the request/response formats beyond the current
>> >> client-side proposal. It only involves a trivial reinterpretation of
>> >> the content of the protocol metadata field.
>> >>
>> >> Joel
>> >>
>> >> On Wed, Aug 26, 2015 at 9:33 PM, Neha Narkhede  wrote:
>> >> > Hey Becket,
>> >> >
>> >> > In that case, the broker side partition assignment would be ideal
>> because
>> >> >> it avoids
>> >> >> issues like metadata inconsistency / split brain / exploding
>> >> subscription
>> >> >> set propagation.
>> >> >
>> >> >
>> >> > As per our previous discussions regarding each of those concerns
>> >> (referring
>> >> > to this email thread, KIP calls and JIRA comments), we are going to
>> run a
>> >> > set of tests using the LinkedIn deployment numbers that we will wait
>> for
>> >> > you to share. The purpose is to see if those concerns are really
>> valid or
>> >> > not. I'd prefer to see that before making any more changes that will
>> >> > complicate the protocol.
>> >> >
>> >> > On Wed, Aug 26, 2015 at 4:57 PM, Jiangjie Qin > >
>> >> > wrote:
>> >> >
>> >> >> Hi folks,
>> >> >>
>> >> >> After further discussion in LinkedIn, we found that while having a
>> more
>> >> >> general group management protocol is very useful, the vast majority
>> of
>> >> the
>> >> >> clients will not use customized partition assignment strategy. In
>> that
>> >> >> case, the broker side partition assignment would be ideal because it
>> >> avoids
>> >> >> issues like metadata inconsistency / split brain / exploding
>> >> subscription
>> >> >> set propagation.
>> >> >>
>> >> >> So we have the following proposal that satisfies the majority of the
>> >> >> clients' needs without changing the currently proposed binary
>> protocol.
>> >> >> i.e., Continue to support broker-side assignment if the assignment
>> >> strategy
>> >> >> is recognized by the coordinator.
>> >> >>
>> >> >> 1. Keep the binary protocol as currently proposed.
>> >> >>
>> >> >> 2. Change the way we interpret ProtocolMetadata:
>> >> >> 2.1 On consumer side, change partition.assignment.strategy to
>> >> >> partition.assignor.class. Implement the something like the following
>> >> >> PartitionAssignor Interface:
>> >> >>
>> >> >> public interface PartitionAssignor {
>> >> >>   List protocolTypes();
>> >> >>   byte[] protocolMetadata();
>> >> >>   // return the Topic->List map that are assigned to this
>> >> >> consumer.
>> >> >>   List assignPartitions(String protocolType, byte[]
>> >> >> responseProtocolMetadata);
>> >> >> }
>> >> >>
>> >> >> public abstract class AbstractPartitionAssignor implements
>> >> >> PartitionAssignor {
>> >> >>   protected final KafkaConsumer consumer;
>> >> >>   AbstractPartitionAssignor(KafkaConsumer consumer) {
>> >> >>     this.consumer = consumer;
>> >> >>   }
>> >> >> }
>> >> >>
>> >> >> 2.2 The ProtocolMetadata in JoinGroupRequest will be
>> >> >> partitionAssignor.protocolMetadata(). When partition.assignor.class
>> is
>> >> >> "range" or "roundrobin", the ProtocolMetadata in JoinGroupRequest
>> will
>> >> be a
>> >> >> JSON subscription set. ("range", "roundrobin" will be reserved
>> words, we
>> >> >> can also consider reserving some Prefix such as "broker-" to be more
>> >> clear)
>> >> >> 2.3 On broker side when ProtocolType is "range" or "roundroubin",
>> >> >> coordinator will parse the ProtocolMetadata in the JoinGroupRequest
>> and
>> >> >> assign the partitions for consumers. In the JoinGroupResponse, the
>> >> >> ProtocolMetadata will be the global assignment of partitions.
>> >> >> 2.4 On client side, after receiving the JoinGroupResponse,
>> >> >> partitionAssignor.assignPartitions() will be invoked to return the
>> >> actual
>> >> >> assignment. If the assignor is RangeAssignor or RoundRobinAssignor,
>> they
>> >> >> will parse the assignment from the ProtocolMetadata returned by
>> >> >> coordinator.
>> >> >>
>> >> >> This approach has a few merits:
>> >> >> 1. Does not change the proposed binary protocol, which is still
>> general.
>> >> >> 2. The majority of the consumers will not suffer from inconsistent
>> >> metadata
>> >> >> / split brain / exploding subscription set propagation. This is
>> >> >> specifically to deal with the issue that the current proposal caters
>> to
>> >> a
>> >> >> 20% use-case while adversely impacting the more common 80% use-cases.
>> >> >> 3. Easy to implement. The only thing needed is implement a
>> partitioner
>> >> >> class. For most users, the default range and roundrobin partitioner
>> are
>> >> >> good enough.
>> >> >>
>> >> >> Thoughts?
>> >> >>
>> >> >> Thanks,
>> >> >>
>> >> >> Jiangjie (Becket) Qin
>> >> >>
>> >> >> On Tue, Aug 18, 2015 at 2:51 PM, Jason Gustafson
>> >> >> wrote:
>> >> >>
>> >> >> > Follow-up from the kip call:
>> >> >> >
>> >> >> > 1. Onur brought up the question of whether this protocol provides
>> >> enough
>> >> >> > coordination capabilities to be generally useful in practice (is
>> that
>> >> >> > accurate, Onur?). If it doesn't, then each use case would probably
>> >> need a
>> >> >> > dependence on zookeeper anyway, and we haven't really gained
>> anything.
>> >> >> The
>> >> >> > group membership provided by this protocol is a useful primitive
>> for
>> >> >> > coordination, but it's limited in the sense that everything shared
>> >> among
>> >> >> > the group has to be communicated at the time the group is created.
>> If
>> >> any
>> >> >> > shared data changes, then the only way the group can ensure
>> agreement
>> >> is
>> >> >> to
>> >> >> > force a rebalance. This is expensive since all members must stall
>> >> while
>> >> >> the
>> >> >> > rebalancing takes place. As we have also seen, there is a practical
>> >> limit
>> >> >> > on the amount of metadata that can be sent through this protocol
>> when
>> >> >> > groups get a little larger. This protocol is therefore not
>> suitable to
>> >> >> > cases which require frequent communication or which require a large
>> >> >> amount
>> >> >> > of data to be communicated. For the use cases listed on the wiki,
>> >> neither
>> >> >> > of these appear to be an issue, but there may be other limitations
>> >> which
>> >> >> > would limit reuse of the protocol. Perhaps it would be sufficient
>> to
>> >> >> sketch
>> >> >> > how these cases might work?
>> >> >> >
>> >> >> > 2. We talked a little bit about the issue of metadata churn. Becket
>> >> >> brought
>> >> >> > up the interesting point that not only do we depend on topic
>> metadata
>> >> >> > changing relatively infrequently, but we also expect timely
>> agreement
>> >> >> among
>> >> >> > the brokers on what that metadata is. To resolve this, we can have
>> the
>> >> >> > consumers fetch metadata from the coordinator. We still depend on
>> >> topic
>> >> >> > metadata not changing frequently, but this should resolve any
>> >> >> disagreement
>> >> >> > among the brokers themselves. In fact, since we expect that
>> >> disagreement
>> >> >> is
>> >> >> > relatively rare, we can have the consumers fetch from the
>> coordinator
>> >> >> only
>> >> >> > when when a disagreement occurs. The nice thing about this
>> proposal is
>> >> >> that
>> >> >> > it doesn't affect the join group semantics, so the coordinator
>> would
>> >> >> remain
>> >> >> > oblivious to the metadata used by the group for agreement. Also, if
>> >> >> > metadata churn becomes an issue, it might be possible to have the
>> >> >> > coordinator provide a snapshot for the group to ensure that a
>> >> generation
>> >> >> > would be able to reach agreement (this would probably require
>> adding
>> >> >> > groupId/generation to the metadata request).
>> >> >> >
>> >> >> > 3. We talked briefly about support for multiple protocols in the
>> join
>> >> >> group
>> >> >> > request in order to allow changing the assignment strategy without
>> >> >> > downtime. I think it's a little doubtful that this would get much
>> use
>> >> in
>> >> >> > practice, but I agree it's a nice option to have on the table. An
>> >> >> > alternative, for the sake of argument, is to have each member
>> provide
>> >> >> only
>> >> >> > one version of the protocol, and to let the coordinator choose the
>> >> >> protocol
>> >> >> > with the largest number of supporters. All members which can't
>> support
>> >> >> the
>> >> >> > selected protocol would be kicked out of the group. The drawback
>> in a
>> >> >> > rolling upgrade is that the total capacity of the group would be
>> >> >> > momentarily halved. It would also be a little tricky to handle the
>> >> case
>> >> >> of
>> >> >> > retrying when a consumer is kicked out of the group. We wouldn't
>> want
>> >> it
>> >> >> to
>> >> >> > be able to effect a rebalance, for example, if it would just be
>> kicked
>> >> >> out
>> >> >> > again. That would probably complicate the group management logic on
>> >> the
>> >> >> > coordinator.
>> >> >> >
>> >> >> >
>> >> >> > Thanks,
>> >> >> > Jason
>> >> >> >
>> >> >> >
>> >> >> > On Tue, Aug 18, 2015 at 11:16 AM, Jiangjie Qin
>> >> > >> >
>> >> >> > wrote:
>> >> >> >
>> >> >> > > Jun,
>> >> >> > >
>> >> >> > > Yes, I agree. If the metadata can be synced quickly there should
>> >> not be
>> >> >> > an
>> >> >> > > issue. It just occurred to me that there is a proposal to allow
>> >> >> consuming
>> >> >> > > from followers in ISR, that could potentially cause more frequent
>> >> >> > metadata
>> >> >> > > change for consumers. Would that be an issue?
>> >> >> > >
>> >> >> > > Thanks,
>> >> >> > >
>> >> >> > > Jiangjie (Becket) Qin
>> >> >> > >
>> >> >> > > On Tue, Aug 18, 2015 at 10:22 AM, Jason Gustafson <
>> >> jason@confluent.io>
>> >> >> > > wrote:
>> >> >> > >
>> >> >> > > > Hi Jun,
>> >> >> > > >
>> >> >> > > > Answers below:
>> >> >> > > >
>> >> >> > > > 1. When there are multiple common protocols in the
>> >> JoinGroupRequest,
>> >> >> > > which
>> >> >> > > > one would the coordinator pick?
>> >> >> > > >
>> >> >> > > > I was intending to use the list to indicate preference. If all
>> >> group
>> >> >> > > > members support protocols ["A", "B"] in that order, then we
>> will
>> >> >> choose
>> >> >> > > > "A." If some support ["B", "A"], then we would either choose
>> >> based on
>> >> >> > > > respective counts or just randomly. The main use case of
>> >> supporting
>> >> >> the
>> >> >> > > > list is for rolling upgrades when a change is made to the
>> >> assignment
>> >> >> > > > strategy. In that case, the new assignment strategy would be
>> >> listed
>> >> >> > first
>> >> >> > > > in the upgraded client. I think it's debatable whether this
>> >> feature
>> >> >> > would
>> >> >> > > > get much use in practice, so we might consider dropping it.
>> >> >> > > >
>> >> >> > > > 2. If the protocols don't agree, the group construction fails.
>> >> What
>> >> >> > > exactly
>> >> >> > > > does it mean? Do we send an error in every JoinGroupResponse
>> and
>> >> >> remove
>> >> >> > > all
>> >> >> > > > members in the group in the coordinator?
>> >> >> > > >
>> >> >> > > > Yes, that is right. It would be handled similarly to
>> inconsistent
>> >> >> > > > assignment strategies in the current protocol. The coordinator
>> >> >> returns
>> >> >> > an
>> >> >> > > > error in each join group response, and the client propagates
>> the
>> >> >> error
>> >> >> > to
>> >> >> > > > the user.
>> >> >> > > >
>> >> >> > > > 3. Consumer embedded protocol: The proposal has two different
>> >> formats
>> >> >> > of
>> >> >> > > > subscription depending on whether wildcards are used or not.
>> This
>> >> >> > seems a
>> >> >> > > > bit complicated. Would it be better to always use the metadata
>> >> hash?
>> >> >> > The
>> >> >> > > > clients know the subscribed topics already. This way, the
>> client
>> >> code
>> >> >> > > > behaves the same whether wildcards are used or not.
>> >> >> > > >
>> >> >> > > > Yeah, I think this is possible (Neha also suggested it). I
>> haven't
>> >> >> > > updated
>> >> >> > > > the wiki yet, but the patch I started working on uses only the
>> >> >> metadata
>> >> >> > > > hash. In the case that an explicit topic list is provided, the
>> >> hash
>> >> >> > just
>> >> >> > > > covers the metadata for those topics.
>> >> >> > > >
>> >> >> > > >
>> >> >> > > > Thanks,
>> >> >> > > > Jason
>> >> >> > > >
>> >> >> > > >
>> >> >> > > >
>> >> >> > > > On Tue, Aug 18, 2015 at 10:06 AM, Jun Rao
>> >> wrote:
>> >> >> > > >
>> >> >> > > > > Jason,
>> >> >> > > > >
>> >> >> > > > > Thanks for the writeup. A few comments below.
>> >> >> > > > >
>> >> >> > > > > 1. When there are multiple common protocols in the
>> >> >> JoinGroupRequest,
>> >> >> > > > which
>> >> >> > > > > one would the coordinator pick?
>> >> >> > > > > 2. If the protocols don't agree, the group construction
>> fails.
>> >> What
>> >> >> > > > exactly
>> >> >> > > > > does it mean? Do we send an error in every JoinGroupResponse
>> and
>> >> >> > remove
>> >> >> > > > all
>> >> >> > > > > members in the group in the coordinator?
>> >> >> > > > > 3. Consumer embedded protocol: The proposal has two different
>> >> >> formats
>> >> >> > > of
>> >> >> > > > > subscription depending on whether wildcards are used or not.
>> >> This
>> >> >> > > seems a
>> >> >> > > > > bit complicated. Would it be better to always use the
>> metadata
>> >> >> hash?
>> >> >> > > The
>> >> >> > > > > clients know the subscribed topics already. This way, the
>> client
>> >> >> code
>> >> >> > > > > behaves the same whether wildcards are used or not.
>> >> >> > > > >
>> >> >> > > > > Jiangjie,
>> >> >> > > > >
>> >> >> > > > > With respect to rebalance churns due to topics being
>> >> >> created/deleted.
>> >> >> > > > With
>> >> >> > > > > the new consumer, the rebalance can probably settle within
>> 200ms
>> >> >> when
>> >> >> > > > there
>> >> >> > > > > is a topic change. So, as long as we are not changing topic
>> more
>> >> >> > than 5
>> >> >> > > > > times per sec, there shouldn't be constant churns, right?
>> >> >> > > > >
>> >> >> > > > > Thanks,
>> >> >> > > > >
>> >> >> > > > > Jun
>> >> >> > > > >
>> >> >> > > > >
>> >> >> > > > >
>> >> >> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <
>> >> >> jason@confluent.io
>> >> >> > >
>> >> >> > > > > wrote:
>> >> >> > > > >
>> >> >> > > > > > Hi Kafka Devs,
>> >> >> > > > > >
>> >> >> > > > > > One of the nagging issues in the current design of the new
>> >> >> consumer
>> >> >> > > has
>> >> >> > > > > > been the need to support a variety of assignment
>> strategies.
>> >> >> We've
>> >> >> > > > > > encountered this in particular in the design of copycat and
>> >> the
>> >> >> > > > > processing
>> >> >> > > > > > framework (KIP-28). From what I understand, Samza also has
>> a
>> >> >> number
>> >> >> > > of
>> >> >> > > > > use
>> >> >> > > > > > cases with custom assignment needs. The new consumer
>> protocol
>> >> >> > > supports
>> >> >> > > > > new
>> >> >> > > > > > assignment strategies by hooking them into the broker. For
>> >> many
>> >> >> > > > > > environments, this is a major pain and in some cases, a
>> >> >> > non-starter.
>> >> >> > > It
>> >> >> > > > > > also challenges the validation that the coordinator can
>> >> provide.
>> >> >> > For
>> >> >> > > > > > example, some assignment strategies call for partitions to
>> be
>> >> >> > > assigned
>> >> >> > > > > > multiple times, which means that the coordinator can only
>> >> check
>> >> >> > that
>> >> >> > > > > > partitions have been assigned at least once.
>> >> >> > > > > >
>> >> >> > > > > > To solve these issues, we'd like to propose moving
>> assignment
>> >> to
>> >> >> > the
>> >> >> > > > > > client. I've written a wiki which outlines some protocol
>> >> changes
>> >> >> to
>> >> >> > > > > achieve
>> >> >> > > > > > this:
>> >> >> > > > > >
>> >> >> > > > > >
>> >> >> > > > >
>> >> >> > > >
>> >> >> > >
>> >> >> >
>> >> >>
>> >>
>> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
>> >> >> > > > > > .
>> >> >> > > > > > To summarize briefly, instead of the coordinator assigning
>> the
>> >> >> > > > partitions
>> >> >> > > > > > itself, all subscriptions are forwarded to each member of
>> the
>> >> >> group
>> >> >> > > > which
>> >> >> > > > > > then decides independently which partitions it should
>> consume.
>> >> >> The
>> >> >> > > > > protocol
>> >> >> > > > > > provides a mechanism for the coordinator to validate that
>> all
>> >> >> > > consumers
>> >> >> > > > > use
>> >> >> > > > > > the same assignment strategy, but it does not ensure that
>> the
>> >> >> > > resulting
>> >> >> > > > > > assignment is "correct." This provides a powerful
>> capability
>> >> for
>> >> >> > > users
>> >> >> > > > to
>> >> >> > > > > > control the full data flow on the client side. They control
>> >> how
>> >> >> > data
>> >> >> > > is
>> >> >> > > > > > written to partitions through the Partitioner interface and
>> >> they
>> >> >> > > > control
>> >> >> > > > > > how data is consumed through the assignment strategy, all
>> >> without
>> >> >> > > > > touching
>> >> >> > > > > > the server.
>> >> >> > > > > >
>> >> >> > > > > > Of course nothing comes for free. In particular, this
>> change
>> >> >> > removes
>> >> >> > > > the
>> >> >> > > > > > ability of the coordinator to validate that commits are
>> made
>> >> by
>> >> >> > > > consumers
>> >> >> > > > > > who were assigned the respective partition. This might not
>> be
>> >> too
>> >> >> > bad
>> >> >> > > > > since
>> >> >> > > > > > we retain the ability to validate the generation id, but it
>> >> is a
>> >> >> > > > > potential
>> >> >> > > > > > concern. We have considered alternative protocols which
>> add a
>> >> >> > second
>> >> >> > > > > > round-trip to the protocol in order to give the coordinator
>> >> the
>> >> >> > > ability
>> >> >> > > > > to
>> >> >> > > > > > confirm the assignment. As mentioned above, the
>> coordinator is
>> >> >> > > somewhat
>> >> >> > > > > > limited in what it can actually validate, but this would
>> >> return
>> >> >> its
>> >> >> > > > > ability
>> >> >> > > > > > to validate commits. The tradeoff is that it increases the
>> >> >> > protocol's
>> >> >> > > > > > complexity which means more ways for the protocol to fail
>> and
>> >> >> > > > > consequently
>> >> >> > > > > > more edge cases in the code.
>> >> >> > > > > >
>> >> >> > > > > > It also misses an opportunity to generalize the group
>> >> membership
>> >> >> > > > protocol
>> >> >> > > > > > for additional use cases. In fact, after you've gone to the
>> >> >> trouble
>> >> >> > > of
>> >> >> > > > > > moving assignment to the client, the main thing that is
>> left
>> >> in
>> >> >> > this
>> >> >> > > > > > protocol is basically a general group management
>> capability.
>> >> This
>> >> >> > is
>> >> >> > > > > > exactly what is needed for a few cases that are currently
>> >> under
>> >> >> > > > > discussion
>> >> >> > > > > > (e.g. copycat or single-writer producer). We've taken this
>> >> >> further
>> >> >> > > step
>> >> >> > > > > in
>> >> >> > > > > > the proposal and attempted to envision what that general
>> >> protocol
>> >> >> > > might
>> >> >> > > > > > look like and how it could be used both by the consumer and
>> >> for
>> >> >> > some
>> >> >> > > of
>> >> >> > > > > > these other cases.
>> >> >> > > > > >
>> >> >> > > > > > Anyway, since time is running out on the new consumer, we
>> have
>> >> >> > > perhaps
>> >> >> > > > > one
>> >> >> > > > > > last chance to consider a significant change in the
>> protocol
>> >> like
>> >> >> > > this,
>> >> >> > > > > so
>> >> >> > > > > > have a look at the wiki and share your thoughts. I've no
>> doubt
>> >> >> that
>> >> >> > > > some
>> >> >> > > > > > ideas seem clearer in my mind than they do on paper, so ask
>> >> >> > questions
>> >> >> > > > if
>> >> >> > > > > > there is any confusion.
>> >> >> > > > > >
>> >> >> > > > > > Thanks!
>> >> >> > > > > > Jason
>> >> >> > > > > >
>> >> >> > > > >
>> >> >> > > >
>> >> >> > >
>> >> >> >
>> >> >>
>> >> >
>> >> >
>> >> >
>> >> > --
>> >> > Thanks,
>> >> > Neha
>> >>
>>

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Onur Karaman <ok...@linkedin.com.INVALID>.
>From what I understand, the "largest number of partitions" trick is based
on the assumption that topics can only expand their partitions. What
happens when a topic gets deleted and recreated? This breaks that
assumption.

On Fri, Aug 28, 2015 at 6:33 AM, Neha Narkhede <ne...@confluent.io> wrote:

> Thanks for re-reviewing Joel.
>
>
>
>
>
>
> On Fri, Aug 28, 2015 at 2:51 AM -0700, "Joel Koshy" <jj...@gmail.com>
> wrote:
>
>
>
>
>
>
>
>
>
>
> > I think we think this proposal addresses 100% of the split brain issues
> > ever seen in the ZK-based protocol, but I think you think there are still
> > issues. Can you explain what your thinking of and when you think it would
> > happen? I want to make sure you aren't assuming client-side=>split-brain
> > since I think that is totally not the case.
>
> Yes I had concluded that client-side assignment would still result in
> split-brain wrt partition counts, but I overlooked a key sentence in
> the wiki - i.e., that the assignment algorithm for consumers can just
> use the largest number of partitions for each topic reported by any of
> the consumers. i.e., I assumed that consumers would just fail
> rebalance if the partition counts were inconsistent but that is not
> the case since this conflict can be easily resolved as described
> without further join-group requests. Sorry about that. There is still
> the issue of the coordinator having to send back n*m worth of
> metadata, but that was not my biggest concern. I'll look over it again
> and reply back tomorrow.
>
> Joel
>
> On Thu, Aug 27, 2015 at 2:55 PM, Jay Kreps  wrote:
> > Hey Joel,
> >
> > I really don't think we should do both. There are pros and cons but we
> > should make a decision and work on operationalizing one approach. Much of
> > really making something like this work is getting all the bugs out,
> getting
> > monitoring in place, getting rigorous system tests in place. Trying to do
> > those things twice with the same resources will just mean we do them half
> > as well. I also think this buys nothing from the user's point of
> view--they
> > want co-ordination that works correctly, the debate we are having is
> purely
> > a "how should we build that" debate. So this is really not the kind of
> > thing we'd want to make pluggable and if we did that would just
> complicate
> > life for the user.
> >
> > I think we think this proposal addresses 100% of the split brain issues
> > ever seen in the ZK-based protocol, but I think you think there are still
> > issues. Can you explain what your thinking of and when you think it would
> > happen? I want to make sure you aren't assuming client-side=>split-brain
> > since I think that is totally not the case.
> >
> > With respect to "herd issues" I actually think all the proposals address
> > this by scaling the co-ordinator out to all nodes and making the
> > co-ordination vastly cheaper. No proposal, of course, gets rid of the
> fact
> > that all clients rejoin at once when there is a membership change, but
> that
> > is kind of fundamental to the problem.
> >
> > -Jay
> >
> > On Thu, Aug 27, 2015 at 2:02 PM, Joel Koshy  wrote:
> >
> >> I actually feel these set of tests (whatever they may be) are somewhat
> >> irrelevant here. My main concern with the current client-side proposal
> >> (i.e., without Becket's follow-up suggestions) is that it makes a
> >> significant compromise to the original charter of the new consumer -
> >> i.e., reduce/eliminate herd and split brain problems in both group
> >> management and partition assignment. I understand the need for
> >> client-side partition assignment in some use cases (which we are also
> >> interested in), but I also think we should make every effort to keep
> >> full server-side coordination for the remaining (majority) of use
> >> cases especially if it does not complicate the protocol. The proposed
> >> changes do not complicate the protocol IMO - i.e., there is no further
> >> modification to the request/response formats beyond the current
> >> client-side proposal. It only involves a trivial reinterpretation of
> >> the content of the protocol metadata field.
> >>
> >> Joel
> >>
> >> On Wed, Aug 26, 2015 at 9:33 PM, Neha Narkhede  wrote:
> >> > Hey Becket,
> >> >
> >> > In that case, the broker side partition assignment would be ideal
> because
> >> >> it avoids
> >> >> issues like metadata inconsistency / split brain / exploding
> >> subscription
> >> >> set propagation.
> >> >
> >> >
> >> > As per our previous discussions regarding each of those concerns
> >> (referring
> >> > to this email thread, KIP calls and JIRA comments), we are going to
> run a
> >> > set of tests using the LinkedIn deployment numbers that we will wait
> for
> >> > you to share. The purpose is to see if those concerns are really
> valid or
> >> > not. I'd prefer to see that before making any more changes that will
> >> > complicate the protocol.
> >> >
> >> > On Wed, Aug 26, 2015 at 4:57 PM, Jiangjie Qin > >
> >> > wrote:
> >> >
> >> >> Hi folks,
> >> >>
> >> >> After further discussion in LinkedIn, we found that while having a
> more
> >> >> general group management protocol is very useful, the vast majority
> of
> >> the
> >> >> clients will not use customized partition assignment strategy. In
> that
> >> >> case, the broker side partition assignment would be ideal because it
> >> avoids
> >> >> issues like metadata inconsistency / split brain / exploding
> >> subscription
> >> >> set propagation.
> >> >>
> >> >> So we have the following proposal that satisfies the majority of the
> >> >> clients' needs without changing the currently proposed binary
> protocol.
> >> >> i.e., Continue to support broker-side assignment if the assignment
> >> strategy
> >> >> is recognized by the coordinator.
> >> >>
> >> >> 1. Keep the binary protocol as currently proposed.
> >> >>
> >> >> 2. Change the way we interpret ProtocolMetadata:
> >> >> 2.1 On consumer side, change partition.assignment.strategy to
> >> >> partition.assignor.class. Implement the something like the following
> >> >> PartitionAssignor Interface:
> >> >>
> >> >> public interface PartitionAssignor {
> >> >>   List protocolTypes();
> >> >>   byte[] protocolMetadata();
> >> >>   // return the Topic->List map that are assigned to this
> >> >> consumer.
> >> >>   List assignPartitions(String protocolType, byte[]
> >> >> responseProtocolMetadata);
> >> >> }
> >> >>
> >> >> public abstract class AbstractPartitionAssignor implements
> >> >> PartitionAssignor {
> >> >>   protected final KafkaConsumer consumer;
> >> >>   AbstractPartitionAssignor(KafkaConsumer consumer) {
> >> >>     this.consumer = consumer;
> >> >>   }
> >> >> }
> >> >>
> >> >> 2.2 The ProtocolMetadata in JoinGroupRequest will be
> >> >> partitionAssignor.protocolMetadata(). When partition.assignor.class
> is
> >> >> "range" or "roundrobin", the ProtocolMetadata in JoinGroupRequest
> will
> >> be a
> >> >> JSON subscription set. ("range", "roundrobin" will be reserved
> words, we
> >> >> can also consider reserving some Prefix such as "broker-" to be more
> >> clear)
> >> >> 2.3 On broker side when ProtocolType is "range" or "roundroubin",
> >> >> coordinator will parse the ProtocolMetadata in the JoinGroupRequest
> and
> >> >> assign the partitions for consumers. In the JoinGroupResponse, the
> >> >> ProtocolMetadata will be the global assignment of partitions.
> >> >> 2.4 On client side, after receiving the JoinGroupResponse,
> >> >> partitionAssignor.assignPartitions() will be invoked to return the
> >> actual
> >> >> assignment. If the assignor is RangeAssignor or RoundRobinAssignor,
> they
> >> >> will parse the assignment from the ProtocolMetadata returned by
> >> >> coordinator.
> >> >>
> >> >> This approach has a few merits:
> >> >> 1. Does not change the proposed binary protocol, which is still
> general.
> >> >> 2. The majority of the consumers will not suffer from inconsistent
> >> metadata
> >> >> / split brain / exploding subscription set propagation. This is
> >> >> specifically to deal with the issue that the current proposal caters
> to
> >> a
> >> >> 20% use-case while adversely impacting the more common 80% use-cases.
> >> >> 3. Easy to implement. The only thing needed is implement a
> partitioner
> >> >> class. For most users, the default range and roundrobin partitioner
> are
> >> >> good enough.
> >> >>
> >> >> Thoughts?
> >> >>
> >> >> Thanks,
> >> >>
> >> >> Jiangjie (Becket) Qin
> >> >>
> >> >> On Tue, Aug 18, 2015 at 2:51 PM, Jason Gustafson
> >> >> wrote:
> >> >>
> >> >> > Follow-up from the kip call:
> >> >> >
> >> >> > 1. Onur brought up the question of whether this protocol provides
> >> enough
> >> >> > coordination capabilities to be generally useful in practice (is
> that
> >> >> > accurate, Onur?). If it doesn't, then each use case would probably
> >> need a
> >> >> > dependence on zookeeper anyway, and we haven't really gained
> anything.
> >> >> The
> >> >> > group membership provided by this protocol is a useful primitive
> for
> >> >> > coordination, but it's limited in the sense that everything shared
> >> among
> >> >> > the group has to be communicated at the time the group is created.
> If
> >> any
> >> >> > shared data changes, then the only way the group can ensure
> agreement
> >> is
> >> >> to
> >> >> > force a rebalance. This is expensive since all members must stall
> >> while
> >> >> the
> >> >> > rebalancing takes place. As we have also seen, there is a practical
> >> limit
> >> >> > on the amount of metadata that can be sent through this protocol
> when
> >> >> > groups get a little larger. This protocol is therefore not
> suitable to
> >> >> > cases which require frequent communication or which require a large
> >> >> amount
> >> >> > of data to be communicated. For the use cases listed on the wiki,
> >> neither
> >> >> > of these appear to be an issue, but there may be other limitations
> >> which
> >> >> > would limit reuse of the protocol. Perhaps it would be sufficient
> to
> >> >> sketch
> >> >> > how these cases might work?
> >> >> >
> >> >> > 2. We talked a little bit about the issue of metadata churn. Becket
> >> >> brought
> >> >> > up the interesting point that not only do we depend on topic
> metadata
> >> >> > changing relatively infrequently, but we also expect timely
> agreement
> >> >> among
> >> >> > the brokers on what that metadata is. To resolve this, we can have
> the
> >> >> > consumers fetch metadata from the coordinator. We still depend on
> >> topic
> >> >> > metadata not changing frequently, but this should resolve any
> >> >> disagreement
> >> >> > among the brokers themselves. In fact, since we expect that
> >> disagreement
> >> >> is
> >> >> > relatively rare, we can have the consumers fetch from the
> coordinator
> >> >> only
> >> >> > when when a disagreement occurs. The nice thing about this
> proposal is
> >> >> that
> >> >> > it doesn't affect the join group semantics, so the coordinator
> would
> >> >> remain
> >> >> > oblivious to the metadata used by the group for agreement. Also, if
> >> >> > metadata churn becomes an issue, it might be possible to have the
> >> >> > coordinator provide a snapshot for the group to ensure that a
> >> generation
> >> >> > would be able to reach agreement (this would probably require
> adding
> >> >> > groupId/generation to the metadata request).
> >> >> >
> >> >> > 3. We talked briefly about support for multiple protocols in the
> join
> >> >> group
> >> >> > request in order to allow changing the assignment strategy without
> >> >> > downtime. I think it's a little doubtful that this would get much
> use
> >> in
> >> >> > practice, but I agree it's a nice option to have on the table. An
> >> >> > alternative, for the sake of argument, is to have each member
> provide
> >> >> only
> >> >> > one version of the protocol, and to let the coordinator choose the
> >> >> protocol
> >> >> > with the largest number of supporters. All members which can't
> support
> >> >> the
> >> >> > selected protocol would be kicked out of the group. The drawback
> in a
> >> >> > rolling upgrade is that the total capacity of the group would be
> >> >> > momentarily halved. It would also be a little tricky to handle the
> >> case
> >> >> of
> >> >> > retrying when a consumer is kicked out of the group. We wouldn't
> want
> >> it
> >> >> to
> >> >> > be able to effect a rebalance, for example, if it would just be
> kicked
> >> >> out
> >> >> > again. That would probably complicate the group management logic on
> >> the
> >> >> > coordinator.
> >> >> >
> >> >> >
> >> >> > Thanks,
> >> >> > Jason
> >> >> >
> >> >> >
> >> >> > On Tue, Aug 18, 2015 at 11:16 AM, Jiangjie Qin
> >> > >> >
> >> >> > wrote:
> >> >> >
> >> >> > > Jun,
> >> >> > >
> >> >> > > Yes, I agree. If the metadata can be synced quickly there should
> >> not be
> >> >> > an
> >> >> > > issue. It just occurred to me that there is a proposal to allow
> >> >> consuming
> >> >> > > from followers in ISR, that could potentially cause more frequent
> >> >> > metadata
> >> >> > > change for consumers. Would that be an issue?
> >> >> > >
> >> >> > > Thanks,
> >> >> > >
> >> >> > > Jiangjie (Becket) Qin
> >> >> > >
> >> >> > > On Tue, Aug 18, 2015 at 10:22 AM, Jason Gustafson <
> >> jason@confluent.io>
> >> >> > > wrote:
> >> >> > >
> >> >> > > > Hi Jun,
> >> >> > > >
> >> >> > > > Answers below:
> >> >> > > >
> >> >> > > > 1. When there are multiple common protocols in the
> >> JoinGroupRequest,
> >> >> > > which
> >> >> > > > one would the coordinator pick?
> >> >> > > >
> >> >> > > > I was intending to use the list to indicate preference. If all
> >> group
> >> >> > > > members support protocols ["A", "B"] in that order, then we
> will
> >> >> choose
> >> >> > > > "A." If some support ["B", "A"], then we would either choose
> >> based on
> >> >> > > > respective counts or just randomly. The main use case of
> >> supporting
> >> >> the
> >> >> > > > list is for rolling upgrades when a change is made to the
> >> assignment
> >> >> > > > strategy. In that case, the new assignment strategy would be
> >> listed
> >> >> > first
> >> >> > > > in the upgraded client. I think it's debatable whether this
> >> feature
> >> >> > would
> >> >> > > > get much use in practice, so we might consider dropping it.
> >> >> > > >
> >> >> > > > 2. If the protocols don't agree, the group construction fails.
> >> What
> >> >> > > exactly
> >> >> > > > does it mean? Do we send an error in every JoinGroupResponse
> and
> >> >> remove
> >> >> > > all
> >> >> > > > members in the group in the coordinator?
> >> >> > > >
> >> >> > > > Yes, that is right. It would be handled similarly to
> inconsistent
> >> >> > > > assignment strategies in the current protocol. The coordinator
> >> >> returns
> >> >> > an
> >> >> > > > error in each join group response, and the client propagates
> the
> >> >> error
> >> >> > to
> >> >> > > > the user.
> >> >> > > >
> >> >> > > > 3. Consumer embedded protocol: The proposal has two different
> >> formats
> >> >> > of
> >> >> > > > subscription depending on whether wildcards are used or not.
> This
> >> >> > seems a
> >> >> > > > bit complicated. Would it be better to always use the metadata
> >> hash?
> >> >> > The
> >> >> > > > clients know the subscribed topics already. This way, the
> client
> >> code
> >> >> > > > behaves the same whether wildcards are used or not.
> >> >> > > >
> >> >> > > > Yeah, I think this is possible (Neha also suggested it). I
> haven't
> >> >> > > updated
> >> >> > > > the wiki yet, but the patch I started working on uses only the
> >> >> metadata
> >> >> > > > hash. In the case that an explicit topic list is provided, the
> >> hash
> >> >> > just
> >> >> > > > covers the metadata for those topics.
> >> >> > > >
> >> >> > > >
> >> >> > > > Thanks,
> >> >> > > > Jason
> >> >> > > >
> >> >> > > >
> >> >> > > >
> >> >> > > > On Tue, Aug 18, 2015 at 10:06 AM, Jun Rao
> >> wrote:
> >> >> > > >
> >> >> > > > > Jason,
> >> >> > > > >
> >> >> > > > > Thanks for the writeup. A few comments below.
> >> >> > > > >
> >> >> > > > > 1. When there are multiple common protocols in the
> >> >> JoinGroupRequest,
> >> >> > > > which
> >> >> > > > > one would the coordinator pick?
> >> >> > > > > 2. If the protocols don't agree, the group construction
> fails.
> >> What
> >> >> > > > exactly
> >> >> > > > > does it mean? Do we send an error in every JoinGroupResponse
> and
> >> >> > remove
> >> >> > > > all
> >> >> > > > > members in the group in the coordinator?
> >> >> > > > > 3. Consumer embedded protocol: The proposal has two different
> >> >> formats
> >> >> > > of
> >> >> > > > > subscription depending on whether wildcards are used or not.
> >> This
> >> >> > > seems a
> >> >> > > > > bit complicated. Would it be better to always use the
> metadata
> >> >> hash?
> >> >> > > The
> >> >> > > > > clients know the subscribed topics already. This way, the
> client
> >> >> code
> >> >> > > > > behaves the same whether wildcards are used or not.
> >> >> > > > >
> >> >> > > > > Jiangjie,
> >> >> > > > >
> >> >> > > > > With respect to rebalance churns due to topics being
> >> >> created/deleted.
> >> >> > > > With
> >> >> > > > > the new consumer, the rebalance can probably settle within
> 200ms
> >> >> when
> >> >> > > > there
> >> >> > > > > is a topic change. So, as long as we are not changing topic
> more
> >> >> > than 5
> >> >> > > > > times per sec, there shouldn't be constant churns, right?
> >> >> > > > >
> >> >> > > > > Thanks,
> >> >> > > > >
> >> >> > > > > Jun
> >> >> > > > >
> >> >> > > > >
> >> >> > > > >
> >> >> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <
> >> >> jason@confluent.io
> >> >> > >
> >> >> > > > > wrote:
> >> >> > > > >
> >> >> > > > > > Hi Kafka Devs,
> >> >> > > > > >
> >> >> > > > > > One of the nagging issues in the current design of the new
> >> >> consumer
> >> >> > > has
> >> >> > > > > > been the need to support a variety of assignment
> strategies.
> >> >> We've
> >> >> > > > > > encountered this in particular in the design of copycat and
> >> the
> >> >> > > > > processing
> >> >> > > > > > framework (KIP-28). From what I understand, Samza also has
> a
> >> >> number
> >> >> > > of
> >> >> > > > > use
> >> >> > > > > > cases with custom assignment needs. The new consumer
> protocol
> >> >> > > supports
> >> >> > > > > new
> >> >> > > > > > assignment strategies by hooking them into the broker. For
> >> many
> >> >> > > > > > environments, this is a major pain and in some cases, a
> >> >> > non-starter.
> >> >> > > It
> >> >> > > > > > also challenges the validation that the coordinator can
> >> provide.
> >> >> > For
> >> >> > > > > > example, some assignment strategies call for partitions to
> be
> >> >> > > assigned
> >> >> > > > > > multiple times, which means that the coordinator can only
> >> check
> >> >> > that
> >> >> > > > > > partitions have been assigned at least once.
> >> >> > > > > >
> >> >> > > > > > To solve these issues, we'd like to propose moving
> assignment
> >> to
> >> >> > the
> >> >> > > > > > client. I've written a wiki which outlines some protocol
> >> changes
> >> >> to
> >> >> > > > > achieve
> >> >> > > > > > this:
> >> >> > > > > >
> >> >> > > > > >
> >> >> > > > >
> >> >> > > >
> >> >> > >
> >> >> >
> >> >>
> >>
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> >> >> > > > > > .
> >> >> > > > > > To summarize briefly, instead of the coordinator assigning
> the
> >> >> > > > partitions
> >> >> > > > > > itself, all subscriptions are forwarded to each member of
> the
> >> >> group
> >> >> > > > which
> >> >> > > > > > then decides independently which partitions it should
> consume.
> >> >> The
> >> >> > > > > protocol
> >> >> > > > > > provides a mechanism for the coordinator to validate that
> all
> >> >> > > consumers
> >> >> > > > > use
> >> >> > > > > > the same assignment strategy, but it does not ensure that
> the
> >> >> > > resulting
> >> >> > > > > > assignment is "correct." This provides a powerful
> capability
> >> for
> >> >> > > users
> >> >> > > > to
> >> >> > > > > > control the full data flow on the client side. They control
> >> how
> >> >> > data
> >> >> > > is
> >> >> > > > > > written to partitions through the Partitioner interface and
> >> they
> >> >> > > > control
> >> >> > > > > > how data is consumed through the assignment strategy, all
> >> without
> >> >> > > > > touching
> >> >> > > > > > the server.
> >> >> > > > > >
> >> >> > > > > > Of course nothing comes for free. In particular, this
> change
> >> >> > removes
> >> >> > > > the
> >> >> > > > > > ability of the coordinator to validate that commits are
> made
> >> by
> >> >> > > > consumers
> >> >> > > > > > who were assigned the respective partition. This might not
> be
> >> too
> >> >> > bad
> >> >> > > > > since
> >> >> > > > > > we retain the ability to validate the generation id, but it
> >> is a
> >> >> > > > > potential
> >> >> > > > > > concern. We have considered alternative protocols which
> add a
> >> >> > second
> >> >> > > > > > round-trip to the protocol in order to give the coordinator
> >> the
> >> >> > > ability
> >> >> > > > > to
> >> >> > > > > > confirm the assignment. As mentioned above, the
> coordinator is
> >> >> > > somewhat
> >> >> > > > > > limited in what it can actually validate, but this would
> >> return
> >> >> its
> >> >> > > > > ability
> >> >> > > > > > to validate commits. The tradeoff is that it increases the
> >> >> > protocol's
> >> >> > > > > > complexity which means more ways for the protocol to fail
> and
> >> >> > > > > consequently
> >> >> > > > > > more edge cases in the code.
> >> >> > > > > >
> >> >> > > > > > It also misses an opportunity to generalize the group
> >> membership
> >> >> > > > protocol
> >> >> > > > > > for additional use cases. In fact, after you've gone to the
> >> >> trouble
> >> >> > > of
> >> >> > > > > > moving assignment to the client, the main thing that is
> left
> >> in
> >> >> > this
> >> >> > > > > > protocol is basically a general group management
> capability.
> >> This
> >> >> > is
> >> >> > > > > > exactly what is needed for a few cases that are currently
> >> under
> >> >> > > > > discussion
> >> >> > > > > > (e.g. copycat or single-writer producer). We've taken this
> >> >> further
> >> >> > > step
> >> >> > > > > in
> >> >> > > > > > the proposal and attempted to envision what that general
> >> protocol
> >> >> > > might
> >> >> > > > > > look like and how it could be used both by the consumer and
> >> for
> >> >> > some
> >> >> > > of
> >> >> > > > > > these other cases.
> >> >> > > > > >
> >> >> > > > > > Anyway, since time is running out on the new consumer, we
> have
> >> >> > > perhaps
> >> >> > > > > one
> >> >> > > > > > last chance to consider a significant change in the
> protocol
> >> like
> >> >> > > this,
> >> >> > > > > so
> >> >> > > > > > have a look at the wiki and share your thoughts. I've no
> doubt
> >> >> that
> >> >> > > > some
> >> >> > > > > > ideas seem clearer in my mind than they do on paper, so ask
> >> >> > questions
> >> >> > > > if
> >> >> > > > > > there is any confusion.
> >> >> > > > > >
> >> >> > > > > > Thanks!
> >> >> > > > > > Jason
> >> >> > > > > >
> >> >> > > > >
> >> >> > > >
> >> >> > >
> >> >> >
> >> >>
> >> >
> >> >
> >> >
> >> > --
> >> > Thanks,
> >> > Neha
> >>
>

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Neha Narkhede <ne...@confluent.io>.
Thanks for re-reviewing Joel. 






On Fri, Aug 28, 2015 at 2:51 AM -0700, "Joel Koshy" <jj...@gmail.com> wrote:










> I think we think this proposal addresses 100% of the split brain issues
> ever seen in the ZK-based protocol, but I think you think there are still
> issues. Can you explain what your thinking of and when you think it would
> happen? I want to make sure you aren't assuming client-side=>split-brain
> since I think that is totally not the case.

Yes I had concluded that client-side assignment would still result in
split-brain wrt partition counts, but I overlooked a key sentence in
the wiki - i.e., that the assignment algorithm for consumers can just
use the largest number of partitions for each topic reported by any of
the consumers. i.e., I assumed that consumers would just fail
rebalance if the partition counts were inconsistent but that is not
the case since this conflict can be easily resolved as described
without further join-group requests. Sorry about that. There is still
the issue of the coordinator having to send back n*m worth of
metadata, but that was not my biggest concern. I'll look over it again
and reply back tomorrow.

Joel

On Thu, Aug 27, 2015 at 2:55 PM, Jay Kreps  wrote:
> Hey Joel,
>
> I really don't think we should do both. There are pros and cons but we
> should make a decision and work on operationalizing one approach. Much of
> really making something like this work is getting all the bugs out, getting
> monitoring in place, getting rigorous system tests in place. Trying to do
> those things twice with the same resources will just mean we do them half
> as well. I also think this buys nothing from the user's point of view--they
> want co-ordination that works correctly, the debate we are having is purely
> a "how should we build that" debate. So this is really not the kind of
> thing we'd want to make pluggable and if we did that would just complicate
> life for the user.
>
> I think we think this proposal addresses 100% of the split brain issues
> ever seen in the ZK-based protocol, but I think you think there are still
> issues. Can you explain what your thinking of and when you think it would
> happen? I want to make sure you aren't assuming client-side=>split-brain
> since I think that is totally not the case.
>
> With respect to "herd issues" I actually think all the proposals address
> this by scaling the co-ordinator out to all nodes and making the
> co-ordination vastly cheaper. No proposal, of course, gets rid of the fact
> that all clients rejoin at once when there is a membership change, but that
> is kind of fundamental to the problem.
>
> -Jay
>
> On Thu, Aug 27, 2015 at 2:02 PM, Joel Koshy  wrote:
>
>> I actually feel these set of tests (whatever they may be) are somewhat
>> irrelevant here. My main concern with the current client-side proposal
>> (i.e., without Becket's follow-up suggestions) is that it makes a
>> significant compromise to the original charter of the new consumer -
>> i.e., reduce/eliminate herd and split brain problems in both group
>> management and partition assignment. I understand the need for
>> client-side partition assignment in some use cases (which we are also
>> interested in), but I also think we should make every effort to keep
>> full server-side coordination for the remaining (majority) of use
>> cases especially if it does not complicate the protocol. The proposed
>> changes do not complicate the protocol IMO - i.e., there is no further
>> modification to the request/response formats beyond the current
>> client-side proposal. It only involves a trivial reinterpretation of
>> the content of the protocol metadata field.
>>
>> Joel
>>
>> On Wed, Aug 26, 2015 at 9:33 PM, Neha Narkhede  wrote:
>> > Hey Becket,
>> >
>> > In that case, the broker side partition assignment would be ideal because
>> >> it avoids
>> >> issues like metadata inconsistency / split brain / exploding
>> subscription
>> >> set propagation.
>> >
>> >
>> > As per our previous discussions regarding each of those concerns
>> (referring
>> > to this email thread, KIP calls and JIRA comments), we are going to run a
>> > set of tests using the LinkedIn deployment numbers that we will wait for
>> > you to share. The purpose is to see if those concerns are really valid or
>> > not. I'd prefer to see that before making any more changes that will
>> > complicate the protocol.
>> >
>> > On Wed, Aug 26, 2015 at 4:57 PM, Jiangjie Qin > >
>> > wrote:
>> >
>> >> Hi folks,
>> >>
>> >> After further discussion in LinkedIn, we found that while having a more
>> >> general group management protocol is very useful, the vast majority of
>> the
>> >> clients will not use customized partition assignment strategy. In that
>> >> case, the broker side partition assignment would be ideal because it
>> avoids
>> >> issues like metadata inconsistency / split brain / exploding
>> subscription
>> >> set propagation.
>> >>
>> >> So we have the following proposal that satisfies the majority of the
>> >> clients' needs without changing the currently proposed binary protocol.
>> >> i.e., Continue to support broker-side assignment if the assignment
>> strategy
>> >> is recognized by the coordinator.
>> >>
>> >> 1. Keep the binary protocol as currently proposed.
>> >>
>> >> 2. Change the way we interpret ProtocolMetadata:
>> >> 2.1 On consumer side, change partition.assignment.strategy to
>> >> partition.assignor.class. Implement the something like the following
>> >> PartitionAssignor Interface:
>> >>
>> >> public interface PartitionAssignor {
>> >>   List protocolTypes();
>> >>   byte[] protocolMetadata();
>> >>   // return the Topic->List map that are assigned to this
>> >> consumer.
>> >>   List assignPartitions(String protocolType, byte[]
>> >> responseProtocolMetadata);
>> >> }
>> >>
>> >> public abstract class AbstractPartitionAssignor implements
>> >> PartitionAssignor {
>> >>   protected final KafkaConsumer consumer;
>> >>   AbstractPartitionAssignor(KafkaConsumer consumer) {
>> >>     this.consumer = consumer;
>> >>   }
>> >> }
>> >>
>> >> 2.2 The ProtocolMetadata in JoinGroupRequest will be
>> >> partitionAssignor.protocolMetadata(). When partition.assignor.class is
>> >> "range" or "roundrobin", the ProtocolMetadata in JoinGroupRequest will
>> be a
>> >> JSON subscription set. ("range", "roundrobin" will be reserved words, we
>> >> can also consider reserving some Prefix such as "broker-" to be more
>> clear)
>> >> 2.3 On broker side when ProtocolType is "range" or "roundroubin",
>> >> coordinator will parse the ProtocolMetadata in the JoinGroupRequest and
>> >> assign the partitions for consumers. In the JoinGroupResponse, the
>> >> ProtocolMetadata will be the global assignment of partitions.
>> >> 2.4 On client side, after receiving the JoinGroupResponse,
>> >> partitionAssignor.assignPartitions() will be invoked to return the
>> actual
>> >> assignment. If the assignor is RangeAssignor or RoundRobinAssignor, they
>> >> will parse the assignment from the ProtocolMetadata returned by
>> >> coordinator.
>> >>
>> >> This approach has a few merits:
>> >> 1. Does not change the proposed binary protocol, which is still general.
>> >> 2. The majority of the consumers will not suffer from inconsistent
>> metadata
>> >> / split brain / exploding subscription set propagation. This is
>> >> specifically to deal with the issue that the current proposal caters to
>> a
>> >> 20% use-case while adversely impacting the more common 80% use-cases.
>> >> 3. Easy to implement. The only thing needed is implement a partitioner
>> >> class. For most users, the default range and roundrobin partitioner are
>> >> good enough.
>> >>
>> >> Thoughts?
>> >>
>> >> Thanks,
>> >>
>> >> Jiangjie (Becket) Qin
>> >>
>> >> On Tue, Aug 18, 2015 at 2:51 PM, Jason Gustafson 
>> >> wrote:
>> >>
>> >> > Follow-up from the kip call:
>> >> >
>> >> > 1. Onur brought up the question of whether this protocol provides
>> enough
>> >> > coordination capabilities to be generally useful in practice (is that
>> >> > accurate, Onur?). If it doesn't, then each use case would probably
>> need a
>> >> > dependence on zookeeper anyway, and we haven't really gained anything.
>> >> The
>> >> > group membership provided by this protocol is a useful primitive for
>> >> > coordination, but it's limited in the sense that everything shared
>> among
>> >> > the group has to be communicated at the time the group is created. If
>> any
>> >> > shared data changes, then the only way the group can ensure agreement
>> is
>> >> to
>> >> > force a rebalance. This is expensive since all members must stall
>> while
>> >> the
>> >> > rebalancing takes place. As we have also seen, there is a practical
>> limit
>> >> > on the amount of metadata that can be sent through this protocol when
>> >> > groups get a little larger. This protocol is therefore not suitable to
>> >> > cases which require frequent communication or which require a large
>> >> amount
>> >> > of data to be communicated. For the use cases listed on the wiki,
>> neither
>> >> > of these appear to be an issue, but there may be other limitations
>> which
>> >> > would limit reuse of the protocol. Perhaps it would be sufficient to
>> >> sketch
>> >> > how these cases might work?
>> >> >
>> >> > 2. We talked a little bit about the issue of metadata churn. Becket
>> >> brought
>> >> > up the interesting point that not only do we depend on topic metadata
>> >> > changing relatively infrequently, but we also expect timely agreement
>> >> among
>> >> > the brokers on what that metadata is. To resolve this, we can have the
>> >> > consumers fetch metadata from the coordinator. We still depend on
>> topic
>> >> > metadata not changing frequently, but this should resolve any
>> >> disagreement
>> >> > among the brokers themselves. In fact, since we expect that
>> disagreement
>> >> is
>> >> > relatively rare, we can have the consumers fetch from the coordinator
>> >> only
>> >> > when when a disagreement occurs. The nice thing about this proposal is
>> >> that
>> >> > it doesn't affect the join group semantics, so the coordinator would
>> >> remain
>> >> > oblivious to the metadata used by the group for agreement. Also, if
>> >> > metadata churn becomes an issue, it might be possible to have the
>> >> > coordinator provide a snapshot for the group to ensure that a
>> generation
>> >> > would be able to reach agreement (this would probably require adding
>> >> > groupId/generation to the metadata request).
>> >> >
>> >> > 3. We talked briefly about support for multiple protocols in the join
>> >> group
>> >> > request in order to allow changing the assignment strategy without
>> >> > downtime. I think it's a little doubtful that this would get much use
>> in
>> >> > practice, but I agree it's a nice option to have on the table. An
>> >> > alternative, for the sake of argument, is to have each member provide
>> >> only
>> >> > one version of the protocol, and to let the coordinator choose the
>> >> protocol
>> >> > with the largest number of supporters. All members which can't support
>> >> the
>> >> > selected protocol would be kicked out of the group. The drawback in a
>> >> > rolling upgrade is that the total capacity of the group would be
>> >> > momentarily halved. It would also be a little tricky to handle the
>> case
>> >> of
>> >> > retrying when a consumer is kicked out of the group. We wouldn't want
>> it
>> >> to
>> >> > be able to effect a rebalance, for example, if it would just be kicked
>> >> out
>> >> > again. That would probably complicate the group management logic on
>> the
>> >> > coordinator.
>> >> >
>> >> >
>> >> > Thanks,
>> >> > Jason
>> >> >
>> >> >
>> >> > On Tue, Aug 18, 2015 at 11:16 AM, Jiangjie Qin
>> > >> >
>> >> > wrote:
>> >> >
>> >> > > Jun,
>> >> > >
>> >> > > Yes, I agree. If the metadata can be synced quickly there should
>> not be
>> >> > an
>> >> > > issue. It just occurred to me that there is a proposal to allow
>> >> consuming
>> >> > > from followers in ISR, that could potentially cause more frequent
>> >> > metadata
>> >> > > change for consumers. Would that be an issue?
>> >> > >
>> >> > > Thanks,
>> >> > >
>> >> > > Jiangjie (Becket) Qin
>> >> > >
>> >> > > On Tue, Aug 18, 2015 at 10:22 AM, Jason Gustafson <
>> jason@confluent.io>
>> >> > > wrote:
>> >> > >
>> >> > > > Hi Jun,
>> >> > > >
>> >> > > > Answers below:
>> >> > > >
>> >> > > > 1. When there are multiple common protocols in the
>> JoinGroupRequest,
>> >> > > which
>> >> > > > one would the coordinator pick?
>> >> > > >
>> >> > > > I was intending to use the list to indicate preference. If all
>> group
>> >> > > > members support protocols ["A", "B"] in that order, then we will
>> >> choose
>> >> > > > "A." If some support ["B", "A"], then we would either choose
>> based on
>> >> > > > respective counts or just randomly. The main use case of
>> supporting
>> >> the
>> >> > > > list is for rolling upgrades when a change is made to the
>> assignment
>> >> > > > strategy. In that case, the new assignment strategy would be
>> listed
>> >> > first
>> >> > > > in the upgraded client. I think it's debatable whether this
>> feature
>> >> > would
>> >> > > > get much use in practice, so we might consider dropping it.
>> >> > > >
>> >> > > > 2. If the protocols don't agree, the group construction fails.
>> What
>> >> > > exactly
>> >> > > > does it mean? Do we send an error in every JoinGroupResponse and
>> >> remove
>> >> > > all
>> >> > > > members in the group in the coordinator?
>> >> > > >
>> >> > > > Yes, that is right. It would be handled similarly to inconsistent
>> >> > > > assignment strategies in the current protocol. The coordinator
>> >> returns
>> >> > an
>> >> > > > error in each join group response, and the client propagates the
>> >> error
>> >> > to
>> >> > > > the user.
>> >> > > >
>> >> > > > 3. Consumer embedded protocol: The proposal has two different
>> formats
>> >> > of
>> >> > > > subscription depending on whether wildcards are used or not. This
>> >> > seems a
>> >> > > > bit complicated. Would it be better to always use the metadata
>> hash?
>> >> > The
>> >> > > > clients know the subscribed topics already. This way, the client
>> code
>> >> > > > behaves the same whether wildcards are used or not.
>> >> > > >
>> >> > > > Yeah, I think this is possible (Neha also suggested it). I haven't
>> >> > > updated
>> >> > > > the wiki yet, but the patch I started working on uses only the
>> >> metadata
>> >> > > > hash. In the case that an explicit topic list is provided, the
>> hash
>> >> > just
>> >> > > > covers the metadata for those topics.
>> >> > > >
>> >> > > >
>> >> > > > Thanks,
>> >> > > > Jason
>> >> > > >
>> >> > > >
>> >> > > >
>> >> > > > On Tue, Aug 18, 2015 at 10:06 AM, Jun Rao 
>> wrote:
>> >> > > >
>> >> > > > > Jason,
>> >> > > > >
>> >> > > > > Thanks for the writeup. A few comments below.
>> >> > > > >
>> >> > > > > 1. When there are multiple common protocols in the
>> >> JoinGroupRequest,
>> >> > > > which
>> >> > > > > one would the coordinator pick?
>> >> > > > > 2. If the protocols don't agree, the group construction fails.
>> What
>> >> > > > exactly
>> >> > > > > does it mean? Do we send an error in every JoinGroupResponse and
>> >> > remove
>> >> > > > all
>> >> > > > > members in the group in the coordinator?
>> >> > > > > 3. Consumer embedded protocol: The proposal has two different
>> >> formats
>> >> > > of
>> >> > > > > subscription depending on whether wildcards are used or not.
>> This
>> >> > > seems a
>> >> > > > > bit complicated. Would it be better to always use the metadata
>> >> hash?
>> >> > > The
>> >> > > > > clients know the subscribed topics already. This way, the client
>> >> code
>> >> > > > > behaves the same whether wildcards are used or not.
>> >> > > > >
>> >> > > > > Jiangjie,
>> >> > > > >
>> >> > > > > With respect to rebalance churns due to topics being
>> >> created/deleted.
>> >> > > > With
>> >> > > > > the new consumer, the rebalance can probably settle within 200ms
>> >> when
>> >> > > > there
>> >> > > > > is a topic change. So, as long as we are not changing topic more
>> >> > than 5
>> >> > > > > times per sec, there shouldn't be constant churns, right?
>> >> > > > >
>> >> > > > > Thanks,
>> >> > > > >
>> >> > > > > Jun
>> >> > > > >
>> >> > > > >
>> >> > > > >
>> >> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <
>> >> jason@confluent.io
>> >> > >
>> >> > > > > wrote:
>> >> > > > >
>> >> > > > > > Hi Kafka Devs,
>> >> > > > > >
>> >> > > > > > One of the nagging issues in the current design of the new
>> >> consumer
>> >> > > has
>> >> > > > > > been the need to support a variety of assignment strategies.
>> >> We've
>> >> > > > > > encountered this in particular in the design of copycat and
>> the
>> >> > > > > processing
>> >> > > > > > framework (KIP-28). From what I understand, Samza also has a
>> >> number
>> >> > > of
>> >> > > > > use
>> >> > > > > > cases with custom assignment needs. The new consumer protocol
>> >> > > supports
>> >> > > > > new
>> >> > > > > > assignment strategies by hooking them into the broker. For
>> many
>> >> > > > > > environments, this is a major pain and in some cases, a
>> >> > non-starter.
>> >> > > It
>> >> > > > > > also challenges the validation that the coordinator can
>> provide.
>> >> > For
>> >> > > > > > example, some assignment strategies call for partitions to be
>> >> > > assigned
>> >> > > > > > multiple times, which means that the coordinator can only
>> check
>> >> > that
>> >> > > > > > partitions have been assigned at least once.
>> >> > > > > >
>> >> > > > > > To solve these issues, we'd like to propose moving assignment
>> to
>> >> > the
>> >> > > > > > client. I've written a wiki which outlines some protocol
>> changes
>> >> to
>> >> > > > > achieve
>> >> > > > > > this:
>> >> > > > > >
>> >> > > > > >
>> >> > > > >
>> >> > > >
>> >> > >
>> >> >
>> >>
>> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
>> >> > > > > > .
>> >> > > > > > To summarize briefly, instead of the coordinator assigning the
>> >> > > > partitions
>> >> > > > > > itself, all subscriptions are forwarded to each member of the
>> >> group
>> >> > > > which
>> >> > > > > > then decides independently which partitions it should consume.
>> >> The
>> >> > > > > protocol
>> >> > > > > > provides a mechanism for the coordinator to validate that all
>> >> > > consumers
>> >> > > > > use
>> >> > > > > > the same assignment strategy, but it does not ensure that the
>> >> > > resulting
>> >> > > > > > assignment is "correct." This provides a powerful capability
>> for
>> >> > > users
>> >> > > > to
>> >> > > > > > control the full data flow on the client side. They control
>> how
>> >> > data
>> >> > > is
>> >> > > > > > written to partitions through the Partitioner interface and
>> they
>> >> > > > control
>> >> > > > > > how data is consumed through the assignment strategy, all
>> without
>> >> > > > > touching
>> >> > > > > > the server.
>> >> > > > > >
>> >> > > > > > Of course nothing comes for free. In particular, this change
>> >> > removes
>> >> > > > the
>> >> > > > > > ability of the coordinator to validate that commits are made
>> by
>> >> > > > consumers
>> >> > > > > > who were assigned the respective partition. This might not be
>> too
>> >> > bad
>> >> > > > > since
>> >> > > > > > we retain the ability to validate the generation id, but it
>> is a
>> >> > > > > potential
>> >> > > > > > concern. We have considered alternative protocols which add a
>> >> > second
>> >> > > > > > round-trip to the protocol in order to give the coordinator
>> the
>> >> > > ability
>> >> > > > > to
>> >> > > > > > confirm the assignment. As mentioned above, the coordinator is
>> >> > > somewhat
>> >> > > > > > limited in what it can actually validate, but this would
>> return
>> >> its
>> >> > > > > ability
>> >> > > > > > to validate commits. The tradeoff is that it increases the
>> >> > protocol's
>> >> > > > > > complexity which means more ways for the protocol to fail and
>> >> > > > > consequently
>> >> > > > > > more edge cases in the code.
>> >> > > > > >
>> >> > > > > > It also misses an opportunity to generalize the group
>> membership
>> >> > > > protocol
>> >> > > > > > for additional use cases. In fact, after you've gone to the
>> >> trouble
>> >> > > of
>> >> > > > > > moving assignment to the client, the main thing that is left
>> in
>> >> > this
>> >> > > > > > protocol is basically a general group management capability.
>> This
>> >> > is
>> >> > > > > > exactly what is needed for a few cases that are currently
>> under
>> >> > > > > discussion
>> >> > > > > > (e.g. copycat or single-writer producer). We've taken this
>> >> further
>> >> > > step
>> >> > > > > in
>> >> > > > > > the proposal and attempted to envision what that general
>> protocol
>> >> > > might
>> >> > > > > > look like and how it could be used both by the consumer and
>> for
>> >> > some
>> >> > > of
>> >> > > > > > these other cases.
>> >> > > > > >
>> >> > > > > > Anyway, since time is running out on the new consumer, we have
>> >> > > perhaps
>> >> > > > > one
>> >> > > > > > last chance to consider a significant change in the protocol
>> like
>> >> > > this,
>> >> > > > > so
>> >> > > > > > have a look at the wiki and share your thoughts. I've no doubt
>> >> that
>> >> > > > some
>> >> > > > > > ideas seem clearer in my mind than they do on paper, so ask
>> >> > questions
>> >> > > > if
>> >> > > > > > there is any confusion.
>> >> > > > > >
>> >> > > > > > Thanks!
>> >> > > > > > Jason
>> >> > > > > >
>> >> > > > >
>> >> > > >
>> >> > >
>> >> >
>> >>
>> >
>> >
>> >
>> > --
>> > Thanks,
>> > Neha
>>

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Joel Koshy <jj...@gmail.com>.
> I think we think this proposal addresses 100% of the split brain issues
> ever seen in the ZK-based protocol, but I think you think there are still
> issues. Can you explain what your thinking of and when you think it would
> happen? I want to make sure you aren't assuming client-side=>split-brain
> since I think that is totally not the case.

Yes I had concluded that client-side assignment would still result in
split-brain wrt partition counts, but I overlooked a key sentence in
the wiki - i.e., that the assignment algorithm for consumers can just
use the largest number of partitions for each topic reported by any of
the consumers. i.e., I assumed that consumers would just fail
rebalance if the partition counts were inconsistent but that is not
the case since this conflict can be easily resolved as described
without further join-group requests. Sorry about that. There is still
the issue of the coordinator having to send back n*m worth of
metadata, but that was not my biggest concern. I'll look over it again
and reply back tomorrow.

Joel

On Thu, Aug 27, 2015 at 2:55 PM, Jay Kreps <ja...@confluent.io> wrote:
> Hey Joel,
>
> I really don't think we should do both. There are pros and cons but we
> should make a decision and work on operationalizing one approach. Much of
> really making something like this work is getting all the bugs out, getting
> monitoring in place, getting rigorous system tests in place. Trying to do
> those things twice with the same resources will just mean we do them half
> as well. I also think this buys nothing from the user's point of view--they
> want co-ordination that works correctly, the debate we are having is purely
> a "how should we build that" debate. So this is really not the kind of
> thing we'd want to make pluggable and if we did that would just complicate
> life for the user.
>
> I think we think this proposal addresses 100% of the split brain issues
> ever seen in the ZK-based protocol, but I think you think there are still
> issues. Can you explain what your thinking of and when you think it would
> happen? I want to make sure you aren't assuming client-side=>split-brain
> since I think that is totally not the case.
>
> With respect to "herd issues" I actually think all the proposals address
> this by scaling the co-ordinator out to all nodes and making the
> co-ordination vastly cheaper. No proposal, of course, gets rid of the fact
> that all clients rejoin at once when there is a membership change, but that
> is kind of fundamental to the problem.
>
> -Jay
>
> On Thu, Aug 27, 2015 at 2:02 PM, Joel Koshy <jj...@gmail.com> wrote:
>
>> I actually feel these set of tests (whatever they may be) are somewhat
>> irrelevant here. My main concern with the current client-side proposal
>> (i.e., without Becket's follow-up suggestions) is that it makes a
>> significant compromise to the original charter of the new consumer -
>> i.e., reduce/eliminate herd and split brain problems in both group
>> management and partition assignment. I understand the need for
>> client-side partition assignment in some use cases (which we are also
>> interested in), but I also think we should make every effort to keep
>> full server-side coordination for the remaining (majority) of use
>> cases especially if it does not complicate the protocol. The proposed
>> changes do not complicate the protocol IMO - i.e., there is no further
>> modification to the request/response formats beyond the current
>> client-side proposal. It only involves a trivial reinterpretation of
>> the content of the protocol metadata field.
>>
>> Joel
>>
>> On Wed, Aug 26, 2015 at 9:33 PM, Neha Narkhede <ne...@confluent.io> wrote:
>> > Hey Becket,
>> >
>> > In that case, the broker side partition assignment would be ideal because
>> >> it avoids
>> >> issues like metadata inconsistency / split brain / exploding
>> subscription
>> >> set propagation.
>> >
>> >
>> > As per our previous discussions regarding each of those concerns
>> (referring
>> > to this email thread, KIP calls and JIRA comments), we are going to run a
>> > set of tests using the LinkedIn deployment numbers that we will wait for
>> > you to share. The purpose is to see if those concerns are really valid or
>> > not. I'd prefer to see that before making any more changes that will
>> > complicate the protocol.
>> >
>> > On Wed, Aug 26, 2015 at 4:57 PM, Jiangjie Qin <jqin@linkedin.com.invalid
>> >
>> > wrote:
>> >
>> >> Hi folks,
>> >>
>> >> After further discussion in LinkedIn, we found that while having a more
>> >> general group management protocol is very useful, the vast majority of
>> the
>> >> clients will not use customized partition assignment strategy. In that
>> >> case, the broker side partition assignment would be ideal because it
>> avoids
>> >> issues like metadata inconsistency / split brain / exploding
>> subscription
>> >> set propagation.
>> >>
>> >> So we have the following proposal that satisfies the majority of the
>> >> clients' needs without changing the currently proposed binary protocol.
>> >> i.e., Continue to support broker-side assignment if the assignment
>> strategy
>> >> is recognized by the coordinator.
>> >>
>> >> 1. Keep the binary protocol as currently proposed.
>> >>
>> >> 2. Change the way we interpret ProtocolMetadata:
>> >> 2.1 On consumer side, change partition.assignment.strategy to
>> >> partition.assignor.class. Implement the something like the following
>> >> PartitionAssignor Interface:
>> >>
>> >> public interface PartitionAssignor {
>> >>   List<String> protocolTypes();
>> >>   byte[] protocolMetadata();
>> >>   // return the Topic->List<Partition> map that are assigned to this
>> >> consumer.
>> >>   List<TopicPartition> assignPartitions(String protocolType, byte[]
>> >> responseProtocolMetadata);
>> >> }
>> >>
>> >> public abstract class AbstractPartitionAssignor implements
>> >> PartitionAssignor {
>> >>   protected final KafkaConsumer consumer;
>> >>   AbstractPartitionAssignor(KafkaConsumer consumer) {
>> >>     this.consumer = consumer;
>> >>   }
>> >> }
>> >>
>> >> 2.2 The ProtocolMetadata in JoinGroupRequest will be
>> >> partitionAssignor.protocolMetadata(). When partition.assignor.class is
>> >> "range" or "roundrobin", the ProtocolMetadata in JoinGroupRequest will
>> be a
>> >> JSON subscription set. ("range", "roundrobin" will be reserved words, we
>> >> can also consider reserving some Prefix such as "broker-" to be more
>> clear)
>> >> 2.3 On broker side when ProtocolType is "range" or "roundroubin",
>> >> coordinator will parse the ProtocolMetadata in the JoinGroupRequest and
>> >> assign the partitions for consumers. In the JoinGroupResponse, the
>> >> ProtocolMetadata will be the global assignment of partitions.
>> >> 2.4 On client side, after receiving the JoinGroupResponse,
>> >> partitionAssignor.assignPartitions() will be invoked to return the
>> actual
>> >> assignment. If the assignor is RangeAssignor or RoundRobinAssignor, they
>> >> will parse the assignment from the ProtocolMetadata returned by
>> >> coordinator.
>> >>
>> >> This approach has a few merits:
>> >> 1. Does not change the proposed binary protocol, which is still general.
>> >> 2. The majority of the consumers will not suffer from inconsistent
>> metadata
>> >> / split brain / exploding subscription set propagation. This is
>> >> specifically to deal with the issue that the current proposal caters to
>> a
>> >> 20% use-case while adversely impacting the more common 80% use-cases.
>> >> 3. Easy to implement. The only thing needed is implement a partitioner
>> >> class. For most users, the default range and roundrobin partitioner are
>> >> good enough.
>> >>
>> >> Thoughts?
>> >>
>> >> Thanks,
>> >>
>> >> Jiangjie (Becket) Qin
>> >>
>> >> On Tue, Aug 18, 2015 at 2:51 PM, Jason Gustafson <ja...@confluent.io>
>> >> wrote:
>> >>
>> >> > Follow-up from the kip call:
>> >> >
>> >> > 1. Onur brought up the question of whether this protocol provides
>> enough
>> >> > coordination capabilities to be generally useful in practice (is that
>> >> > accurate, Onur?). If it doesn't, then each use case would probably
>> need a
>> >> > dependence on zookeeper anyway, and we haven't really gained anything.
>> >> The
>> >> > group membership provided by this protocol is a useful primitive for
>> >> > coordination, but it's limited in the sense that everything shared
>> among
>> >> > the group has to be communicated at the time the group is created. If
>> any
>> >> > shared data changes, then the only way the group can ensure agreement
>> is
>> >> to
>> >> > force a rebalance. This is expensive since all members must stall
>> while
>> >> the
>> >> > rebalancing takes place. As we have also seen, there is a practical
>> limit
>> >> > on the amount of metadata that can be sent through this protocol when
>> >> > groups get a little larger. This protocol is therefore not suitable to
>> >> > cases which require frequent communication or which require a large
>> >> amount
>> >> > of data to be communicated. For the use cases listed on the wiki,
>> neither
>> >> > of these appear to be an issue, but there may be other limitations
>> which
>> >> > would limit reuse of the protocol. Perhaps it would be sufficient to
>> >> sketch
>> >> > how these cases might work?
>> >> >
>> >> > 2. We talked a little bit about the issue of metadata churn. Becket
>> >> brought
>> >> > up the interesting point that not only do we depend on topic metadata
>> >> > changing relatively infrequently, but we also expect timely agreement
>> >> among
>> >> > the brokers on what that metadata is. To resolve this, we can have the
>> >> > consumers fetch metadata from the coordinator. We still depend on
>> topic
>> >> > metadata not changing frequently, but this should resolve any
>> >> disagreement
>> >> > among the brokers themselves. In fact, since we expect that
>> disagreement
>> >> is
>> >> > relatively rare, we can have the consumers fetch from the coordinator
>> >> only
>> >> > when when a disagreement occurs. The nice thing about this proposal is
>> >> that
>> >> > it doesn't affect the join group semantics, so the coordinator would
>> >> remain
>> >> > oblivious to the metadata used by the group for agreement. Also, if
>> >> > metadata churn becomes an issue, it might be possible to have the
>> >> > coordinator provide a snapshot for the group to ensure that a
>> generation
>> >> > would be able to reach agreement (this would probably require adding
>> >> > groupId/generation to the metadata request).
>> >> >
>> >> > 3. We talked briefly about support for multiple protocols in the join
>> >> group
>> >> > request in order to allow changing the assignment strategy without
>> >> > downtime. I think it's a little doubtful that this would get much use
>> in
>> >> > practice, but I agree it's a nice option to have on the table. An
>> >> > alternative, for the sake of argument, is to have each member provide
>> >> only
>> >> > one version of the protocol, and to let the coordinator choose the
>> >> protocol
>> >> > with the largest number of supporters. All members which can't support
>> >> the
>> >> > selected protocol would be kicked out of the group. The drawback in a
>> >> > rolling upgrade is that the total capacity of the group would be
>> >> > momentarily halved. It would also be a little tricky to handle the
>> case
>> >> of
>> >> > retrying when a consumer is kicked out of the group. We wouldn't want
>> it
>> >> to
>> >> > be able to effect a rebalance, for example, if it would just be kicked
>> >> out
>> >> > again. That would probably complicate the group management logic on
>> the
>> >> > coordinator.
>> >> >
>> >> >
>> >> > Thanks,
>> >> > Jason
>> >> >
>> >> >
>> >> > On Tue, Aug 18, 2015 at 11:16 AM, Jiangjie Qin
>> <jqin@linkedin.com.invalid
>> >> >
>> >> > wrote:
>> >> >
>> >> > > Jun,
>> >> > >
>> >> > > Yes, I agree. If the metadata can be synced quickly there should
>> not be
>> >> > an
>> >> > > issue. It just occurred to me that there is a proposal to allow
>> >> consuming
>> >> > > from followers in ISR, that could potentially cause more frequent
>> >> > metadata
>> >> > > change for consumers. Would that be an issue?
>> >> > >
>> >> > > Thanks,
>> >> > >
>> >> > > Jiangjie (Becket) Qin
>> >> > >
>> >> > > On Tue, Aug 18, 2015 at 10:22 AM, Jason Gustafson <
>> jason@confluent.io>
>> >> > > wrote:
>> >> > >
>> >> > > > Hi Jun,
>> >> > > >
>> >> > > > Answers below:
>> >> > > >
>> >> > > > 1. When there are multiple common protocols in the
>> JoinGroupRequest,
>> >> > > which
>> >> > > > one would the coordinator pick?
>> >> > > >
>> >> > > > I was intending to use the list to indicate preference. If all
>> group
>> >> > > > members support protocols ["A", "B"] in that order, then we will
>> >> choose
>> >> > > > "A." If some support ["B", "A"], then we would either choose
>> based on
>> >> > > > respective counts or just randomly. The main use case of
>> supporting
>> >> the
>> >> > > > list is for rolling upgrades when a change is made to the
>> assignment
>> >> > > > strategy. In that case, the new assignment strategy would be
>> listed
>> >> > first
>> >> > > > in the upgraded client. I think it's debatable whether this
>> feature
>> >> > would
>> >> > > > get much use in practice, so we might consider dropping it.
>> >> > > >
>> >> > > > 2. If the protocols don't agree, the group construction fails.
>> What
>> >> > > exactly
>> >> > > > does it mean? Do we send an error in every JoinGroupResponse and
>> >> remove
>> >> > > all
>> >> > > > members in the group in the coordinator?
>> >> > > >
>> >> > > > Yes, that is right. It would be handled similarly to inconsistent
>> >> > > > assignment strategies in the current protocol. The coordinator
>> >> returns
>> >> > an
>> >> > > > error in each join group response, and the client propagates the
>> >> error
>> >> > to
>> >> > > > the user.
>> >> > > >
>> >> > > > 3. Consumer embedded protocol: The proposal has two different
>> formats
>> >> > of
>> >> > > > subscription depending on whether wildcards are used or not. This
>> >> > seems a
>> >> > > > bit complicated. Would it be better to always use the metadata
>> hash?
>> >> > The
>> >> > > > clients know the subscribed topics already. This way, the client
>> code
>> >> > > > behaves the same whether wildcards are used or not.
>> >> > > >
>> >> > > > Yeah, I think this is possible (Neha also suggested it). I haven't
>> >> > > updated
>> >> > > > the wiki yet, but the patch I started working on uses only the
>> >> metadata
>> >> > > > hash. In the case that an explicit topic list is provided, the
>> hash
>> >> > just
>> >> > > > covers the metadata for those topics.
>> >> > > >
>> >> > > >
>> >> > > > Thanks,
>> >> > > > Jason
>> >> > > >
>> >> > > >
>> >> > > >
>> >> > > > On Tue, Aug 18, 2015 at 10:06 AM, Jun Rao <ju...@confluent.io>
>> wrote:
>> >> > > >
>> >> > > > > Jason,
>> >> > > > >
>> >> > > > > Thanks for the writeup. A few comments below.
>> >> > > > >
>> >> > > > > 1. When there are multiple common protocols in the
>> >> JoinGroupRequest,
>> >> > > > which
>> >> > > > > one would the coordinator pick?
>> >> > > > > 2. If the protocols don't agree, the group construction fails.
>> What
>> >> > > > exactly
>> >> > > > > does it mean? Do we send an error in every JoinGroupResponse and
>> >> > remove
>> >> > > > all
>> >> > > > > members in the group in the coordinator?
>> >> > > > > 3. Consumer embedded protocol: The proposal has two different
>> >> formats
>> >> > > of
>> >> > > > > subscription depending on whether wildcards are used or not.
>> This
>> >> > > seems a
>> >> > > > > bit complicated. Would it be better to always use the metadata
>> >> hash?
>> >> > > The
>> >> > > > > clients know the subscribed topics already. This way, the client
>> >> code
>> >> > > > > behaves the same whether wildcards are used or not.
>> >> > > > >
>> >> > > > > Jiangjie,
>> >> > > > >
>> >> > > > > With respect to rebalance churns due to topics being
>> >> created/deleted.
>> >> > > > With
>> >> > > > > the new consumer, the rebalance can probably settle within 200ms
>> >> when
>> >> > > > there
>> >> > > > > is a topic change. So, as long as we are not changing topic more
>> >> > than 5
>> >> > > > > times per sec, there shouldn't be constant churns, right?
>> >> > > > >
>> >> > > > > Thanks,
>> >> > > > >
>> >> > > > > Jun
>> >> > > > >
>> >> > > > >
>> >> > > > >
>> >> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <
>> >> jason@confluent.io
>> >> > >
>> >> > > > > wrote:
>> >> > > > >
>> >> > > > > > Hi Kafka Devs,
>> >> > > > > >
>> >> > > > > > One of the nagging issues in the current design of the new
>> >> consumer
>> >> > > has
>> >> > > > > > been the need to support a variety of assignment strategies.
>> >> We've
>> >> > > > > > encountered this in particular in the design of copycat and
>> the
>> >> > > > > processing
>> >> > > > > > framework (KIP-28). From what I understand, Samza also has a
>> >> number
>> >> > > of
>> >> > > > > use
>> >> > > > > > cases with custom assignment needs. The new consumer protocol
>> >> > > supports
>> >> > > > > new
>> >> > > > > > assignment strategies by hooking them into the broker. For
>> many
>> >> > > > > > environments, this is a major pain and in some cases, a
>> >> > non-starter.
>> >> > > It
>> >> > > > > > also challenges the validation that the coordinator can
>> provide.
>> >> > For
>> >> > > > > > example, some assignment strategies call for partitions to be
>> >> > > assigned
>> >> > > > > > multiple times, which means that the coordinator can only
>> check
>> >> > that
>> >> > > > > > partitions have been assigned at least once.
>> >> > > > > >
>> >> > > > > > To solve these issues, we'd like to propose moving assignment
>> to
>> >> > the
>> >> > > > > > client. I've written a wiki which outlines some protocol
>> changes
>> >> to
>> >> > > > > achieve
>> >> > > > > > this:
>> >> > > > > >
>> >> > > > > >
>> >> > > > >
>> >> > > >
>> >> > >
>> >> >
>> >>
>> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
>> >> > > > > > .
>> >> > > > > > To summarize briefly, instead of the coordinator assigning the
>> >> > > > partitions
>> >> > > > > > itself, all subscriptions are forwarded to each member of the
>> >> group
>> >> > > > which
>> >> > > > > > then decides independently which partitions it should consume.
>> >> The
>> >> > > > > protocol
>> >> > > > > > provides a mechanism for the coordinator to validate that all
>> >> > > consumers
>> >> > > > > use
>> >> > > > > > the same assignment strategy, but it does not ensure that the
>> >> > > resulting
>> >> > > > > > assignment is "correct." This provides a powerful capability
>> for
>> >> > > users
>> >> > > > to
>> >> > > > > > control the full data flow on the client side. They control
>> how
>> >> > data
>> >> > > is
>> >> > > > > > written to partitions through the Partitioner interface and
>> they
>> >> > > > control
>> >> > > > > > how data is consumed through the assignment strategy, all
>> without
>> >> > > > > touching
>> >> > > > > > the server.
>> >> > > > > >
>> >> > > > > > Of course nothing comes for free. In particular, this change
>> >> > removes
>> >> > > > the
>> >> > > > > > ability of the coordinator to validate that commits are made
>> by
>> >> > > > consumers
>> >> > > > > > who were assigned the respective partition. This might not be
>> too
>> >> > bad
>> >> > > > > since
>> >> > > > > > we retain the ability to validate the generation id, but it
>> is a
>> >> > > > > potential
>> >> > > > > > concern. We have considered alternative protocols which add a
>> >> > second
>> >> > > > > > round-trip to the protocol in order to give the coordinator
>> the
>> >> > > ability
>> >> > > > > to
>> >> > > > > > confirm the assignment. As mentioned above, the coordinator is
>> >> > > somewhat
>> >> > > > > > limited in what it can actually validate, but this would
>> return
>> >> its
>> >> > > > > ability
>> >> > > > > > to validate commits. The tradeoff is that it increases the
>> >> > protocol's
>> >> > > > > > complexity which means more ways for the protocol to fail and
>> >> > > > > consequently
>> >> > > > > > more edge cases in the code.
>> >> > > > > >
>> >> > > > > > It also misses an opportunity to generalize the group
>> membership
>> >> > > > protocol
>> >> > > > > > for additional use cases. In fact, after you've gone to the
>> >> trouble
>> >> > > of
>> >> > > > > > moving assignment to the client, the main thing that is left
>> in
>> >> > this
>> >> > > > > > protocol is basically a general group management capability.
>> This
>> >> > is
>> >> > > > > > exactly what is needed for a few cases that are currently
>> under
>> >> > > > > discussion
>> >> > > > > > (e.g. copycat or single-writer producer). We've taken this
>> >> further
>> >> > > step
>> >> > > > > in
>> >> > > > > > the proposal and attempted to envision what that general
>> protocol
>> >> > > might
>> >> > > > > > look like and how it could be used both by the consumer and
>> for
>> >> > some
>> >> > > of
>> >> > > > > > these other cases.
>> >> > > > > >
>> >> > > > > > Anyway, since time is running out on the new consumer, we have
>> >> > > perhaps
>> >> > > > > one
>> >> > > > > > last chance to consider a significant change in the protocol
>> like
>> >> > > this,
>> >> > > > > so
>> >> > > > > > have a look at the wiki and share your thoughts. I've no doubt
>> >> that
>> >> > > > some
>> >> > > > > > ideas seem clearer in my mind than they do on paper, so ask
>> >> > questions
>> >> > > > if
>> >> > > > > > there is any confusion.
>> >> > > > > >
>> >> > > > > > Thanks!
>> >> > > > > > Jason
>> >> > > > > >
>> >> > > > >
>> >> > > >
>> >> > >
>> >> >
>> >>
>> >
>> >
>> >
>> > --
>> > Thanks,
>> > Neha
>>

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Jay Kreps <ja...@confluent.io>.
Hey Joel,

I really don't think we should do both. There are pros and cons but we
should make a decision and work on operationalizing one approach. Much of
really making something like this work is getting all the bugs out, getting
monitoring in place, getting rigorous system tests in place. Trying to do
those things twice with the same resources will just mean we do them half
as well. I also think this buys nothing from the user's point of view--they
want co-ordination that works correctly, the debate we are having is purely
a "how should we build that" debate. So this is really not the kind of
thing we'd want to make pluggable and if we did that would just complicate
life for the user.

I think we think this proposal addresses 100% of the split brain issues
ever seen in the ZK-based protocol, but I think you think there are still
issues. Can you explain what your thinking of and when you think it would
happen? I want to make sure you aren't assuming client-side=>split-brain
since I think that is totally not the case.

With respect to "herd issues" I actually think all the proposals address
this by scaling the co-ordinator out to all nodes and making the
co-ordination vastly cheaper. No proposal, of course, gets rid of the fact
that all clients rejoin at once when there is a membership change, but that
is kind of fundamental to the problem.

-Jay

On Thu, Aug 27, 2015 at 2:02 PM, Joel Koshy <jj...@gmail.com> wrote:

> I actually feel these set of tests (whatever they may be) are somewhat
> irrelevant here. My main concern with the current client-side proposal
> (i.e., without Becket's follow-up suggestions) is that it makes a
> significant compromise to the original charter of the new consumer -
> i.e., reduce/eliminate herd and split brain problems in both group
> management and partition assignment. I understand the need for
> client-side partition assignment in some use cases (which we are also
> interested in), but I also think we should make every effort to keep
> full server-side coordination for the remaining (majority) of use
> cases especially if it does not complicate the protocol. The proposed
> changes do not complicate the protocol IMO - i.e., there is no further
> modification to the request/response formats beyond the current
> client-side proposal. It only involves a trivial reinterpretation of
> the content of the protocol metadata field.
>
> Joel
>
> On Wed, Aug 26, 2015 at 9:33 PM, Neha Narkhede <ne...@confluent.io> wrote:
> > Hey Becket,
> >
> > In that case, the broker side partition assignment would be ideal because
> >> it avoids
> >> issues like metadata inconsistency / split brain / exploding
> subscription
> >> set propagation.
> >
> >
> > As per our previous discussions regarding each of those concerns
> (referring
> > to this email thread, KIP calls and JIRA comments), we are going to run a
> > set of tests using the LinkedIn deployment numbers that we will wait for
> > you to share. The purpose is to see if those concerns are really valid or
> > not. I'd prefer to see that before making any more changes that will
> > complicate the protocol.
> >
> > On Wed, Aug 26, 2015 at 4:57 PM, Jiangjie Qin <jqin@linkedin.com.invalid
> >
> > wrote:
> >
> >> Hi folks,
> >>
> >> After further discussion in LinkedIn, we found that while having a more
> >> general group management protocol is very useful, the vast majority of
> the
> >> clients will not use customized partition assignment strategy. In that
> >> case, the broker side partition assignment would be ideal because it
> avoids
> >> issues like metadata inconsistency / split brain / exploding
> subscription
> >> set propagation.
> >>
> >> So we have the following proposal that satisfies the majority of the
> >> clients' needs without changing the currently proposed binary protocol.
> >> i.e., Continue to support broker-side assignment if the assignment
> strategy
> >> is recognized by the coordinator.
> >>
> >> 1. Keep the binary protocol as currently proposed.
> >>
> >> 2. Change the way we interpret ProtocolMetadata:
> >> 2.1 On consumer side, change partition.assignment.strategy to
> >> partition.assignor.class. Implement the something like the following
> >> PartitionAssignor Interface:
> >>
> >> public interface PartitionAssignor {
> >>   List<String> protocolTypes();
> >>   byte[] protocolMetadata();
> >>   // return the Topic->List<Partition> map that are assigned to this
> >> consumer.
> >>   List<TopicPartition> assignPartitions(String protocolType, byte[]
> >> responseProtocolMetadata);
> >> }
> >>
> >> public abstract class AbstractPartitionAssignor implements
> >> PartitionAssignor {
> >>   protected final KafkaConsumer consumer;
> >>   AbstractPartitionAssignor(KafkaConsumer consumer) {
> >>     this.consumer = consumer;
> >>   }
> >> }
> >>
> >> 2.2 The ProtocolMetadata in JoinGroupRequest will be
> >> partitionAssignor.protocolMetadata(). When partition.assignor.class is
> >> "range" or "roundrobin", the ProtocolMetadata in JoinGroupRequest will
> be a
> >> JSON subscription set. ("range", "roundrobin" will be reserved words, we
> >> can also consider reserving some Prefix such as "broker-" to be more
> clear)
> >> 2.3 On broker side when ProtocolType is "range" or "roundroubin",
> >> coordinator will parse the ProtocolMetadata in the JoinGroupRequest and
> >> assign the partitions for consumers. In the JoinGroupResponse, the
> >> ProtocolMetadata will be the global assignment of partitions.
> >> 2.4 On client side, after receiving the JoinGroupResponse,
> >> partitionAssignor.assignPartitions() will be invoked to return the
> actual
> >> assignment. If the assignor is RangeAssignor or RoundRobinAssignor, they
> >> will parse the assignment from the ProtocolMetadata returned by
> >> coordinator.
> >>
> >> This approach has a few merits:
> >> 1. Does not change the proposed binary protocol, which is still general.
> >> 2. The majority of the consumers will not suffer from inconsistent
> metadata
> >> / split brain / exploding subscription set propagation. This is
> >> specifically to deal with the issue that the current proposal caters to
> a
> >> 20% use-case while adversely impacting the more common 80% use-cases.
> >> 3. Easy to implement. The only thing needed is implement a partitioner
> >> class. For most users, the default range and roundrobin partitioner are
> >> good enough.
> >>
> >> Thoughts?
> >>
> >> Thanks,
> >>
> >> Jiangjie (Becket) Qin
> >>
> >> On Tue, Aug 18, 2015 at 2:51 PM, Jason Gustafson <ja...@confluent.io>
> >> wrote:
> >>
> >> > Follow-up from the kip call:
> >> >
> >> > 1. Onur brought up the question of whether this protocol provides
> enough
> >> > coordination capabilities to be generally useful in practice (is that
> >> > accurate, Onur?). If it doesn't, then each use case would probably
> need a
> >> > dependence on zookeeper anyway, and we haven't really gained anything.
> >> The
> >> > group membership provided by this protocol is a useful primitive for
> >> > coordination, but it's limited in the sense that everything shared
> among
> >> > the group has to be communicated at the time the group is created. If
> any
> >> > shared data changes, then the only way the group can ensure agreement
> is
> >> to
> >> > force a rebalance. This is expensive since all members must stall
> while
> >> the
> >> > rebalancing takes place. As we have also seen, there is a practical
> limit
> >> > on the amount of metadata that can be sent through this protocol when
> >> > groups get a little larger. This protocol is therefore not suitable to
> >> > cases which require frequent communication or which require a large
> >> amount
> >> > of data to be communicated. For the use cases listed on the wiki,
> neither
> >> > of these appear to be an issue, but there may be other limitations
> which
> >> > would limit reuse of the protocol. Perhaps it would be sufficient to
> >> sketch
> >> > how these cases might work?
> >> >
> >> > 2. We talked a little bit about the issue of metadata churn. Becket
> >> brought
> >> > up the interesting point that not only do we depend on topic metadata
> >> > changing relatively infrequently, but we also expect timely agreement
> >> among
> >> > the brokers on what that metadata is. To resolve this, we can have the
> >> > consumers fetch metadata from the coordinator. We still depend on
> topic
> >> > metadata not changing frequently, but this should resolve any
> >> disagreement
> >> > among the brokers themselves. In fact, since we expect that
> disagreement
> >> is
> >> > relatively rare, we can have the consumers fetch from the coordinator
> >> only
> >> > when when a disagreement occurs. The nice thing about this proposal is
> >> that
> >> > it doesn't affect the join group semantics, so the coordinator would
> >> remain
> >> > oblivious to the metadata used by the group for agreement. Also, if
> >> > metadata churn becomes an issue, it might be possible to have the
> >> > coordinator provide a snapshot for the group to ensure that a
> generation
> >> > would be able to reach agreement (this would probably require adding
> >> > groupId/generation to the metadata request).
> >> >
> >> > 3. We talked briefly about support for multiple protocols in the join
> >> group
> >> > request in order to allow changing the assignment strategy without
> >> > downtime. I think it's a little doubtful that this would get much use
> in
> >> > practice, but I agree it's a nice option to have on the table. An
> >> > alternative, for the sake of argument, is to have each member provide
> >> only
> >> > one version of the protocol, and to let the coordinator choose the
> >> protocol
> >> > with the largest number of supporters. All members which can't support
> >> the
> >> > selected protocol would be kicked out of the group. The drawback in a
> >> > rolling upgrade is that the total capacity of the group would be
> >> > momentarily halved. It would also be a little tricky to handle the
> case
> >> of
> >> > retrying when a consumer is kicked out of the group. We wouldn't want
> it
> >> to
> >> > be able to effect a rebalance, for example, if it would just be kicked
> >> out
> >> > again. That would probably complicate the group management logic on
> the
> >> > coordinator.
> >> >
> >> >
> >> > Thanks,
> >> > Jason
> >> >
> >> >
> >> > On Tue, Aug 18, 2015 at 11:16 AM, Jiangjie Qin
> <jqin@linkedin.com.invalid
> >> >
> >> > wrote:
> >> >
> >> > > Jun,
> >> > >
> >> > > Yes, I agree. If the metadata can be synced quickly there should
> not be
> >> > an
> >> > > issue. It just occurred to me that there is a proposal to allow
> >> consuming
> >> > > from followers in ISR, that could potentially cause more frequent
> >> > metadata
> >> > > change for consumers. Would that be an issue?
> >> > >
> >> > > Thanks,
> >> > >
> >> > > Jiangjie (Becket) Qin
> >> > >
> >> > > On Tue, Aug 18, 2015 at 10:22 AM, Jason Gustafson <
> jason@confluent.io>
> >> > > wrote:
> >> > >
> >> > > > Hi Jun,
> >> > > >
> >> > > > Answers below:
> >> > > >
> >> > > > 1. When there are multiple common protocols in the
> JoinGroupRequest,
> >> > > which
> >> > > > one would the coordinator pick?
> >> > > >
> >> > > > I was intending to use the list to indicate preference. If all
> group
> >> > > > members support protocols ["A", "B"] in that order, then we will
> >> choose
> >> > > > "A." If some support ["B", "A"], then we would either choose
> based on
> >> > > > respective counts or just randomly. The main use case of
> supporting
> >> the
> >> > > > list is for rolling upgrades when a change is made to the
> assignment
> >> > > > strategy. In that case, the new assignment strategy would be
> listed
> >> > first
> >> > > > in the upgraded client. I think it's debatable whether this
> feature
> >> > would
> >> > > > get much use in practice, so we might consider dropping it.
> >> > > >
> >> > > > 2. If the protocols don't agree, the group construction fails.
> What
> >> > > exactly
> >> > > > does it mean? Do we send an error in every JoinGroupResponse and
> >> remove
> >> > > all
> >> > > > members in the group in the coordinator?
> >> > > >
> >> > > > Yes, that is right. It would be handled similarly to inconsistent
> >> > > > assignment strategies in the current protocol. The coordinator
> >> returns
> >> > an
> >> > > > error in each join group response, and the client propagates the
> >> error
> >> > to
> >> > > > the user.
> >> > > >
> >> > > > 3. Consumer embedded protocol: The proposal has two different
> formats
> >> > of
> >> > > > subscription depending on whether wildcards are used or not. This
> >> > seems a
> >> > > > bit complicated. Would it be better to always use the metadata
> hash?
> >> > The
> >> > > > clients know the subscribed topics already. This way, the client
> code
> >> > > > behaves the same whether wildcards are used or not.
> >> > > >
> >> > > > Yeah, I think this is possible (Neha also suggested it). I haven't
> >> > > updated
> >> > > > the wiki yet, but the patch I started working on uses only the
> >> metadata
> >> > > > hash. In the case that an explicit topic list is provided, the
> hash
> >> > just
> >> > > > covers the metadata for those topics.
> >> > > >
> >> > > >
> >> > > > Thanks,
> >> > > > Jason
> >> > > >
> >> > > >
> >> > > >
> >> > > > On Tue, Aug 18, 2015 at 10:06 AM, Jun Rao <ju...@confluent.io>
> wrote:
> >> > > >
> >> > > > > Jason,
> >> > > > >
> >> > > > > Thanks for the writeup. A few comments below.
> >> > > > >
> >> > > > > 1. When there are multiple common protocols in the
> >> JoinGroupRequest,
> >> > > > which
> >> > > > > one would the coordinator pick?
> >> > > > > 2. If the protocols don't agree, the group construction fails.
> What
> >> > > > exactly
> >> > > > > does it mean? Do we send an error in every JoinGroupResponse and
> >> > remove
> >> > > > all
> >> > > > > members in the group in the coordinator?
> >> > > > > 3. Consumer embedded protocol: The proposal has two different
> >> formats
> >> > > of
> >> > > > > subscription depending on whether wildcards are used or not.
> This
> >> > > seems a
> >> > > > > bit complicated. Would it be better to always use the metadata
> >> hash?
> >> > > The
> >> > > > > clients know the subscribed topics already. This way, the client
> >> code
> >> > > > > behaves the same whether wildcards are used or not.
> >> > > > >
> >> > > > > Jiangjie,
> >> > > > >
> >> > > > > With respect to rebalance churns due to topics being
> >> created/deleted.
> >> > > > With
> >> > > > > the new consumer, the rebalance can probably settle within 200ms
> >> when
> >> > > > there
> >> > > > > is a topic change. So, as long as we are not changing topic more
> >> > than 5
> >> > > > > times per sec, there shouldn't be constant churns, right?
> >> > > > >
> >> > > > > Thanks,
> >> > > > >
> >> > > > > Jun
> >> > > > >
> >> > > > >
> >> > > > >
> >> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <
> >> jason@confluent.io
> >> > >
> >> > > > > wrote:
> >> > > > >
> >> > > > > > Hi Kafka Devs,
> >> > > > > >
> >> > > > > > One of the nagging issues in the current design of the new
> >> consumer
> >> > > has
> >> > > > > > been the need to support a variety of assignment strategies.
> >> We've
> >> > > > > > encountered this in particular in the design of copycat and
> the
> >> > > > > processing
> >> > > > > > framework (KIP-28). From what I understand, Samza also has a
> >> number
> >> > > of
> >> > > > > use
> >> > > > > > cases with custom assignment needs. The new consumer protocol
> >> > > supports
> >> > > > > new
> >> > > > > > assignment strategies by hooking them into the broker. For
> many
> >> > > > > > environments, this is a major pain and in some cases, a
> >> > non-starter.
> >> > > It
> >> > > > > > also challenges the validation that the coordinator can
> provide.
> >> > For
> >> > > > > > example, some assignment strategies call for partitions to be
> >> > > assigned
> >> > > > > > multiple times, which means that the coordinator can only
> check
> >> > that
> >> > > > > > partitions have been assigned at least once.
> >> > > > > >
> >> > > > > > To solve these issues, we'd like to propose moving assignment
> to
> >> > the
> >> > > > > > client. I've written a wiki which outlines some protocol
> changes
> >> to
> >> > > > > achieve
> >> > > > > > this:
> >> > > > > >
> >> > > > > >
> >> > > > >
> >> > > >
> >> > >
> >> >
> >>
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> >> > > > > > .
> >> > > > > > To summarize briefly, instead of the coordinator assigning the
> >> > > > partitions
> >> > > > > > itself, all subscriptions are forwarded to each member of the
> >> group
> >> > > > which
> >> > > > > > then decides independently which partitions it should consume.
> >> The
> >> > > > > protocol
> >> > > > > > provides a mechanism for the coordinator to validate that all
> >> > > consumers
> >> > > > > use
> >> > > > > > the same assignment strategy, but it does not ensure that the
> >> > > resulting
> >> > > > > > assignment is "correct." This provides a powerful capability
> for
> >> > > users
> >> > > > to
> >> > > > > > control the full data flow on the client side. They control
> how
> >> > data
> >> > > is
> >> > > > > > written to partitions through the Partitioner interface and
> they
> >> > > > control
> >> > > > > > how data is consumed through the assignment strategy, all
> without
> >> > > > > touching
> >> > > > > > the server.
> >> > > > > >
> >> > > > > > Of course nothing comes for free. In particular, this change
> >> > removes
> >> > > > the
> >> > > > > > ability of the coordinator to validate that commits are made
> by
> >> > > > consumers
> >> > > > > > who were assigned the respective partition. This might not be
> too
> >> > bad
> >> > > > > since
> >> > > > > > we retain the ability to validate the generation id, but it
> is a
> >> > > > > potential
> >> > > > > > concern. We have considered alternative protocols which add a
> >> > second
> >> > > > > > round-trip to the protocol in order to give the coordinator
> the
> >> > > ability
> >> > > > > to
> >> > > > > > confirm the assignment. As mentioned above, the coordinator is
> >> > > somewhat
> >> > > > > > limited in what it can actually validate, but this would
> return
> >> its
> >> > > > > ability
> >> > > > > > to validate commits. The tradeoff is that it increases the
> >> > protocol's
> >> > > > > > complexity which means more ways for the protocol to fail and
> >> > > > > consequently
> >> > > > > > more edge cases in the code.
> >> > > > > >
> >> > > > > > It also misses an opportunity to generalize the group
> membership
> >> > > > protocol
> >> > > > > > for additional use cases. In fact, after you've gone to the
> >> trouble
> >> > > of
> >> > > > > > moving assignment to the client, the main thing that is left
> in
> >> > this
> >> > > > > > protocol is basically a general group management capability.
> This
> >> > is
> >> > > > > > exactly what is needed for a few cases that are currently
> under
> >> > > > > discussion
> >> > > > > > (e.g. copycat or single-writer producer). We've taken this
> >> further
> >> > > step
> >> > > > > in
> >> > > > > > the proposal and attempted to envision what that general
> protocol
> >> > > might
> >> > > > > > look like and how it could be used both by the consumer and
> for
> >> > some
> >> > > of
> >> > > > > > these other cases.
> >> > > > > >
> >> > > > > > Anyway, since time is running out on the new consumer, we have
> >> > > perhaps
> >> > > > > one
> >> > > > > > last chance to consider a significant change in the protocol
> like
> >> > > this,
> >> > > > > so
> >> > > > > > have a look at the wiki and share your thoughts. I've no doubt
> >> that
> >> > > > some
> >> > > > > > ideas seem clearer in my mind than they do on paper, so ask
> >> > questions
> >> > > > if
> >> > > > > > there is any confusion.
> >> > > > > >
> >> > > > > > Thanks!
> >> > > > > > Jason
> >> > > > > >
> >> > > > >
> >> > > >
> >> > >
> >> >
> >>
> >
> >
> >
> > --
> > Thanks,
> > Neha
>

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Joel Koshy <jj...@gmail.com>.
I actually feel these set of tests (whatever they may be) are somewhat
irrelevant here. My main concern with the current client-side proposal
(i.e., without Becket's follow-up suggestions) is that it makes a
significant compromise to the original charter of the new consumer -
i.e., reduce/eliminate herd and split brain problems in both group
management and partition assignment. I understand the need for
client-side partition assignment in some use cases (which we are also
interested in), but I also think we should make every effort to keep
full server-side coordination for the remaining (majority) of use
cases especially if it does not complicate the protocol. The proposed
changes do not complicate the protocol IMO - i.e., there is no further
modification to the request/response formats beyond the current
client-side proposal. It only involves a trivial reinterpretation of
the content of the protocol metadata field.

Joel

On Wed, Aug 26, 2015 at 9:33 PM, Neha Narkhede <ne...@confluent.io> wrote:
> Hey Becket,
>
> In that case, the broker side partition assignment would be ideal because
>> it avoids
>> issues like metadata inconsistency / split brain / exploding subscription
>> set propagation.
>
>
> As per our previous discussions regarding each of those concerns (referring
> to this email thread, KIP calls and JIRA comments), we are going to run a
> set of tests using the LinkedIn deployment numbers that we will wait for
> you to share. The purpose is to see if those concerns are really valid or
> not. I'd prefer to see that before making any more changes that will
> complicate the protocol.
>
> On Wed, Aug 26, 2015 at 4:57 PM, Jiangjie Qin <jq...@linkedin.com.invalid>
> wrote:
>
>> Hi folks,
>>
>> After further discussion in LinkedIn, we found that while having a more
>> general group management protocol is very useful, the vast majority of the
>> clients will not use customized partition assignment strategy. In that
>> case, the broker side partition assignment would be ideal because it avoids
>> issues like metadata inconsistency / split brain / exploding subscription
>> set propagation.
>>
>> So we have the following proposal that satisfies the majority of the
>> clients' needs without changing the currently proposed binary protocol.
>> i.e., Continue to support broker-side assignment if the assignment strategy
>> is recognized by the coordinator.
>>
>> 1. Keep the binary protocol as currently proposed.
>>
>> 2. Change the way we interpret ProtocolMetadata:
>> 2.1 On consumer side, change partition.assignment.strategy to
>> partition.assignor.class. Implement the something like the following
>> PartitionAssignor Interface:
>>
>> public interface PartitionAssignor {
>>   List<String> protocolTypes();
>>   byte[] protocolMetadata();
>>   // return the Topic->List<Partition> map that are assigned to this
>> consumer.
>>   List<TopicPartition> assignPartitions(String protocolType, byte[]
>> responseProtocolMetadata);
>> }
>>
>> public abstract class AbstractPartitionAssignor implements
>> PartitionAssignor {
>>   protected final KafkaConsumer consumer;
>>   AbstractPartitionAssignor(KafkaConsumer consumer) {
>>     this.consumer = consumer;
>>   }
>> }
>>
>> 2.2 The ProtocolMetadata in JoinGroupRequest will be
>> partitionAssignor.protocolMetadata(). When partition.assignor.class is
>> "range" or "roundrobin", the ProtocolMetadata in JoinGroupRequest will be a
>> JSON subscription set. ("range", "roundrobin" will be reserved words, we
>> can also consider reserving some Prefix such as "broker-" to be more clear)
>> 2.3 On broker side when ProtocolType is "range" or "roundroubin",
>> coordinator will parse the ProtocolMetadata in the JoinGroupRequest and
>> assign the partitions for consumers. In the JoinGroupResponse, the
>> ProtocolMetadata will be the global assignment of partitions.
>> 2.4 On client side, after receiving the JoinGroupResponse,
>> partitionAssignor.assignPartitions() will be invoked to return the actual
>> assignment. If the assignor is RangeAssignor or RoundRobinAssignor, they
>> will parse the assignment from the ProtocolMetadata returned by
>> coordinator.
>>
>> This approach has a few merits:
>> 1. Does not change the proposed binary protocol, which is still general.
>> 2. The majority of the consumers will not suffer from inconsistent metadata
>> / split brain / exploding subscription set propagation. This is
>> specifically to deal with the issue that the current proposal caters to a
>> 20% use-case while adversely impacting the more common 80% use-cases.
>> 3. Easy to implement. The only thing needed is implement a partitioner
>> class. For most users, the default range and roundrobin partitioner are
>> good enough.
>>
>> Thoughts?
>>
>> Thanks,
>>
>> Jiangjie (Becket) Qin
>>
>> On Tue, Aug 18, 2015 at 2:51 PM, Jason Gustafson <ja...@confluent.io>
>> wrote:
>>
>> > Follow-up from the kip call:
>> >
>> > 1. Onur brought up the question of whether this protocol provides enough
>> > coordination capabilities to be generally useful in practice (is that
>> > accurate, Onur?). If it doesn't, then each use case would probably need a
>> > dependence on zookeeper anyway, and we haven't really gained anything.
>> The
>> > group membership provided by this protocol is a useful primitive for
>> > coordination, but it's limited in the sense that everything shared among
>> > the group has to be communicated at the time the group is created. If any
>> > shared data changes, then the only way the group can ensure agreement is
>> to
>> > force a rebalance. This is expensive since all members must stall while
>> the
>> > rebalancing takes place. As we have also seen, there is a practical limit
>> > on the amount of metadata that can be sent through this protocol when
>> > groups get a little larger. This protocol is therefore not suitable to
>> > cases which require frequent communication or which require a large
>> amount
>> > of data to be communicated. For the use cases listed on the wiki, neither
>> > of these appear to be an issue, but there may be other limitations which
>> > would limit reuse of the protocol. Perhaps it would be sufficient to
>> sketch
>> > how these cases might work?
>> >
>> > 2. We talked a little bit about the issue of metadata churn. Becket
>> brought
>> > up the interesting point that not only do we depend on topic metadata
>> > changing relatively infrequently, but we also expect timely agreement
>> among
>> > the brokers on what that metadata is. To resolve this, we can have the
>> > consumers fetch metadata from the coordinator. We still depend on topic
>> > metadata not changing frequently, but this should resolve any
>> disagreement
>> > among the brokers themselves. In fact, since we expect that disagreement
>> is
>> > relatively rare, we can have the consumers fetch from the coordinator
>> only
>> > when when a disagreement occurs. The nice thing about this proposal is
>> that
>> > it doesn't affect the join group semantics, so the coordinator would
>> remain
>> > oblivious to the metadata used by the group for agreement. Also, if
>> > metadata churn becomes an issue, it might be possible to have the
>> > coordinator provide a snapshot for the group to ensure that a generation
>> > would be able to reach agreement (this would probably require adding
>> > groupId/generation to the metadata request).
>> >
>> > 3. We talked briefly about support for multiple protocols in the join
>> group
>> > request in order to allow changing the assignment strategy without
>> > downtime. I think it's a little doubtful that this would get much use in
>> > practice, but I agree it's a nice option to have on the table. An
>> > alternative, for the sake of argument, is to have each member provide
>> only
>> > one version of the protocol, and to let the coordinator choose the
>> protocol
>> > with the largest number of supporters. All members which can't support
>> the
>> > selected protocol would be kicked out of the group. The drawback in a
>> > rolling upgrade is that the total capacity of the group would be
>> > momentarily halved. It would also be a little tricky to handle the case
>> of
>> > retrying when a consumer is kicked out of the group. We wouldn't want it
>> to
>> > be able to effect a rebalance, for example, if it would just be kicked
>> out
>> > again. That would probably complicate the group management logic on the
>> > coordinator.
>> >
>> >
>> > Thanks,
>> > Jason
>> >
>> >
>> > On Tue, Aug 18, 2015 at 11:16 AM, Jiangjie Qin <jqin@linkedin.com.invalid
>> >
>> > wrote:
>> >
>> > > Jun,
>> > >
>> > > Yes, I agree. If the metadata can be synced quickly there should not be
>> > an
>> > > issue. It just occurred to me that there is a proposal to allow
>> consuming
>> > > from followers in ISR, that could potentially cause more frequent
>> > metadata
>> > > change for consumers. Would that be an issue?
>> > >
>> > > Thanks,
>> > >
>> > > Jiangjie (Becket) Qin
>> > >
>> > > On Tue, Aug 18, 2015 at 10:22 AM, Jason Gustafson <ja...@confluent.io>
>> > > wrote:
>> > >
>> > > > Hi Jun,
>> > > >
>> > > > Answers below:
>> > > >
>> > > > 1. When there are multiple common protocols in the JoinGroupRequest,
>> > > which
>> > > > one would the coordinator pick?
>> > > >
>> > > > I was intending to use the list to indicate preference. If all group
>> > > > members support protocols ["A", "B"] in that order, then we will
>> choose
>> > > > "A." If some support ["B", "A"], then we would either choose based on
>> > > > respective counts or just randomly. The main use case of supporting
>> the
>> > > > list is for rolling upgrades when a change is made to the assignment
>> > > > strategy. In that case, the new assignment strategy would be listed
>> > first
>> > > > in the upgraded client. I think it's debatable whether this feature
>> > would
>> > > > get much use in practice, so we might consider dropping it.
>> > > >
>> > > > 2. If the protocols don't agree, the group construction fails. What
>> > > exactly
>> > > > does it mean? Do we send an error in every JoinGroupResponse and
>> remove
>> > > all
>> > > > members in the group in the coordinator?
>> > > >
>> > > > Yes, that is right. It would be handled similarly to inconsistent
>> > > > assignment strategies in the current protocol. The coordinator
>> returns
>> > an
>> > > > error in each join group response, and the client propagates the
>> error
>> > to
>> > > > the user.
>> > > >
>> > > > 3. Consumer embedded protocol: The proposal has two different formats
>> > of
>> > > > subscription depending on whether wildcards are used or not. This
>> > seems a
>> > > > bit complicated. Would it be better to always use the metadata hash?
>> > The
>> > > > clients know the subscribed topics already. This way, the client code
>> > > > behaves the same whether wildcards are used or not.
>> > > >
>> > > > Yeah, I think this is possible (Neha also suggested it). I haven't
>> > > updated
>> > > > the wiki yet, but the patch I started working on uses only the
>> metadata
>> > > > hash. In the case that an explicit topic list is provided, the hash
>> > just
>> > > > covers the metadata for those topics.
>> > > >
>> > > >
>> > > > Thanks,
>> > > > Jason
>> > > >
>> > > >
>> > > >
>> > > > On Tue, Aug 18, 2015 at 10:06 AM, Jun Rao <ju...@confluent.io> wrote:
>> > > >
>> > > > > Jason,
>> > > > >
>> > > > > Thanks for the writeup. A few comments below.
>> > > > >
>> > > > > 1. When there are multiple common protocols in the
>> JoinGroupRequest,
>> > > > which
>> > > > > one would the coordinator pick?
>> > > > > 2. If the protocols don't agree, the group construction fails. What
>> > > > exactly
>> > > > > does it mean? Do we send an error in every JoinGroupResponse and
>> > remove
>> > > > all
>> > > > > members in the group in the coordinator?
>> > > > > 3. Consumer embedded protocol: The proposal has two different
>> formats
>> > > of
>> > > > > subscription depending on whether wildcards are used or not. This
>> > > seems a
>> > > > > bit complicated. Would it be better to always use the metadata
>> hash?
>> > > The
>> > > > > clients know the subscribed topics already. This way, the client
>> code
>> > > > > behaves the same whether wildcards are used or not.
>> > > > >
>> > > > > Jiangjie,
>> > > > >
>> > > > > With respect to rebalance churns due to topics being
>> created/deleted.
>> > > > With
>> > > > > the new consumer, the rebalance can probably settle within 200ms
>> when
>> > > > there
>> > > > > is a topic change. So, as long as we are not changing topic more
>> > than 5
>> > > > > times per sec, there shouldn't be constant churns, right?
>> > > > >
>> > > > > Thanks,
>> > > > >
>> > > > > Jun
>> > > > >
>> > > > >
>> > > > >
>> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <
>> jason@confluent.io
>> > >
>> > > > > wrote:
>> > > > >
>> > > > > > Hi Kafka Devs,
>> > > > > >
>> > > > > > One of the nagging issues in the current design of the new
>> consumer
>> > > has
>> > > > > > been the need to support a variety of assignment strategies.
>> We've
>> > > > > > encountered this in particular in the design of copycat and the
>> > > > > processing
>> > > > > > framework (KIP-28). From what I understand, Samza also has a
>> number
>> > > of
>> > > > > use
>> > > > > > cases with custom assignment needs. The new consumer protocol
>> > > supports
>> > > > > new
>> > > > > > assignment strategies by hooking them into the broker. For many
>> > > > > > environments, this is a major pain and in some cases, a
>> > non-starter.
>> > > It
>> > > > > > also challenges the validation that the coordinator can provide.
>> > For
>> > > > > > example, some assignment strategies call for partitions to be
>> > > assigned
>> > > > > > multiple times, which means that the coordinator can only check
>> > that
>> > > > > > partitions have been assigned at least once.
>> > > > > >
>> > > > > > To solve these issues, we'd like to propose moving assignment to
>> > the
>> > > > > > client. I've written a wiki which outlines some protocol changes
>> to
>> > > > > achieve
>> > > > > > this:
>> > > > > >
>> > > > > >
>> > > > >
>> > > >
>> > >
>> >
>> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
>> > > > > > .
>> > > > > > To summarize briefly, instead of the coordinator assigning the
>> > > > partitions
>> > > > > > itself, all subscriptions are forwarded to each member of the
>> group
>> > > > which
>> > > > > > then decides independently which partitions it should consume.
>> The
>> > > > > protocol
>> > > > > > provides a mechanism for the coordinator to validate that all
>> > > consumers
>> > > > > use
>> > > > > > the same assignment strategy, but it does not ensure that the
>> > > resulting
>> > > > > > assignment is "correct." This provides a powerful capability for
>> > > users
>> > > > to
>> > > > > > control the full data flow on the client side. They control how
>> > data
>> > > is
>> > > > > > written to partitions through the Partitioner interface and they
>> > > > control
>> > > > > > how data is consumed through the assignment strategy, all without
>> > > > > touching
>> > > > > > the server.
>> > > > > >
>> > > > > > Of course nothing comes for free. In particular, this change
>> > removes
>> > > > the
>> > > > > > ability of the coordinator to validate that commits are made by
>> > > > consumers
>> > > > > > who were assigned the respective partition. This might not be too
>> > bad
>> > > > > since
>> > > > > > we retain the ability to validate the generation id, but it is a
>> > > > > potential
>> > > > > > concern. We have considered alternative protocols which add a
>> > second
>> > > > > > round-trip to the protocol in order to give the coordinator the
>> > > ability
>> > > > > to
>> > > > > > confirm the assignment. As mentioned above, the coordinator is
>> > > somewhat
>> > > > > > limited in what it can actually validate, but this would return
>> its
>> > > > > ability
>> > > > > > to validate commits. The tradeoff is that it increases the
>> > protocol's
>> > > > > > complexity which means more ways for the protocol to fail and
>> > > > > consequently
>> > > > > > more edge cases in the code.
>> > > > > >
>> > > > > > It also misses an opportunity to generalize the group membership
>> > > > protocol
>> > > > > > for additional use cases. In fact, after you've gone to the
>> trouble
>> > > of
>> > > > > > moving assignment to the client, the main thing that is left in
>> > this
>> > > > > > protocol is basically a general group management capability. This
>> > is
>> > > > > > exactly what is needed for a few cases that are currently under
>> > > > > discussion
>> > > > > > (e.g. copycat or single-writer producer). We've taken this
>> further
>> > > step
>> > > > > in
>> > > > > > the proposal and attempted to envision what that general protocol
>> > > might
>> > > > > > look like and how it could be used both by the consumer and for
>> > some
>> > > of
>> > > > > > these other cases.
>> > > > > >
>> > > > > > Anyway, since time is running out on the new consumer, we have
>> > > perhaps
>> > > > > one
>> > > > > > last chance to consider a significant change in the protocol like
>> > > this,
>> > > > > so
>> > > > > > have a look at the wiki and share your thoughts. I've no doubt
>> that
>> > > > some
>> > > > > > ideas seem clearer in my mind than they do on paper, so ask
>> > questions
>> > > > if
>> > > > > > there is any confusion.
>> > > > > >
>> > > > > > Thanks!
>> > > > > > Jason
>> > > > > >
>> > > > >
>> > > >
>> > >
>> >
>>
>
>
>
> --
> Thanks,
> Neha

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Neha Narkhede <ne...@confluent.io>.
Hey Becket,

In that case, the broker side partition assignment would be ideal because
> it avoids
> issues like metadata inconsistency / split brain / exploding subscription
> set propagation.


As per our previous discussions regarding each of those concerns (referring
to this email thread, KIP calls and JIRA comments), we are going to run a
set of tests using the LinkedIn deployment numbers that we will wait for
you to share. The purpose is to see if those concerns are really valid or
not. I'd prefer to see that before making any more changes that will
complicate the protocol.

On Wed, Aug 26, 2015 at 4:57 PM, Jiangjie Qin <jq...@linkedin.com.invalid>
wrote:

> Hi folks,
>
> After further discussion in LinkedIn, we found that while having a more
> general group management protocol is very useful, the vast majority of the
> clients will not use customized partition assignment strategy. In that
> case, the broker side partition assignment would be ideal because it avoids
> issues like metadata inconsistency / split brain / exploding subscription
> set propagation.
>
> So we have the following proposal that satisfies the majority of the
> clients' needs without changing the currently proposed binary protocol.
> i.e., Continue to support broker-side assignment if the assignment strategy
> is recognized by the coordinator.
>
> 1. Keep the binary protocol as currently proposed.
>
> 2. Change the way we interpret ProtocolMetadata:
> 2.1 On consumer side, change partition.assignment.strategy to
> partition.assignor.class. Implement the something like the following
> PartitionAssignor Interface:
>
> public interface PartitionAssignor {
>   List<String> protocolTypes();
>   byte[] protocolMetadata();
>   // return the Topic->List<Partition> map that are assigned to this
> consumer.
>   List<TopicPartition> assignPartitions(String protocolType, byte[]
> responseProtocolMetadata);
> }
>
> public abstract class AbstractPartitionAssignor implements
> PartitionAssignor {
>   protected final KafkaConsumer consumer;
>   AbstractPartitionAssignor(KafkaConsumer consumer) {
>     this.consumer = consumer;
>   }
> }
>
> 2.2 The ProtocolMetadata in JoinGroupRequest will be
> partitionAssignor.protocolMetadata(). When partition.assignor.class is
> "range" or "roundrobin", the ProtocolMetadata in JoinGroupRequest will be a
> JSON subscription set. ("range", "roundrobin" will be reserved words, we
> can also consider reserving some Prefix such as "broker-" to be more clear)
> 2.3 On broker side when ProtocolType is "range" or "roundroubin",
> coordinator will parse the ProtocolMetadata in the JoinGroupRequest and
> assign the partitions for consumers. In the JoinGroupResponse, the
> ProtocolMetadata will be the global assignment of partitions.
> 2.4 On client side, after receiving the JoinGroupResponse,
> partitionAssignor.assignPartitions() will be invoked to return the actual
> assignment. If the assignor is RangeAssignor or RoundRobinAssignor, they
> will parse the assignment from the ProtocolMetadata returned by
> coordinator.
>
> This approach has a few merits:
> 1. Does not change the proposed binary protocol, which is still general.
> 2. The majority of the consumers will not suffer from inconsistent metadata
> / split brain / exploding subscription set propagation. This is
> specifically to deal with the issue that the current proposal caters to a
> 20% use-case while adversely impacting the more common 80% use-cases.
> 3. Easy to implement. The only thing needed is implement a partitioner
> class. For most users, the default range and roundrobin partitioner are
> good enough.
>
> Thoughts?
>
> Thanks,
>
> Jiangjie (Becket) Qin
>
> On Tue, Aug 18, 2015 at 2:51 PM, Jason Gustafson <ja...@confluent.io>
> wrote:
>
> > Follow-up from the kip call:
> >
> > 1. Onur brought up the question of whether this protocol provides enough
> > coordination capabilities to be generally useful in practice (is that
> > accurate, Onur?). If it doesn't, then each use case would probably need a
> > dependence on zookeeper anyway, and we haven't really gained anything.
> The
> > group membership provided by this protocol is a useful primitive for
> > coordination, but it's limited in the sense that everything shared among
> > the group has to be communicated at the time the group is created. If any
> > shared data changes, then the only way the group can ensure agreement is
> to
> > force a rebalance. This is expensive since all members must stall while
> the
> > rebalancing takes place. As we have also seen, there is a practical limit
> > on the amount of metadata that can be sent through this protocol when
> > groups get a little larger. This protocol is therefore not suitable to
> > cases which require frequent communication or which require a large
> amount
> > of data to be communicated. For the use cases listed on the wiki, neither
> > of these appear to be an issue, but there may be other limitations which
> > would limit reuse of the protocol. Perhaps it would be sufficient to
> sketch
> > how these cases might work?
> >
> > 2. We talked a little bit about the issue of metadata churn. Becket
> brought
> > up the interesting point that not only do we depend on topic metadata
> > changing relatively infrequently, but we also expect timely agreement
> among
> > the brokers on what that metadata is. To resolve this, we can have the
> > consumers fetch metadata from the coordinator. We still depend on topic
> > metadata not changing frequently, but this should resolve any
> disagreement
> > among the brokers themselves. In fact, since we expect that disagreement
> is
> > relatively rare, we can have the consumers fetch from the coordinator
> only
> > when when a disagreement occurs. The nice thing about this proposal is
> that
> > it doesn't affect the join group semantics, so the coordinator would
> remain
> > oblivious to the metadata used by the group for agreement. Also, if
> > metadata churn becomes an issue, it might be possible to have the
> > coordinator provide a snapshot for the group to ensure that a generation
> > would be able to reach agreement (this would probably require adding
> > groupId/generation to the metadata request).
> >
> > 3. We talked briefly about support for multiple protocols in the join
> group
> > request in order to allow changing the assignment strategy without
> > downtime. I think it's a little doubtful that this would get much use in
> > practice, but I agree it's a nice option to have on the table. An
> > alternative, for the sake of argument, is to have each member provide
> only
> > one version of the protocol, and to let the coordinator choose the
> protocol
> > with the largest number of supporters. All members which can't support
> the
> > selected protocol would be kicked out of the group. The drawback in a
> > rolling upgrade is that the total capacity of the group would be
> > momentarily halved. It would also be a little tricky to handle the case
> of
> > retrying when a consumer is kicked out of the group. We wouldn't want it
> to
> > be able to effect a rebalance, for example, if it would just be kicked
> out
> > again. That would probably complicate the group management logic on the
> > coordinator.
> >
> >
> > Thanks,
> > Jason
> >
> >
> > On Tue, Aug 18, 2015 at 11:16 AM, Jiangjie Qin <jqin@linkedin.com.invalid
> >
> > wrote:
> >
> > > Jun,
> > >
> > > Yes, I agree. If the metadata can be synced quickly there should not be
> > an
> > > issue. It just occurred to me that there is a proposal to allow
> consuming
> > > from followers in ISR, that could potentially cause more frequent
> > metadata
> > > change for consumers. Would that be an issue?
> > >
> > > Thanks,
> > >
> > > Jiangjie (Becket) Qin
> > >
> > > On Tue, Aug 18, 2015 at 10:22 AM, Jason Gustafson <ja...@confluent.io>
> > > wrote:
> > >
> > > > Hi Jun,
> > > >
> > > > Answers below:
> > > >
> > > > 1. When there are multiple common protocols in the JoinGroupRequest,
> > > which
> > > > one would the coordinator pick?
> > > >
> > > > I was intending to use the list to indicate preference. If all group
> > > > members support protocols ["A", "B"] in that order, then we will
> choose
> > > > "A." If some support ["B", "A"], then we would either choose based on
> > > > respective counts or just randomly. The main use case of supporting
> the
> > > > list is for rolling upgrades when a change is made to the assignment
> > > > strategy. In that case, the new assignment strategy would be listed
> > first
> > > > in the upgraded client. I think it's debatable whether this feature
> > would
> > > > get much use in practice, so we might consider dropping it.
> > > >
> > > > 2. If the protocols don't agree, the group construction fails. What
> > > exactly
> > > > does it mean? Do we send an error in every JoinGroupResponse and
> remove
> > > all
> > > > members in the group in the coordinator?
> > > >
> > > > Yes, that is right. It would be handled similarly to inconsistent
> > > > assignment strategies in the current protocol. The coordinator
> returns
> > an
> > > > error in each join group response, and the client propagates the
> error
> > to
> > > > the user.
> > > >
> > > > 3. Consumer embedded protocol: The proposal has two different formats
> > of
> > > > subscription depending on whether wildcards are used or not. This
> > seems a
> > > > bit complicated. Would it be better to always use the metadata hash?
> > The
> > > > clients know the subscribed topics already. This way, the client code
> > > > behaves the same whether wildcards are used or not.
> > > >
> > > > Yeah, I think this is possible (Neha also suggested it). I haven't
> > > updated
> > > > the wiki yet, but the patch I started working on uses only the
> metadata
> > > > hash. In the case that an explicit topic list is provided, the hash
> > just
> > > > covers the metadata for those topics.
> > > >
> > > >
> > > > Thanks,
> > > > Jason
> > > >
> > > >
> > > >
> > > > On Tue, Aug 18, 2015 at 10:06 AM, Jun Rao <ju...@confluent.io> wrote:
> > > >
> > > > > Jason,
> > > > >
> > > > > Thanks for the writeup. A few comments below.
> > > > >
> > > > > 1. When there are multiple common protocols in the
> JoinGroupRequest,
> > > > which
> > > > > one would the coordinator pick?
> > > > > 2. If the protocols don't agree, the group construction fails. What
> > > > exactly
> > > > > does it mean? Do we send an error in every JoinGroupResponse and
> > remove
> > > > all
> > > > > members in the group in the coordinator?
> > > > > 3. Consumer embedded protocol: The proposal has two different
> formats
> > > of
> > > > > subscription depending on whether wildcards are used or not. This
> > > seems a
> > > > > bit complicated. Would it be better to always use the metadata
> hash?
> > > The
> > > > > clients know the subscribed topics already. This way, the client
> code
> > > > > behaves the same whether wildcards are used or not.
> > > > >
> > > > > Jiangjie,
> > > > >
> > > > > With respect to rebalance churns due to topics being
> created/deleted.
> > > > With
> > > > > the new consumer, the rebalance can probably settle within 200ms
> when
> > > > there
> > > > > is a topic change. So, as long as we are not changing topic more
> > than 5
> > > > > times per sec, there shouldn't be constant churns, right?
> > > > >
> > > > > Thanks,
> > > > >
> > > > > Jun
> > > > >
> > > > >
> > > > >
> > > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <
> jason@confluent.io
> > >
> > > > > wrote:
> > > > >
> > > > > > Hi Kafka Devs,
> > > > > >
> > > > > > One of the nagging issues in the current design of the new
> consumer
> > > has
> > > > > > been the need to support a variety of assignment strategies.
> We've
> > > > > > encountered this in particular in the design of copycat and the
> > > > > processing
> > > > > > framework (KIP-28). From what I understand, Samza also has a
> number
> > > of
> > > > > use
> > > > > > cases with custom assignment needs. The new consumer protocol
> > > supports
> > > > > new
> > > > > > assignment strategies by hooking them into the broker. For many
> > > > > > environments, this is a major pain and in some cases, a
> > non-starter.
> > > It
> > > > > > also challenges the validation that the coordinator can provide.
> > For
> > > > > > example, some assignment strategies call for partitions to be
> > > assigned
> > > > > > multiple times, which means that the coordinator can only check
> > that
> > > > > > partitions have been assigned at least once.
> > > > > >
> > > > > > To solve these issues, we'd like to propose moving assignment to
> > the
> > > > > > client. I've written a wiki which outlines some protocol changes
> to
> > > > > achieve
> > > > > > this:
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> > > > > > .
> > > > > > To summarize briefly, instead of the coordinator assigning the
> > > > partitions
> > > > > > itself, all subscriptions are forwarded to each member of the
> group
> > > > which
> > > > > > then decides independently which partitions it should consume.
> The
> > > > > protocol
> > > > > > provides a mechanism for the coordinator to validate that all
> > > consumers
> > > > > use
> > > > > > the same assignment strategy, but it does not ensure that the
> > > resulting
> > > > > > assignment is "correct." This provides a powerful capability for
> > > users
> > > > to
> > > > > > control the full data flow on the client side. They control how
> > data
> > > is
> > > > > > written to partitions through the Partitioner interface and they
> > > > control
> > > > > > how data is consumed through the assignment strategy, all without
> > > > > touching
> > > > > > the server.
> > > > > >
> > > > > > Of course nothing comes for free. In particular, this change
> > removes
> > > > the
> > > > > > ability of the coordinator to validate that commits are made by
> > > > consumers
> > > > > > who were assigned the respective partition. This might not be too
> > bad
> > > > > since
> > > > > > we retain the ability to validate the generation id, but it is a
> > > > > potential
> > > > > > concern. We have considered alternative protocols which add a
> > second
> > > > > > round-trip to the protocol in order to give the coordinator the
> > > ability
> > > > > to
> > > > > > confirm the assignment. As mentioned above, the coordinator is
> > > somewhat
> > > > > > limited in what it can actually validate, but this would return
> its
> > > > > ability
> > > > > > to validate commits. The tradeoff is that it increases the
> > protocol's
> > > > > > complexity which means more ways for the protocol to fail and
> > > > > consequently
> > > > > > more edge cases in the code.
> > > > > >
> > > > > > It also misses an opportunity to generalize the group membership
> > > > protocol
> > > > > > for additional use cases. In fact, after you've gone to the
> trouble
> > > of
> > > > > > moving assignment to the client, the main thing that is left in
> > this
> > > > > > protocol is basically a general group management capability. This
> > is
> > > > > > exactly what is needed for a few cases that are currently under
> > > > > discussion
> > > > > > (e.g. copycat or single-writer producer). We've taken this
> further
> > > step
> > > > > in
> > > > > > the proposal and attempted to envision what that general protocol
> > > might
> > > > > > look like and how it could be used both by the consumer and for
> > some
> > > of
> > > > > > these other cases.
> > > > > >
> > > > > > Anyway, since time is running out on the new consumer, we have
> > > perhaps
> > > > > one
> > > > > > last chance to consider a significant change in the protocol like
> > > this,
> > > > > so
> > > > > > have a look at the wiki and share your thoughts. I've no doubt
> that
> > > > some
> > > > > > ideas seem clearer in my mind than they do on paper, so ask
> > questions
> > > > if
> > > > > > there is any confusion.
> > > > > >
> > > > > > Thanks!
> > > > > > Jason
> > > > > >
> > > > >
> > > >
> > >
> >
>



-- 
Thanks,
Neha

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Jiangjie Qin <jq...@linkedin.com.INVALID>.
Hi folks,

After further discussion in LinkedIn, we found that while having a more
general group management protocol is very useful, the vast majority of the
clients will not use customized partition assignment strategy. In that
case, the broker side partition assignment would be ideal because it avoids
issues like metadata inconsistency / split brain / exploding subscription
set propagation.

So we have the following proposal that satisfies the majority of the
clients' needs without changing the currently proposed binary protocol.
i.e., Continue to support broker-side assignment if the assignment strategy
is recognized by the coordinator.

1. Keep the binary protocol as currently proposed.

2. Change the way we interpret ProtocolMetadata:
2.1 On consumer side, change partition.assignment.strategy to
partition.assignor.class. Implement the something like the following
PartitionAssignor Interface:

public interface PartitionAssignor {
  List<String> protocolTypes();
  byte[] protocolMetadata();
  // return the Topic->List<Partition> map that are assigned to this
consumer.
  List<TopicPartition> assignPartitions(String protocolType, byte[]
responseProtocolMetadata);
}

public abstract class AbstractPartitionAssignor implements
PartitionAssignor {
  protected final KafkaConsumer consumer;
  AbstractPartitionAssignor(KafkaConsumer consumer) {
    this.consumer = consumer;
  }
}

2.2 The ProtocolMetadata in JoinGroupRequest will be
partitionAssignor.protocolMetadata(). When partition.assignor.class is
"range" or "roundrobin", the ProtocolMetadata in JoinGroupRequest will be a
JSON subscription set. ("range", "roundrobin" will be reserved words, we
can also consider reserving some Prefix such as "broker-" to be more clear)
2.3 On broker side when ProtocolType is "range" or "roundroubin",
coordinator will parse the ProtocolMetadata in the JoinGroupRequest and
assign the partitions for consumers. In the JoinGroupResponse, the
ProtocolMetadata will be the global assignment of partitions.
2.4 On client side, after receiving the JoinGroupResponse,
partitionAssignor.assignPartitions() will be invoked to return the actual
assignment. If the assignor is RangeAssignor or RoundRobinAssignor, they
will parse the assignment from the ProtocolMetadata returned by coordinator.

This approach has a few merits:
1. Does not change the proposed binary protocol, which is still general.
2. The majority of the consumers will not suffer from inconsistent metadata
/ split brain / exploding subscription set propagation. This is
specifically to deal with the issue that the current proposal caters to a
20% use-case while adversely impacting the more common 80% use-cases.
3. Easy to implement. The only thing needed is implement a partitioner
class. For most users, the default range and roundrobin partitioner are
good enough.

Thoughts?

Thanks,

Jiangjie (Becket) Qin

On Tue, Aug 18, 2015 at 2:51 PM, Jason Gustafson <ja...@confluent.io> wrote:

> Follow-up from the kip call:
>
> 1. Onur brought up the question of whether this protocol provides enough
> coordination capabilities to be generally useful in practice (is that
> accurate, Onur?). If it doesn't, then each use case would probably need a
> dependence on zookeeper anyway, and we haven't really gained anything. The
> group membership provided by this protocol is a useful primitive for
> coordination, but it's limited in the sense that everything shared among
> the group has to be communicated at the time the group is created. If any
> shared data changes, then the only way the group can ensure agreement is to
> force a rebalance. This is expensive since all members must stall while the
> rebalancing takes place. As we have also seen, there is a practical limit
> on the amount of metadata that can be sent through this protocol when
> groups get a little larger. This protocol is therefore not suitable to
> cases which require frequent communication or which require a large amount
> of data to be communicated. For the use cases listed on the wiki, neither
> of these appear to be an issue, but there may be other limitations which
> would limit reuse of the protocol. Perhaps it would be sufficient to sketch
> how these cases might work?
>
> 2. We talked a little bit about the issue of metadata churn. Becket brought
> up the interesting point that not only do we depend on topic metadata
> changing relatively infrequently, but we also expect timely agreement among
> the brokers on what that metadata is. To resolve this, we can have the
> consumers fetch metadata from the coordinator. We still depend on topic
> metadata not changing frequently, but this should resolve any disagreement
> among the brokers themselves. In fact, since we expect that disagreement is
> relatively rare, we can have the consumers fetch from the coordinator only
> when when a disagreement occurs. The nice thing about this proposal is that
> it doesn't affect the join group semantics, so the coordinator would remain
> oblivious to the metadata used by the group for agreement. Also, if
> metadata churn becomes an issue, it might be possible to have the
> coordinator provide a snapshot for the group to ensure that a generation
> would be able to reach agreement (this would probably require adding
> groupId/generation to the metadata request).
>
> 3. We talked briefly about support for multiple protocols in the join group
> request in order to allow changing the assignment strategy without
> downtime. I think it's a little doubtful that this would get much use in
> practice, but I agree it's a nice option to have on the table. An
> alternative, for the sake of argument, is to have each member provide only
> one version of the protocol, and to let the coordinator choose the protocol
> with the largest number of supporters. All members which can't support the
> selected protocol would be kicked out of the group. The drawback in a
> rolling upgrade is that the total capacity of the group would be
> momentarily halved. It would also be a little tricky to handle the case of
> retrying when a consumer is kicked out of the group. We wouldn't want it to
> be able to effect a rebalance, for example, if it would just be kicked out
> again. That would probably complicate the group management logic on the
> coordinator.
>
>
> Thanks,
> Jason
>
>
> On Tue, Aug 18, 2015 at 11:16 AM, Jiangjie Qin <jq...@linkedin.com.invalid>
> wrote:
>
> > Jun,
> >
> > Yes, I agree. If the metadata can be synced quickly there should not be
> an
> > issue. It just occurred to me that there is a proposal to allow consuming
> > from followers in ISR, that could potentially cause more frequent
> metadata
> > change for consumers. Would that be an issue?
> >
> > Thanks,
> >
> > Jiangjie (Becket) Qin
> >
> > On Tue, Aug 18, 2015 at 10:22 AM, Jason Gustafson <ja...@confluent.io>
> > wrote:
> >
> > > Hi Jun,
> > >
> > > Answers below:
> > >
> > > 1. When there are multiple common protocols in the JoinGroupRequest,
> > which
> > > one would the coordinator pick?
> > >
> > > I was intending to use the list to indicate preference. If all group
> > > members support protocols ["A", "B"] in that order, then we will choose
> > > "A." If some support ["B", "A"], then we would either choose based on
> > > respective counts or just randomly. The main use case of supporting the
> > > list is for rolling upgrades when a change is made to the assignment
> > > strategy. In that case, the new assignment strategy would be listed
> first
> > > in the upgraded client. I think it's debatable whether this feature
> would
> > > get much use in practice, so we might consider dropping it.
> > >
> > > 2. If the protocols don't agree, the group construction fails. What
> > exactly
> > > does it mean? Do we send an error in every JoinGroupResponse and remove
> > all
> > > members in the group in the coordinator?
> > >
> > > Yes, that is right. It would be handled similarly to inconsistent
> > > assignment strategies in the current protocol. The coordinator returns
> an
> > > error in each join group response, and the client propagates the error
> to
> > > the user.
> > >
> > > 3. Consumer embedded protocol: The proposal has two different formats
> of
> > > subscription depending on whether wildcards are used or not. This
> seems a
> > > bit complicated. Would it be better to always use the metadata hash?
> The
> > > clients know the subscribed topics already. This way, the client code
> > > behaves the same whether wildcards are used or not.
> > >
> > > Yeah, I think this is possible (Neha also suggested it). I haven't
> > updated
> > > the wiki yet, but the patch I started working on uses only the metadata
> > > hash. In the case that an explicit topic list is provided, the hash
> just
> > > covers the metadata for those topics.
> > >
> > >
> > > Thanks,
> > > Jason
> > >
> > >
> > >
> > > On Tue, Aug 18, 2015 at 10:06 AM, Jun Rao <ju...@confluent.io> wrote:
> > >
> > > > Jason,
> > > >
> > > > Thanks for the writeup. A few comments below.
> > > >
> > > > 1. When there are multiple common protocols in the JoinGroupRequest,
> > > which
> > > > one would the coordinator pick?
> > > > 2. If the protocols don't agree, the group construction fails. What
> > > exactly
> > > > does it mean? Do we send an error in every JoinGroupResponse and
> remove
> > > all
> > > > members in the group in the coordinator?
> > > > 3. Consumer embedded protocol: The proposal has two different formats
> > of
> > > > subscription depending on whether wildcards are used or not. This
> > seems a
> > > > bit complicated. Would it be better to always use the metadata hash?
> > The
> > > > clients know the subscribed topics already. This way, the client code
> > > > behaves the same whether wildcards are used or not.
> > > >
> > > > Jiangjie,
> > > >
> > > > With respect to rebalance churns due to topics being created/deleted.
> > > With
> > > > the new consumer, the rebalance can probably settle within 200ms when
> > > there
> > > > is a topic change. So, as long as we are not changing topic more
> than 5
> > > > times per sec, there shouldn't be constant churns, right?
> > > >
> > > > Thanks,
> > > >
> > > > Jun
> > > >
> > > >
> > > >
> > > > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <jason@confluent.io
> >
> > > > wrote:
> > > >
> > > > > Hi Kafka Devs,
> > > > >
> > > > > One of the nagging issues in the current design of the new consumer
> > has
> > > > > been the need to support a variety of assignment strategies. We've
> > > > > encountered this in particular in the design of copycat and the
> > > > processing
> > > > > framework (KIP-28). From what I understand, Samza also has a number
> > of
> > > > use
> > > > > cases with custom assignment needs. The new consumer protocol
> > supports
> > > > new
> > > > > assignment strategies by hooking them into the broker. For many
> > > > > environments, this is a major pain and in some cases, a
> non-starter.
> > It
> > > > > also challenges the validation that the coordinator can provide.
> For
> > > > > example, some assignment strategies call for partitions to be
> > assigned
> > > > > multiple times, which means that the coordinator can only check
> that
> > > > > partitions have been assigned at least once.
> > > > >
> > > > > To solve these issues, we'd like to propose moving assignment to
> the
> > > > > client. I've written a wiki which outlines some protocol changes to
> > > > achieve
> > > > > this:
> > > > >
> > > > >
> > > >
> > >
> >
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> > > > > .
> > > > > To summarize briefly, instead of the coordinator assigning the
> > > partitions
> > > > > itself, all subscriptions are forwarded to each member of the group
> > > which
> > > > > then decides independently which partitions it should consume. The
> > > > protocol
> > > > > provides a mechanism for the coordinator to validate that all
> > consumers
> > > > use
> > > > > the same assignment strategy, but it does not ensure that the
> > resulting
> > > > > assignment is "correct." This provides a powerful capability for
> > users
> > > to
> > > > > control the full data flow on the client side. They control how
> data
> > is
> > > > > written to partitions through the Partitioner interface and they
> > > control
> > > > > how data is consumed through the assignment strategy, all without
> > > > touching
> > > > > the server.
> > > > >
> > > > > Of course nothing comes for free. In particular, this change
> removes
> > > the
> > > > > ability of the coordinator to validate that commits are made by
> > > consumers
> > > > > who were assigned the respective partition. This might not be too
> bad
> > > > since
> > > > > we retain the ability to validate the generation id, but it is a
> > > > potential
> > > > > concern. We have considered alternative protocols which add a
> second
> > > > > round-trip to the protocol in order to give the coordinator the
> > ability
> > > > to
> > > > > confirm the assignment. As mentioned above, the coordinator is
> > somewhat
> > > > > limited in what it can actually validate, but this would return its
> > > > ability
> > > > > to validate commits. The tradeoff is that it increases the
> protocol's
> > > > > complexity which means more ways for the protocol to fail and
> > > > consequently
> > > > > more edge cases in the code.
> > > > >
> > > > > It also misses an opportunity to generalize the group membership
> > > protocol
> > > > > for additional use cases. In fact, after you've gone to the trouble
> > of
> > > > > moving assignment to the client, the main thing that is left in
> this
> > > > > protocol is basically a general group management capability. This
> is
> > > > > exactly what is needed for a few cases that are currently under
> > > > discussion
> > > > > (e.g. copycat or single-writer producer). We've taken this further
> > step
> > > > in
> > > > > the proposal and attempted to envision what that general protocol
> > might
> > > > > look like and how it could be used both by the consumer and for
> some
> > of
> > > > > these other cases.
> > > > >
> > > > > Anyway, since time is running out on the new consumer, we have
> > perhaps
> > > > one
> > > > > last chance to consider a significant change in the protocol like
> > this,
> > > > so
> > > > > have a look at the wiki and share your thoughts. I've no doubt that
> > > some
> > > > > ideas seem clearer in my mind than they do on paper, so ask
> questions
> > > if
> > > > > there is any confusion.
> > > > >
> > > > > Thanks!
> > > > > Jason
> > > > >
> > > >
> > >
> >
>

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Jason Gustafson <ja...@confluent.io>.
Follow-up from the kip call:

1. Onur brought up the question of whether this protocol provides enough
coordination capabilities to be generally useful in practice (is that
accurate, Onur?). If it doesn't, then each use case would probably need a
dependence on zookeeper anyway, and we haven't really gained anything. The
group membership provided by this protocol is a useful primitive for
coordination, but it's limited in the sense that everything shared among
the group has to be communicated at the time the group is created. If any
shared data changes, then the only way the group can ensure agreement is to
force a rebalance. This is expensive since all members must stall while the
rebalancing takes place. As we have also seen, there is a practical limit
on the amount of metadata that can be sent through this protocol when
groups get a little larger. This protocol is therefore not suitable to
cases which require frequent communication or which require a large amount
of data to be communicated. For the use cases listed on the wiki, neither
of these appear to be an issue, but there may be other limitations which
would limit reuse of the protocol. Perhaps it would be sufficient to sketch
how these cases might work?

2. We talked a little bit about the issue of metadata churn. Becket brought
up the interesting point that not only do we depend on topic metadata
changing relatively infrequently, but we also expect timely agreement among
the brokers on what that metadata is. To resolve this, we can have the
consumers fetch metadata from the coordinator. We still depend on topic
metadata not changing frequently, but this should resolve any disagreement
among the brokers themselves. In fact, since we expect that disagreement is
relatively rare, we can have the consumers fetch from the coordinator only
when when a disagreement occurs. The nice thing about this proposal is that
it doesn't affect the join group semantics, so the coordinator would remain
oblivious to the metadata used by the group for agreement. Also, if
metadata churn becomes an issue, it might be possible to have the
coordinator provide a snapshot for the group to ensure that a generation
would be able to reach agreement (this would probably require adding
groupId/generation to the metadata request).

3. We talked briefly about support for multiple protocols in the join group
request in order to allow changing the assignment strategy without
downtime. I think it's a little doubtful that this would get much use in
practice, but I agree it's a nice option to have on the table. An
alternative, for the sake of argument, is to have each member provide only
one version of the protocol, and to let the coordinator choose the protocol
with the largest number of supporters. All members which can't support the
selected protocol would be kicked out of the group. The drawback in a
rolling upgrade is that the total capacity of the group would be
momentarily halved. It would also be a little tricky to handle the case of
retrying when a consumer is kicked out of the group. We wouldn't want it to
be able to effect a rebalance, for example, if it would just be kicked out
again. That would probably complicate the group management logic on the
coordinator.


Thanks,
Jason


On Tue, Aug 18, 2015 at 11:16 AM, Jiangjie Qin <jq...@linkedin.com.invalid>
wrote:

> Jun,
>
> Yes, I agree. If the metadata can be synced quickly there should not be an
> issue. It just occurred to me that there is a proposal to allow consuming
> from followers in ISR, that could potentially cause more frequent metadata
> change for consumers. Would that be an issue?
>
> Thanks,
>
> Jiangjie (Becket) Qin
>
> On Tue, Aug 18, 2015 at 10:22 AM, Jason Gustafson <ja...@confluent.io>
> wrote:
>
> > Hi Jun,
> >
> > Answers below:
> >
> > 1. When there are multiple common protocols in the JoinGroupRequest,
> which
> > one would the coordinator pick?
> >
> > I was intending to use the list to indicate preference. If all group
> > members support protocols ["A", "B"] in that order, then we will choose
> > "A." If some support ["B", "A"], then we would either choose based on
> > respective counts or just randomly. The main use case of supporting the
> > list is for rolling upgrades when a change is made to the assignment
> > strategy. In that case, the new assignment strategy would be listed first
> > in the upgraded client. I think it's debatable whether this feature would
> > get much use in practice, so we might consider dropping it.
> >
> > 2. If the protocols don't agree, the group construction fails. What
> exactly
> > does it mean? Do we send an error in every JoinGroupResponse and remove
> all
> > members in the group in the coordinator?
> >
> > Yes, that is right. It would be handled similarly to inconsistent
> > assignment strategies in the current protocol. The coordinator returns an
> > error in each join group response, and the client propagates the error to
> > the user.
> >
> > 3. Consumer embedded protocol: The proposal has two different formats of
> > subscription depending on whether wildcards are used or not. This seems a
> > bit complicated. Would it be better to always use the metadata hash? The
> > clients know the subscribed topics already. This way, the client code
> > behaves the same whether wildcards are used or not.
> >
> > Yeah, I think this is possible (Neha also suggested it). I haven't
> updated
> > the wiki yet, but the patch I started working on uses only the metadata
> > hash. In the case that an explicit topic list is provided, the hash just
> > covers the metadata for those topics.
> >
> >
> > Thanks,
> > Jason
> >
> >
> >
> > On Tue, Aug 18, 2015 at 10:06 AM, Jun Rao <ju...@confluent.io> wrote:
> >
> > > Jason,
> > >
> > > Thanks for the writeup. A few comments below.
> > >
> > > 1. When there are multiple common protocols in the JoinGroupRequest,
> > which
> > > one would the coordinator pick?
> > > 2. If the protocols don't agree, the group construction fails. What
> > exactly
> > > does it mean? Do we send an error in every JoinGroupResponse and remove
> > all
> > > members in the group in the coordinator?
> > > 3. Consumer embedded protocol: The proposal has two different formats
> of
> > > subscription depending on whether wildcards are used or not. This
> seems a
> > > bit complicated. Would it be better to always use the metadata hash?
> The
> > > clients know the subscribed topics already. This way, the client code
> > > behaves the same whether wildcards are used or not.
> > >
> > > Jiangjie,
> > >
> > > With respect to rebalance churns due to topics being created/deleted.
> > With
> > > the new consumer, the rebalance can probably settle within 200ms when
> > there
> > > is a topic change. So, as long as we are not changing topic more than 5
> > > times per sec, there shouldn't be constant churns, right?
> > >
> > > Thanks,
> > >
> > > Jun
> > >
> > >
> > >
> > > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <ja...@confluent.io>
> > > wrote:
> > >
> > > > Hi Kafka Devs,
> > > >
> > > > One of the nagging issues in the current design of the new consumer
> has
> > > > been the need to support a variety of assignment strategies. We've
> > > > encountered this in particular in the design of copycat and the
> > > processing
> > > > framework (KIP-28). From what I understand, Samza also has a number
> of
> > > use
> > > > cases with custom assignment needs. The new consumer protocol
> supports
> > > new
> > > > assignment strategies by hooking them into the broker. For many
> > > > environments, this is a major pain and in some cases, a non-starter.
> It
> > > > also challenges the validation that the coordinator can provide. For
> > > > example, some assignment strategies call for partitions to be
> assigned
> > > > multiple times, which means that the coordinator can only check that
> > > > partitions have been assigned at least once.
> > > >
> > > > To solve these issues, we'd like to propose moving assignment to the
> > > > client. I've written a wiki which outlines some protocol changes to
> > > achieve
> > > > this:
> > > >
> > > >
> > >
> >
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> > > > .
> > > > To summarize briefly, instead of the coordinator assigning the
> > partitions
> > > > itself, all subscriptions are forwarded to each member of the group
> > which
> > > > then decides independently which partitions it should consume. The
> > > protocol
> > > > provides a mechanism for the coordinator to validate that all
> consumers
> > > use
> > > > the same assignment strategy, but it does not ensure that the
> resulting
> > > > assignment is "correct." This provides a powerful capability for
> users
> > to
> > > > control the full data flow on the client side. They control how data
> is
> > > > written to partitions through the Partitioner interface and they
> > control
> > > > how data is consumed through the assignment strategy, all without
> > > touching
> > > > the server.
> > > >
> > > > Of course nothing comes for free. In particular, this change removes
> > the
> > > > ability of the coordinator to validate that commits are made by
> > consumers
> > > > who were assigned the respective partition. This might not be too bad
> > > since
> > > > we retain the ability to validate the generation id, but it is a
> > > potential
> > > > concern. We have considered alternative protocols which add a second
> > > > round-trip to the protocol in order to give the coordinator the
> ability
> > > to
> > > > confirm the assignment. As mentioned above, the coordinator is
> somewhat
> > > > limited in what it can actually validate, but this would return its
> > > ability
> > > > to validate commits. The tradeoff is that it increases the protocol's
> > > > complexity which means more ways for the protocol to fail and
> > > consequently
> > > > more edge cases in the code.
> > > >
> > > > It also misses an opportunity to generalize the group membership
> > protocol
> > > > for additional use cases. In fact, after you've gone to the trouble
> of
> > > > moving assignment to the client, the main thing that is left in this
> > > > protocol is basically a general group management capability. This is
> > > > exactly what is needed for a few cases that are currently under
> > > discussion
> > > > (e.g. copycat or single-writer producer). We've taken this further
> step
> > > in
> > > > the proposal and attempted to envision what that general protocol
> might
> > > > look like and how it could be used both by the consumer and for some
> of
> > > > these other cases.
> > > >
> > > > Anyway, since time is running out on the new consumer, we have
> perhaps
> > > one
> > > > last chance to consider a significant change in the protocol like
> this,
> > > so
> > > > have a look at the wiki and share your thoughts. I've no doubt that
> > some
> > > > ideas seem clearer in my mind than they do on paper, so ask questions
> > if
> > > > there is any confusion.
> > > >
> > > > Thanks!
> > > > Jason
> > > >
> > >
> >
>

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Jiangjie Qin <jq...@linkedin.com.INVALID>.
Jun,

Yes, I agree. If the metadata can be synced quickly there should not be an
issue. It just occurred to me that there is a proposal to allow consuming
from followers in ISR, that could potentially cause more frequent metadata
change for consumers. Would that be an issue?

Thanks,

Jiangjie (Becket) Qin

On Tue, Aug 18, 2015 at 10:22 AM, Jason Gustafson <ja...@confluent.io>
wrote:

> Hi Jun,
>
> Answers below:
>
> 1. When there are multiple common protocols in the JoinGroupRequest, which
> one would the coordinator pick?
>
> I was intending to use the list to indicate preference. If all group
> members support protocols ["A", "B"] in that order, then we will choose
> "A." If some support ["B", "A"], then we would either choose based on
> respective counts or just randomly. The main use case of supporting the
> list is for rolling upgrades when a change is made to the assignment
> strategy. In that case, the new assignment strategy would be listed first
> in the upgraded client. I think it's debatable whether this feature would
> get much use in practice, so we might consider dropping it.
>
> 2. If the protocols don't agree, the group construction fails. What exactly
> does it mean? Do we send an error in every JoinGroupResponse and remove all
> members in the group in the coordinator?
>
> Yes, that is right. It would be handled similarly to inconsistent
> assignment strategies in the current protocol. The coordinator returns an
> error in each join group response, and the client propagates the error to
> the user.
>
> 3. Consumer embedded protocol: The proposal has two different formats of
> subscription depending on whether wildcards are used or not. This seems a
> bit complicated. Would it be better to always use the metadata hash? The
> clients know the subscribed topics already. This way, the client code
> behaves the same whether wildcards are used or not.
>
> Yeah, I think this is possible (Neha also suggested it). I haven't updated
> the wiki yet, but the patch I started working on uses only the metadata
> hash. In the case that an explicit topic list is provided, the hash just
> covers the metadata for those topics.
>
>
> Thanks,
> Jason
>
>
>
> On Tue, Aug 18, 2015 at 10:06 AM, Jun Rao <ju...@confluent.io> wrote:
>
> > Jason,
> >
> > Thanks for the writeup. A few comments below.
> >
> > 1. When there are multiple common protocols in the JoinGroupRequest,
> which
> > one would the coordinator pick?
> > 2. If the protocols don't agree, the group construction fails. What
> exactly
> > does it mean? Do we send an error in every JoinGroupResponse and remove
> all
> > members in the group in the coordinator?
> > 3. Consumer embedded protocol: The proposal has two different formats of
> > subscription depending on whether wildcards are used or not. This seems a
> > bit complicated. Would it be better to always use the metadata hash? The
> > clients know the subscribed topics already. This way, the client code
> > behaves the same whether wildcards are used or not.
> >
> > Jiangjie,
> >
> > With respect to rebalance churns due to topics being created/deleted.
> With
> > the new consumer, the rebalance can probably settle within 200ms when
> there
> > is a topic change. So, as long as we are not changing topic more than 5
> > times per sec, there shouldn't be constant churns, right?
> >
> > Thanks,
> >
> > Jun
> >
> >
> >
> > On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <ja...@confluent.io>
> > wrote:
> >
> > > Hi Kafka Devs,
> > >
> > > One of the nagging issues in the current design of the new consumer has
> > > been the need to support a variety of assignment strategies. We've
> > > encountered this in particular in the design of copycat and the
> > processing
> > > framework (KIP-28). From what I understand, Samza also has a number of
> > use
> > > cases with custom assignment needs. The new consumer protocol supports
> > new
> > > assignment strategies by hooking them into the broker. For many
> > > environments, this is a major pain and in some cases, a non-starter. It
> > > also challenges the validation that the coordinator can provide. For
> > > example, some assignment strategies call for partitions to be assigned
> > > multiple times, which means that the coordinator can only check that
> > > partitions have been assigned at least once.
> > >
> > > To solve these issues, we'd like to propose moving assignment to the
> > > client. I've written a wiki which outlines some protocol changes to
> > achieve
> > > this:
> > >
> > >
> >
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> > > .
> > > To summarize briefly, instead of the coordinator assigning the
> partitions
> > > itself, all subscriptions are forwarded to each member of the group
> which
> > > then decides independently which partitions it should consume. The
> > protocol
> > > provides a mechanism for the coordinator to validate that all consumers
> > use
> > > the same assignment strategy, but it does not ensure that the resulting
> > > assignment is "correct." This provides a powerful capability for users
> to
> > > control the full data flow on the client side. They control how data is
> > > written to partitions through the Partitioner interface and they
> control
> > > how data is consumed through the assignment strategy, all without
> > touching
> > > the server.
> > >
> > > Of course nothing comes for free. In particular, this change removes
> the
> > > ability of the coordinator to validate that commits are made by
> consumers
> > > who were assigned the respective partition. This might not be too bad
> > since
> > > we retain the ability to validate the generation id, but it is a
> > potential
> > > concern. We have considered alternative protocols which add a second
> > > round-trip to the protocol in order to give the coordinator the ability
> > to
> > > confirm the assignment. As mentioned above, the coordinator is somewhat
> > > limited in what it can actually validate, but this would return its
> > ability
> > > to validate commits. The tradeoff is that it increases the protocol's
> > > complexity which means more ways for the protocol to fail and
> > consequently
> > > more edge cases in the code.
> > >
> > > It also misses an opportunity to generalize the group membership
> protocol
> > > for additional use cases. In fact, after you've gone to the trouble of
> > > moving assignment to the client, the main thing that is left in this
> > > protocol is basically a general group management capability. This is
> > > exactly what is needed for a few cases that are currently under
> > discussion
> > > (e.g. copycat or single-writer producer). We've taken this further step
> > in
> > > the proposal and attempted to envision what that general protocol might
> > > look like and how it could be used both by the consumer and for some of
> > > these other cases.
> > >
> > > Anyway, since time is running out on the new consumer, we have perhaps
> > one
> > > last chance to consider a significant change in the protocol like this,
> > so
> > > have a look at the wiki and share your thoughts. I've no doubt that
> some
> > > ideas seem clearer in my mind than they do on paper, so ask questions
> if
> > > there is any confusion.
> > >
> > > Thanks!
> > > Jason
> > >
> >
>

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Jason Gustafson <ja...@confluent.io>.
Hi Jun,

Answers below:

1. When there are multiple common protocols in the JoinGroupRequest, which
one would the coordinator pick?

I was intending to use the list to indicate preference. If all group
members support protocols ["A", "B"] in that order, then we will choose
"A." If some support ["B", "A"], then we would either choose based on
respective counts or just randomly. The main use case of supporting the
list is for rolling upgrades when a change is made to the assignment
strategy. In that case, the new assignment strategy would be listed first
in the upgraded client. I think it's debatable whether this feature would
get much use in practice, so we might consider dropping it.

2. If the protocols don't agree, the group construction fails. What exactly
does it mean? Do we send an error in every JoinGroupResponse and remove all
members in the group in the coordinator?

Yes, that is right. It would be handled similarly to inconsistent
assignment strategies in the current protocol. The coordinator returns an
error in each join group response, and the client propagates the error to
the user.

3. Consumer embedded protocol: The proposal has two different formats of
subscription depending on whether wildcards are used or not. This seems a
bit complicated. Would it be better to always use the metadata hash? The
clients know the subscribed topics already. This way, the client code
behaves the same whether wildcards are used or not.

Yeah, I think this is possible (Neha also suggested it). I haven't updated
the wiki yet, but the patch I started working on uses only the metadata
hash. In the case that an explicit topic list is provided, the hash just
covers the metadata for those topics.


Thanks,
Jason



On Tue, Aug 18, 2015 at 10:06 AM, Jun Rao <ju...@confluent.io> wrote:

> Jason,
>
> Thanks for the writeup. A few comments below.
>
> 1. When there are multiple common protocols in the JoinGroupRequest, which
> one would the coordinator pick?
> 2. If the protocols don't agree, the group construction fails. What exactly
> does it mean? Do we send an error in every JoinGroupResponse and remove all
> members in the group in the coordinator?
> 3. Consumer embedded protocol: The proposal has two different formats of
> subscription depending on whether wildcards are used or not. This seems a
> bit complicated. Would it be better to always use the metadata hash? The
> clients know the subscribed topics already. This way, the client code
> behaves the same whether wildcards are used or not.
>
> Jiangjie,
>
> With respect to rebalance churns due to topics being created/deleted. With
> the new consumer, the rebalance can probably settle within 200ms when there
> is a topic change. So, as long as we are not changing topic more than 5
> times per sec, there shouldn't be constant churns, right?
>
> Thanks,
>
> Jun
>
>
>
> On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <ja...@confluent.io>
> wrote:
>
> > Hi Kafka Devs,
> >
> > One of the nagging issues in the current design of the new consumer has
> > been the need to support a variety of assignment strategies. We've
> > encountered this in particular in the design of copycat and the
> processing
> > framework (KIP-28). From what I understand, Samza also has a number of
> use
> > cases with custom assignment needs. The new consumer protocol supports
> new
> > assignment strategies by hooking them into the broker. For many
> > environments, this is a major pain and in some cases, a non-starter. It
> > also challenges the validation that the coordinator can provide. For
> > example, some assignment strategies call for partitions to be assigned
> > multiple times, which means that the coordinator can only check that
> > partitions have been assigned at least once.
> >
> > To solve these issues, we'd like to propose moving assignment to the
> > client. I've written a wiki which outlines some protocol changes to
> achieve
> > this:
> >
> >
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> > .
> > To summarize briefly, instead of the coordinator assigning the partitions
> > itself, all subscriptions are forwarded to each member of the group which
> > then decides independently which partitions it should consume. The
> protocol
> > provides a mechanism for the coordinator to validate that all consumers
> use
> > the same assignment strategy, but it does not ensure that the resulting
> > assignment is "correct." This provides a powerful capability for users to
> > control the full data flow on the client side. They control how data is
> > written to partitions through the Partitioner interface and they control
> > how data is consumed through the assignment strategy, all without
> touching
> > the server.
> >
> > Of course nothing comes for free. In particular, this change removes the
> > ability of the coordinator to validate that commits are made by consumers
> > who were assigned the respective partition. This might not be too bad
> since
> > we retain the ability to validate the generation id, but it is a
> potential
> > concern. We have considered alternative protocols which add a second
> > round-trip to the protocol in order to give the coordinator the ability
> to
> > confirm the assignment. As mentioned above, the coordinator is somewhat
> > limited in what it can actually validate, but this would return its
> ability
> > to validate commits. The tradeoff is that it increases the protocol's
> > complexity which means more ways for the protocol to fail and
> consequently
> > more edge cases in the code.
> >
> > It also misses an opportunity to generalize the group membership protocol
> > for additional use cases. In fact, after you've gone to the trouble of
> > moving assignment to the client, the main thing that is left in this
> > protocol is basically a general group management capability. This is
> > exactly what is needed for a few cases that are currently under
> discussion
> > (e.g. copycat or single-writer producer). We've taken this further step
> in
> > the proposal and attempted to envision what that general protocol might
> > look like and how it could be used both by the consumer and for some of
> > these other cases.
> >
> > Anyway, since time is running out on the new consumer, we have perhaps
> one
> > last chance to consider a significant change in the protocol like this,
> so
> > have a look at the wiki and share your thoughts. I've no doubt that some
> > ideas seem clearer in my mind than they do on paper, so ask questions if
> > there is any confusion.
> >
> > Thanks!
> > Jason
> >
>

Re: [DISCUSS] Client-side Assignment for New Consumer

Posted by Jun Rao <ju...@confluent.io>.
Jason,

Thanks for the writeup. A few comments below.

1. When there are multiple common protocols in the JoinGroupRequest, which
one would the coordinator pick?
2. If the protocols don't agree, the group construction fails. What exactly
does it mean? Do we send an error in every JoinGroupResponse and remove all
members in the group in the coordinator?
3. Consumer embedded protocol: The proposal has two different formats of
subscription depending on whether wildcards are used or not. This seems a
bit complicated. Would it be better to always use the metadata hash? The
clients know the subscribed topics already. This way, the client code
behaves the same whether wildcards are used or not.

Jiangjie,

With respect to rebalance churns due to topics being created/deleted. With
the new consumer, the rebalance can probably settle within 200ms when there
is a topic change. So, as long as we are not changing topic more than 5
times per sec, there shouldn't be constant churns, right?

Thanks,

Jun



On Tue, Aug 11, 2015 at 1:19 PM, Jason Gustafson <ja...@confluent.io> wrote:

> Hi Kafka Devs,
>
> One of the nagging issues in the current design of the new consumer has
> been the need to support a variety of assignment strategies. We've
> encountered this in particular in the design of copycat and the processing
> framework (KIP-28). From what I understand, Samza also has a number of use
> cases with custom assignment needs. The new consumer protocol supports new
> assignment strategies by hooking them into the broker. For many
> environments, this is a major pain and in some cases, a non-starter. It
> also challenges the validation that the coordinator can provide. For
> example, some assignment strategies call for partitions to be assigned
> multiple times, which means that the coordinator can only check that
> partitions have been assigned at least once.
>
> To solve these issues, we'd like to propose moving assignment to the
> client. I've written a wiki which outlines some protocol changes to achieve
> this:
>
> https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal
> .
> To summarize briefly, instead of the coordinator assigning the partitions
> itself, all subscriptions are forwarded to each member of the group which
> then decides independently which partitions it should consume. The protocol
> provides a mechanism for the coordinator to validate that all consumers use
> the same assignment strategy, but it does not ensure that the resulting
> assignment is "correct." This provides a powerful capability for users to
> control the full data flow on the client side. They control how data is
> written to partitions through the Partitioner interface and they control
> how data is consumed through the assignment strategy, all without touching
> the server.
>
> Of course nothing comes for free. In particular, this change removes the
> ability of the coordinator to validate that commits are made by consumers
> who were assigned the respective partition. This might not be too bad since
> we retain the ability to validate the generation id, but it is a potential
> concern. We have considered alternative protocols which add a second
> round-trip to the protocol in order to give the coordinator the ability to
> confirm the assignment. As mentioned above, the coordinator is somewhat
> limited in what it can actually validate, but this would return its ability
> to validate commits. The tradeoff is that it increases the protocol's
> complexity which means more ways for the protocol to fail and consequently
> more edge cases in the code.
>
> It also misses an opportunity to generalize the group membership protocol
> for additional use cases. In fact, after you've gone to the trouble of
> moving assignment to the client, the main thing that is left in this
> protocol is basically a general group management capability. This is
> exactly what is needed for a few cases that are currently under discussion
> (e.g. copycat or single-writer producer). We've taken this further step in
> the proposal and attempted to envision what that general protocol might
> look like and how it could be used both by the consumer and for some of
> these other cases.
>
> Anyway, since time is running out on the new consumer, we have perhaps one
> last chance to consider a significant change in the protocol like this, so
> have a look at the wiki and share your thoughts. I've no doubt that some
> ideas seem clearer in my mind than they do on paper, so ask questions if
> there is any confusion.
>
> Thanks!
> Jason
>