Status

Current stateAccepted

Discussion thread: here

Vote threadhere

JIRA: KAFKA-19784

PR: https://github.com/apache/kafka/pull/20691

Motivation

Apache Kafka supports rack-aware partition assignment to improve fault tolerance and reduce cross-rack network traffic/cost. However, the current Admin API does not expose rack information for all type of consumer group members, despite this information being available at the protocol level.

Current State


The ConsumerGroupDescribeResponse (API Key 69) protocol includes a rackId field for each group member, as defined in the protocol specification:

{ "name": "RackId", "type": "string", "versions": "0+", 
  "nullableVersions": "0+", "default": "null",
  "about": "The member rack ID." }


However, when users call AdminClient.describeConsumerGroups(), the returned MemberDescription objects do not include this rack information. The rack ID is available in the wire protocol but is discarded during response processing in DescribeConsumerGroupsHandler.

The Similar case is for AdminClient.describeShareGroups().
The current status can be summarized as follows:


Class

Type of Group

contain RackId? 

protocoal response contain rackId?

MemberDescription

Consumer Group

✅ 

ShareMemberDescription

Share Group

❌ 

✅ 

StreamsGroupMemberDescription

Streams Group

✅ 

✅ 

Problem Statement


This limitation creates several issues:

  1. Monitoring and Observability: Operators cannot determine the rack distribution of consumer group members through the Admin API, making it difficult to verify that rack-aware assignment is working correctly.
  2. Inconsistency: Other group types expose rack information:

  3. Diagnostics: When troubleshooting rack-aware assignment issues or network problems, operators need to use lower-level tools or custom code to access rack information that should be readily available.
  4. Third-party Tools: Monitoring and management tools built on the Admin API cannot display rack information, limiting their usefulness for rack-aware deployments.

Take one example:  currently we have to implemen our AZ/Rack analysis using a workaround — passing the rack information into the clientId field and parsing it afterward.

kafkaConsumerConfig.customConfig(ConsumerConfig.CLIENT_ID_CONFIG, generateClientIdWithRack(ip, rack));


Public Interfaces

We need to do tiny change for the existed public class:
1. Add rack ID support to
org.apache.kafka.clients.admin.MemberDescription:

public class MemberDescription {
    private final String memberId;
    private final Optional<String> groupInstanceId;
    private final Optional<String> rackId;  // new field
    private final String clientId;
    //omit other codes        
    public Optional<String> rackId() {  // new method
       return rackId;
    }
    //omit other codes}

2.  Add rack ID support to org.apache.kafka.clients.admin.ShareMemberDescription:

public class ShareMemberDescription{     
    private final String memberId;
    private final Optional<String> rackId; // new field
    private final String clientId;
    //omit other codes        
    public Optional<String> rackId() {  // new method
       return rackId;
    }
    //omit other codes
}

Proposed Changes

 You can refer to https://github.com/apache/kafka/pull/20691:

Compatibility, Deprecation, and Migration Plan 

Backward Compatibility

This change is fully backward compatible:

  1. Binary Compatibility:

  2. Source Compatibility:

  3. Behavioral Compatibility:

Migration Path

For users upgrading:

For developers using MemberDescription:

Deprecation Plan

Test Plan

We can use follow test to cover the change:

Unit Tests

Integration/System Tests

Rejected Alternatives

Alternative 1: Create a New API
Proposal: Create describeConsumerGroupsWithRack() method
Rejection Reason: