-
Notifications
You must be signed in to change notification settings - Fork 173
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
implement distributied lock with redis cluster #284
Conversation
Hi @whalesongAndLittleFish, welcome to mosn community, Please sign Contributor License Agreement! After you signed CLA, we will automatically sync the status of this pull request in 3 minutes. |
Thanks for your contribution! |
@seeflood 你好,我在实现的时候是并发进行的加锁和解锁的过程,请问一下需要改用采用串行加锁的方式吗。如果这两种方式都可以的话,需要改成根据配置来决定串行还是并发吗 |
@whalesongAndLittleFish 串行加锁有什么优势吗 |
官方文档提到的做法是依次对单个节点去进行加锁的操作,但为什么要依次进行没有看到解释,然后当时做的时候我觉得串行的做法会对效率有影响,所以用并发的方式做的。但是今天同事提到并发的方式可能会导致请求量较多的时候在短时间创建过多的协程,所以想问下需不需要根据不同的场景,通过参数来决定选用哪种方式。(不知道考虑的对不对,麻烦大佬们多多指教(⊙﹏⊙)) |
@whalesongAndLittleFish 如果怕短时间创建大量协程,可以通过协程池的方式优化,比如 |
okkkk,我再验证下~ |
不要使用这个tcpcopy 当作性能优化的点,这个tcpcopy目前的性能就不太行。可以找一下其他go 实现的协程池逻辑,比如https://github.com/mosn/mosn/blob/master/pkg/sync/workerpool.go |
恩恩我拿 https://github.com/gammazero/workerpool |
okk~ 我去瞅瞅 |
你好,我在新的提交里尝试使用了@nejisama 推荐的https://github.com/mosn/mosn/blob/master/pkg/sync/workerpool.go |
003c2c7
to
d800e9b
Compare
Codecov Report
@@ Coverage Diff @@
## main #284 +/- ##
=======================================
Coverage 56.65% 56.65%
=======================================
Files 48 48
Lines 2058 2058
=======================================
Hits 1166 1166
Misses 769 769
Partials 123 123 Continue to review full report at Codecov.
|
@whalesongAndLittleFish 我有个疑问,既然4个、5个节点都需要3个节点加锁成功才算整体加锁成功,为什么不维护更少的4个节点? |
5个节点的话就能够容忍两个节点宕机呀,如果4个就只能容忍一个节点宕机了 |
@whalesongAndLittleFish 一定要限制5个及以上吗 ?3个? 甚至1个可以把单节点的情况都覆盖了 |
实在要用三个其实也可以,但是和四个节点的情况一样只能容忍一个节点异常,最好还是五个嘛。我想的话,如果1个的话感觉可以直接使用已经实现的单点锁,就不用这个集群方案了 |
我在实现的时候没有硬性判定需要五个节点以上,节点数原则上不限制,判定成功的的规则都是过半就成功,如果真要这样使用也可以的 |
所以我在想是不是两个方案可以统一起来了 ? 我看代码里有判断五个节点啊。 |
嗷嗷感谢提醒,我修改一下,两个方案统一的话感觉需要和他们讨论一下,我先解决下问题 |
已修改 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
感谢大佬的review~,辛苦了(ง •̀o•́)ง |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
b55d2fd
to
b0c8ab0
Compare
remove unused replicas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What this PR does:
add redis cluster lock(red lock implement)
Which issue(s) this PR fixes:
Fixes #249