#community-help

Explanation of Typesense's server parameters `--healthy-read-lag` and `--healthy-write-lag`.

TLDR Eric asked about the significance of specific server configuration parameters in Typesense. Jason provided a detailed explanation of how these parameters work during data writes and reads.

Powered by Struct AI

1

Dec 28, 2021 (25 months ago)
Eric
Photo of md5-f930fdb99fd46477205fa1201164ea50
Eric
11:41 PM
Hi, Typesensers! I'm looking for clarity on what the server configuration parameters --healthy-read-lag  and --healthy-write-lag 
mean. What would the implications be if they were both set to 0? I have a rudimentary understanding of the Raft consensus algorithm, but I don't know exactly how Typesense implements it.
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
11:42 PM
Ha! I think this is the first usage of the word "Typesenser" 🙌
11:48
Jason
11:48 PM
To answer your question, when writes are sent to Typesense they are replicated to other nodes via Raft operations... So the writes are first written to an append-only log and then get applied to the in-memory index. If a large volume of writes show up, there might be a lag between writes being written to the log and when they actually get applied to memory. This lag is what is defined by those two parameters.

So if the lag is over --healthy-write-lag, then additional writes are rejected with an HTTP 503 while writes already in the log are applied, and lag eventually reduces below this threshold. If the lag is over --healthy-read-lag, then all reads (eg: searches) also start returning a 503. The former is useful if you don't want to overwhelm the cluster with writes and you want a backoff indicator for the system that is writing into Typesense. The latter is useful in cases where you'd rather not serve any stale data for searches and want to wait for the data that has been sent to Typesense to be available for search
Dec 29, 2021 (25 months ago)
Eric
Photo of md5-f930fdb99fd46477205fa1201164ea50
Eric
02:25 AM
I'm proud to coin the term! Thanks for the answer, Jason.

1