He-Pin opened a new issue, #3230:
URL: https://github.com/apache/pekko/issues/3230

   ### Motivation
   
   Cluster Sharding 在 shard 移交(handover)期间,目标节点上的消息处理可能出现高延迟。虽然 
`handOffTimeout` 配置正确,但实体 `PostStop` 和钝化行为可能导致移交时间超出预期。
   
   ### 当前代码行为
   
   `Shard.scala` 中:
   
   ```scala
   // Shard.scala:886
   entityHandOffTimeout = (settings.tuningParameters.handOffTimeout - 
5.seconds).max(1.seconds)
   ```
   
   `HandOffStopper`(893-906 行)负责终止实体。移交延迟受以下因素影响:
   - 实体 `PostStop` 处理时间(用户清理逻辑)
   - 钝化策略的执行时间
   - `handOffTimeout` 配置是否合理
   
   如果实体持有大量状态或执行耗时的清理,移交可能超时。
   
   ### 预期行为
   
   移交过程应有更细粒度的超时控制,或在文档中明确说明 `handOffTimeout` 应包含实体清理时间。
   
   ### 代码证据
   
   - 
`cluster-sharding/src/main/scala/org/apache/pekko/cluster/sharding/Shard.scala:886`
 — `entityHandOffTimeout` 计算
   - 
`cluster-sharding/src/main/scala/org/apache/pekko/cluster/sharding/Shard.scala:893-906`
 — `HandOffStopper` 实现
   - 
`cluster-sharding/src/main/scala/org/apache/pekko/cluster/sharding/ClusterShardingSettings.scala:80`
 — `handoff-timeout` 配置
   
   ### 复现方式
   
   1. 创建持有大量状态的 sharded entity
   2. 触发 rebalance(如新增节点)
   3. 观察移交期间的消息处理延迟
   
   ### 影响范围
   
   - 模块:`pekko-cluster-sharding`
   - 影响频繁 rebalance 的集群(如滚动更新、自动扩缩容)
   - 移交延迟直接影响请求响应时间
   
   ### 备注
   
   此问题需要运行时基准测试确认实际延迟数据。


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to