alibaba/Sentinel

提供maxContextNameSize设置选项,对于超出限量的资源优先清理空闲

Open

#2,108 opened on Apr 1, 2021

View on GitHub
 (0 comments) (0 reactions) (0 assignees)Java (8,150 forks)batch import
good first issuekind/enhancement

Repository metrics

Stars
 (23,109 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

EntranceNode和DefaultNode构建的invocation tree 会一直存在内存中,因此如果资源大于默认2000,将无法再进行限流。

这一块虽然没有那么重要,但是可以采用这种优化

  • 当数额未超过MAX_CONTEXT_NAME_SIZE,正常处理
  • 当数额超过MAX_CONTEXT_NAME_SIZE,清理 intervalInMs 内无记录的node让出空间。

另外MAX_CONTEXT_NAME_SIZE也可以考虑提供出来供使用者调节。

这样处理在正常情况下应该对性能不会有什么影响,因为一般没有那么多资源限流。而如果真正遇到了需要限流的资源太多,也能够进行处理,而不是直接报错。不过那种场景可能会导致频繁new EntranceNode。而这也可以通过调节MAX_CONTEXT_NAME_SIZE来达到平衡。

Originally posted by @zidoshare in https://github.com/alibaba/Sentinel/discussions/2097#discussioncomment-551580

Contributor guide