503
kafka
network_error
ai_generated
partial
HTTP 503 Service Unavailable:由于重平衡,Connect REST API暂时不可用
HTTP 503 Service Unavailable: Connect REST API is temporarily unavailable due to rebalance
ID: kafka/connect-rest-api-503-service-unavailable
79%修复率
86%置信度
1证据数
2024-04-12首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Kafka 3.4.0 | active | — | — | — |
| Kafka 3.5.1 | active | — | — | — |
| Kafka 3.7.0 | active | — | — | — |
根因分析
当集群正在进行重平衡时,Kafka Connect的REST API返回503,因为工作节点领导权可能正在重新分配,端点被暂时禁用。
English
Kafka Connect's REST API returns 503 when the cluster is undergoing a rebalance, as worker leadership may be reassigned and endpoints are temporarily disabled.
官方文档
https://kafka.apache.org/documentation/#connect_rest解决方案
-
Implement retry logic with exponential backoff in your client. Example in Python: import time; for i in range(5): try: response = requests.get('http://connect-host:8083/connectors'); break; except requests.exceptions.HTTPError as e: if e.response.status_code == 503: time.sleep(2**i); else: raise -
Monitor the rebalance status using Kafka's metrics or logs, and only query the REST API after the rebalance completes. Check for 'REBALANCE_COMPLETED' log entries.
无效尝试
常见但无效的做法:
-
Setting 'rest.advertised.host.name' to a different value
90% 失败
Increasing worker timeout does not prevent the 503 during rebalance; the API is intentionally disabled.
-
Restarting a single Connect worker
85% 失败
Restarting one worker may trigger another rebalance, making the 503 persist longer.