sofastack / sofa-jraft

A production-grade java implementation of RAFT consensus algorithm.
https://www.sofastack.tech/projects/sofa-jraft/
Apache License 2.0
3.56k stars 1.14k forks source link

Jraft is used as a library to maintain the memory state of the cluster (only one cluster), there is no best practice #263

Closed hanzhihua closed 4 years ago

hanzhihua commented 4 years ago

Your question

jraft做为library使用,维护集群的状态内存状态(只有一个集群),有没有最佳实践

Your scenes

我现在在做一个DAG系统,使用jraft来保证控制节点的高可用, 我现在玩法是,使用node.apply(task)做为写操作,而读操作则是直接读取状态机(可以简单的认为是map) 有没有最佳实践,jraft作为library的? 如果是读操作,我怎么做到线性读呢? 如果写操作出现了网络异常,你们有什么建议呢? 另外咨询一下,snapshot各个节点是一致的吗?

Your advice

另外jraft做为最底层的项目,是不是可以单纯一点,不要依赖这么多三方库

Environment

jdk1.8

sofastack-bot[bot] commented 4 years ago

Hi @hanzhihua, we detect non-English characters in the issue. This comment is an auto translation by @sofastack-robot to help other users to understand this issue.

We encourage you to describe your issue in English which is more friendly to other users.

Your question jraft is used as a library, maintaining the state memory state of the cluster (only one cluster), there is no best practice ### Your scenes I am now working on a DAG system, using jraft to ensure high availability of the control node My current gameplay is to use node.apply(task) as a write operation, while the read operation is to read the state machine directly (can be thought of simply as a map) Is there a best practice, jraft as a library? If it is a read operation, how do I do linear reading? If there is a network exception in the write operation, what advice do you have? Also consult, is the snapshot node consistent? ### Your advice In addition, jraft is the bottom-level project. Is it simple? Don't rely on so many three-party libraries### Environment jdk1.8

fengjiachun commented 4 years ago

有没有最佳实践,jraft作为library的? 如果是读操作,我怎么做到线性读呢? 如果写操作出现了网络异常,你们有什么建议呢?

Hi,你好,这几个问题,jraft-rheakv 均有很好的实践,建议可以参考一下,甚至直接使用 jraft-rheakv

另外咨询一下,snapshot各个节点是一致的吗?

snapshot 各个节点独立完成,通常由各自的定时器触发,但这不影响数据一致性

另外jraft做为最底层的项目,是不是可以单纯一点,不要依赖这么多三方库

jraft 考虑到尽量少依赖第三方库,但个人认为第三方库也不是洪水猛兽,有些时候实在没有重复造轮子的必要,比如 common-io 库,不过如果觉得哪些库不应该依赖,可以提出来讨论一下

fengjiachun commented 4 years ago

没更多问题就先关闭了