alibaba / alibaba/Sentinel

The client heap memory usage is too large (客户端内存占用过大)

Open
#2,767 11 comments 2 reactions 0 assignees View on GitHub
area/performance
Dominant language
Java
Stars
23.1k
Forks
8.1k
PR merge metrics
No merged PRs in 30d

Description

## Issue Description

Type: *feature request*

### Describe what happened (or what feature you want)
客户端集成到服务以后,通过对比接入前与接入后的监控信息发现,接入sentinel后内存占用明显升高。
平均内存占用增加350MB,峰值内存占用增加900多兆,并且主要集中在老年代。
通过分析jvm dump文件,占用内存较大的几个对象是:com.alibaba.csp.sentinel.node.metric.MetricNode、java.util.concurrent.atomic.LongAdder、com.alibaba.csp.sentinel.slots.statistic.base.WindowWrap等。
271FA9E8-7211-44DC-A927-E4B217294276

### Describe what you expected to happen
作为一个微服务,这些内存占用有些难以让人接受,希望能尽量减少内存的占用。

### How to reproduce it (as minimally and precisely as possible)
1. MetricNode对象的生成主要来自控制台拉取日志时,客户端读取metric日志,转换成了MetricNode对象。从阅读源码可知,读取日志时,将String转换为MetricNode,再将MetricNode转换成String。是否多此一举,直接将日志发给控制台即可?这样可以减少很多对象的创建以及内存占用。
2. 其它几个高占用对象,粗略看了下源码发现,几乎来自于StatisticSlot中,用来统计resource信息的。不知后续这块是否会有优化计划。如果短期没有,希望给与我一些提示,从哪些角度去优化。从业务角度出发,我能想到的是,通过设置resource白名单,减少对一些不重要的接口做统计,尽量减少内存占用。

### Tell us your environment
sentinel 1.8.2
openjdk 1.8
springboot 2.x

### Anything else we need to know?
控制台每隔十秒从客户端拉取meteic信息。

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the Sentinel 1.8.2 client workload and reviewing the JVM dump, focusing on MetricNode, LongAdder, WindowWrap, and StatisticSlot. Compare the metric-log path and resource-statistics behavior, then define completion as a measurable reduction in average and peak heap usage without losing the metrics expected by the console.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.