Skip to content

Conversation

@Wadimz
Copy link
Contributor

@Wadimz Wadimz commented Nov 16, 2025

This fix addresses a bug where max.connections.per.ip.overrides does not correctly apply the override value to all IP addresses resolved from a multi-IP hostname.

Background

max.connections.per.ip can be overridden per host using the max.connections.per.ip.overrides configuration.
The override can be specified using either an IP address or a hostname.

When a hostname resolves to multiple IP addresses (e.g., when pointing to a load balancer or an auto-scaling group), the broker currently applies the override only to the first resolved IP address.
This occurs because the existing implementation relies on InetAddress.getByName(host), which internally returns only the first value from InetAddress.getAllByName(host).

As a result, additional backend IPs continue to use the default max.connections.per.ip value, leading to inconsistent connection limits for the same logical host.

@github-actions github-actions bot added triage PRs from the community core Kafka Broker small Small PRs labels Nov 16, 2025
class ConnectionQuotas(config: KafkaConfig, time: Time, metrics: Metrics) extends Logging with AutoCloseable {

@volatile private var defaultMaxConnectionsPerIp: Int = config.maxConnectionsPerIp
@volatile private var maxConnectionsPerIpOverrides = config.maxConnectionsPerIpOverrides.map { case (host, count) => (InetAddress.getByName(host), count) }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

internal implementation:

public static InetAddress getByName(String host) throws UnknownHostException {
        return InetAddress.getAllByName(host)[0];
}

@github-actions github-actions bot removed the triage PRs from the community label Nov 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Kafka Broker small Small PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant