Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于RefreshPolicy底层工作原理 #935

Open
xunyao4dev opened this issue Oct 18, 2024 · 6 comments
Open

关于RefreshPolicy底层工作原理 #935

xunyao4dev opened this issue Oct 18, 2024 · 6 comments

Comments

@xunyao4dev
Copy link

我看到RefreshPolicy的实现其实是把每个key包装成一个Task,然后丢给 JetCacheExecutor.heavyIOExecutor() 来定时执行,但是heavyIOExecutor其实是一个coreSize=10的无界队列的线程池,max = Integer.MAX_VALUE,如果缓存的key非常多,那是不是就会导致oom?另外想问一下

heavyIOExecutor = new ScheduledThreadPoolExecutor(
                        10, tf, new ThreadPoolExecutor.DiscardPolicy());

这里的DiscardPolicy应该是无意义的吧,因为无界队列只会oom,而不会出发DiscardPolicy

@xunyao4dev
Copy link
Author

xunyao4dev commented Oct 18, 2024

@areyouok 大佬,帮忙回答下这个问题,基于上述问题,我觉得每个key加一个随机时间来做缓存雪崩其实是有意义的,否则对系统的负担压力会比较大,设置随机时间后万事OK了吧

@areyouok
Copy link
Collaborator

有停止刷新的策略

@xunyao4dev
Copy link
Author

xunyao4dev commented Oct 20, 2024 via email

@areyouok
Copy link
Collaborator

停止刷新,这个任务就没有了,为什么会oom

@xunyao4dev
Copy link
Author

xunyao4dev commented Oct 20, 2024 via email

@areyouok
Copy link
Collaborator

在错误的使用方式下,会有无数种路径造成oom。

如果cache命中次数远远小于刷新的次数,那设置刷新干什么呢?徒增数据库的压力。

如果cache访问次数很多,为什么不把stopRefreshAfterLastAccessMillis这个值设置小一点呢?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants