Replies: 3 comments 8 replies
-
@tiptop96 Ra does not dictate whether your state machine state is stored in memory or not. In RabbitMQ, there are examples of machine that keep a subset in memory (quorum queues), keep virtually everything on disk (streams) and both on disk and in memory (Khepri). The examples keep everything in memory because they are, well, basic examples that demonstrate Ra machine concepts such as state transition applications and effects. Ra will keep a certain amount of Raft state in memory but that does not include your machine's data. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the swift response! That is great. So there is no harm in writing to external storage i Does that mean the statement from this talk about no side effects inside |
Beta Was this translation helpful? Give feedback.
-
Practically the answer is yes, Ra (and Raft) was designed to keep the state machine state in memory. That said writing mutable/on-disk state machines is possible but it is very, very hard to do right and easy to overlook some subtle interaction that may threaten the safety properties of Raft. In addition to this you have quite high write amplification as you'd write to the Ra log then to your on disk state for all entries. Less than ideal for sure. khepri, quorum queues and any other Ra use in RabbitMQ is all in memory. Quorum queues are a special case as they delay the truncation of the log such that messages can be re-read the from the log when needed rather than kept in memory but the state machine itself is kept in memory. So yes the "rule" of no side effects inside |
Beta Was this translation helpful? Give feedback.
-
This assumption might be wrong, but from what I gather
ra
keeps the whole state in memory. If this is not true please correct me. I am interested in usingra
to update some external storage on each node in order to not have the size of my state be constrained by available RAM.The first thing that comes to mind is to have the state machine always return an empty state and just write to some external store whenever we receive a write or do a restore. However this would be a side effect, which I understand is not advisable.
Is there a way to not keep the complete state in memory?
Maybe this
ra
wasn't designed for this use case, perhaps it isn't even a valid use case. 😅Beta Was this translation helpful? Give feedback.
All reactions