# Badger FIFO Mode

**URL:** <https://discuss.dgraph.io/t/badger-fifo-mode/15520>\
**Category:** Badger\
**Tags:** badger\
**Created:** [September 8, 2021, 7:42pm UTC](https://discuss.dgraph.io/t/badger-fifo-mode/15520 "2021-09-08T19:42:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![joriwils](https://avatars.discourse-cdn.com/v4/letter/j/e9bcb4/32.png) [@joriwils](https://discuss.dgraph.io/u/joriwils)\
**Post date:** [September 8, 2021, 7:42pm UTC](https://discuss.dgraph.io/t/badger-fifo-mode/15520/1 "2021-09-08T19:42:02Z")

</div>

Is there a FIFO mode in Badger? That is the ability to  
a) do not do compactions  
b) client can directly read the oldest SST  
c) delete it when done?

---

<div class="post-metadata">

**Author:** ![Naman](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/naman/32/3498_2.png) [@Naman](https://discuss.dgraph.io/u/Naman)\
**Post date:** [October 22, 2021, 4:54pm UTC](https://discuss.dgraph.io/t/badger-fifo-mode/15520/2 "2021-10-22T16:54:58Z")

</div>

Hi @joriwils , I am interested to know more about this use case. Can you please link any external references.

---

<div class="post-metadata">

**Author:** ![joriwils](https://avatars.discourse-cdn.com/v4/letter/j/e9bcb4/32.png) [@joriwils](https://discuss.dgraph.io/u/joriwils)\
**Post date:** [October 22, 2021, 6:41pm UTC](https://discuss.dgraph.io/t/badger-fifo-mode/15520/3 "2021-10-22T18:41:31Z")

</div>

Hi Naman,

RocksDb describes it here: [https://github.com/facebook/rocksdb/wiki/FIFO-compaction-style](https://github.com/facebook/rocksdb/wiki/FIFO-compaction-style)

The use case is a searchable log. That is the client adds Key to the LSM when it the corresponding Value enters the cache. Each key might get a Log Sequence Number (LSN). Then after some time the KV pair is discarded. In that way “log wrap” is emulated.

The FIFO mode has two benefits: there is no compaction cost and no deletion cost. KV pairs are deleted by deleting the oldest SST. For example the master application manages the log content by LSN. Once it knows that all KV pairs with an LSN less than the lowest LSN in an SST have been discarded/passed on, it can delete the SST. Obviously, the FIFO mode has high search costs if the number of SSTs is high. However, if the number of SSTs can be kept low or low search cost is not a major goal, then FIFO compaction works.

I suspect Facebook uses it in their LogDevice: [LogDevice: a distributed data store for logs - Facebook Engineering](https://engineering.fb.com/2017/08/31/core-data/logdevice-a-distributed-data-store-for-logs/)
