You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

Status

Current state: "Under Discussion"

Discussion thread: here

Vote thread:  "Will update after discussion"

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():


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:

    • StreamsGroupMemberDescription includes rackId() method
    • The underlying protocol supports it for consumer groups
    • Only the public Admin API omits this 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:


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
}

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

ShareMemberDescription
public class ShareMemberDescription{     
    private final String memberId;
    private final Optional<String> rackId; // NEW FIELD 
    private final String clientId;
    //omit other codes
}

Proposed Changes

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

  •  add rackId into MemberDescription and ShareMemberDescription
  •  pass through rack ID from protocol response

Compatibility, Deprecation, and Migration Plan 

Backward Compatibility

This change is fully backward compatible:

  1. Binary Compatibility:

    • The old constructor remains available (marked as @Deprecated)
    • Existing code will continue to compile and run
    • The new field is an Optional, defaulting to empty()
  2. Source Compatibility:

    • Existing code using the old constructor continues to work
    • No changes required to existing applications
  3. Behavioral Compatibility:

    • Existing behavior is unchanged
    • Only adds new information when available

Migration Path

For users upgrading:

  • No action required
  • Rack information automatically available when using Admin API
  • Access via memberDescription.rackId() when needed

For developers using MemberDescription:

  • Old constructor still works
  • Recommended to migrate to new constructor over time
  • Old constructor may be removed in a future major version (e.g., Kafka 5.0)

Deprecation Plan

  • Mark old constructor as @Deprecated immediately
  • Keep it available for at least 2 major releases
  • Remove in Kafka 4.2.0 or later

Test Plan

We can use follow test to cover the change:

Unit Tests

  • Test equality with and without rack ID
  • Test rack ID is correctly extracted from DescribeResponse

Integration/System Tests

  • Behavior with mixed rack configurations
  • Behavior with classic and new protocol groups

If there are alternative ways of accomplishing the same thing, what were they? The purpose of this section is to motivate why the design is the way it is and not some other way.

  • Another discussed approach is not to call RLMM#configure() method while instantiating the RemoteLogManager#L422 and define a new method in RemoteLogManager#configureRLMM and this can be called from the BrokerServer. You can refer to the code.
    But the change breaks that contract:
    Accroding to KIP-877: "If a plugin implements this interface, the withPluginMetrics() method will be called when the plugin is instantiated (after configure() if the plugin also implements Configurable). "


  • No labels