Skip to content

Suggestions for optimizing metric data query/writing in Sentinel dashboard #1174

@yangyiweigege

Description

@yangyiweigege

目前 sentinel dashaboard应用数据写入内存/查询 使用的是简单粗暴的synchronize,所有的读/写请求 都是串行处理,当接入的应用较多,写入内存的数据量较大,存在性能问题。建议优化这部分代码,这里给出我的思路以及实现。
1.监控数据按照应用维度 进行锁分离;
2.同一应用 进行读写锁分离;
代码大致如下:
// app -> lock
private Map<String, ReadWriteLock> appLockMap = new ConcurrentHashMap(); //app 读写锁

readWriteLock.writeLock().lock();
监控数据写内存操作;
readWriteLock.writeLock().unlock(); //释放写锁

appLockMap.get(app).readLock().lock();
排序/查询数据操作
appLockMap.get(app).readLock().unlock();

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/dashboardIssues or PRs about Sentinel Dashboard

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions