# Badger cache: are we ready?

**URL:** <https://forum.storj.io/t/badger-cache-are-we-ready/27323>\
**Category:** Node Operators\
**Tags:** badger\
**Created:** [July 28, 2024, 9:41am UTC](https://forum.storj.io/t/badger-cache-are-we-ready/27323 "2024-07-28T09:41:48Z")\
**Posts on this page:** 19\
**Page:** 9

<div class="post-metadata">

**Author:** ![Alexey](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/alexey/32/41_2.png) [@Alexey](https://forum.storj.io/u/Alexey)\
**Post date:** [January 18, 2025, 6:21am UTC](https://forum.storj.io/t/badger-cache-are-we-ready/27323/162 "2025-01-18T06:21:00Z")

</div>

I tested on storj-up, it’s working.  
Could you please check, that the dashboard port is not occupied?

---

<div class="post-metadata">

**Author:** ![ItsHass](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/itshass/32/1122_2.png) [@ItsHass](https://forum.storj.io/u/ItsHass)\
**Post date:** [January 20, 2025, 9:57am UTC](https://forum.storj.io/t/badger-cache-are-we-ready/27323/163 "2025-01-20T09:57:55Z")

</div>

Where can i find information on / when / why / how should I enable this ?

Is there paritcular cirucmstance it should be enabled vs not enabled?

---

<div class="post-metadata">

**Author:** ![snorkel](https://storj.bcdn.literatehosting.com/letter_avatar/snorkel/32/6_22734026db12803ebb3e059622ac3534.png) [@snorkel](https://forum.storj.io/u/snorkel)\
**Post date:** [January 20, 2025, 12:42pm UTC](https://forum.storj.io/t/badger-cache-are-we-ready/27323/164 "2025-01-20T12:42:42Z")

</div>

If you have low RAM and the file walkers struggle aka they take to much time to finish, like hours…  
It also helps to win more races… in theory.

[https://forum.storj.io/t/badger-cache-filewalker-test-results/27334?u=snorkel](https://forum.storj.io/t/badger-cache-filewalker-test-results/27334)  
There is also the official post, but I can’t find it.  
To enable it:

```auto
	--pieces.enable-lazy-filewalker=false \
	--storage2.piece-scan-on-startup=true \
	--pieces.file-stat-cache=badger

```

There is also a post about moving the badger cache dir to SSD, if you want.  
I run all the storagenode files on the same HDD as the storage on 8GB RAM with 2 nodes, and I don’t have any problems (data, databases, badger cache).  
But you need UPS, because a sudden power loss can corrupt the badger cache and you must manualy delete the directory, restart the node and run the startup filewalker as there was no cache (time wise), to rebuild the cache.

---

<div class="post-metadata">

**Author:** ![ItsHass](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/itshass/32/1122_2.png) [@ItsHass](https://forum.storj.io/u/ItsHass)\
**Post date:** [January 23, 2025, 1:41pm UTC](https://forum.storj.io/t/badger-cache-are-we-ready/27323/165 "2025-01-23T13:41:36Z")

</div>

is it possible like DB’s , to have these new pieces coming from the SSD drive ?

---

<div class="post-metadata">

**Author:** ![snorkel](https://storj.bcdn.literatehosting.com/letter_avatar/snorkel/32/6_22734026db12803ebb3e059622ac3534.png) [@snorkel](https://forum.storj.io/u/snorkel)\
**Post date:** [January 23, 2025, 3:33pm UTC](https://forum.storj.io/t/badger-cache-are-we-ready/27323/166 "2025-01-23T15:33:01Z")

</div>

You can direct the badger directory like db-es wherever you want. I will look for a command semple if you wait a little.

```auto
--mount type=bind,source="/volume1/Storj/Identity/storagenode/",destination=/app/identity \
--mount type=bind,source="/volume1/Storj/",destination=/app/config \
--mount type=bind,source="/volumeUSB1/usbshare/storjdbs1/filestatcache/",destination=/app/config/storage/filestatcache \
--mount type=bind,source="/volumeUSB1/usbshare/storjdbs1/",destination=/app/dbs \
--name storagenode storjlabs/storagenode:latest \
--storage2.database-dir=dbs \

```

---

<div class="post-metadata">

**Author:** ![EasyRhino](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/easyrhino/32/1133_2.png) [@EasyRhino](https://forum.storj.io/u/EasyRhino)\
**Post date:** [January 23, 2025, 4:42pm UTC](https://forum.storj.io/t/badger-cache-are-we-ready/27323/167 "2025-01-23T16:42:22Z")

</div>

> [@ItsHass](#):
>
> is it possible like DB’s , to have these new pieces coming from the SSD drive ?

if you’re using docker compose it’s something like this (the source is the SSD you want it to be)

```auto
    volumes:
      - type: bind
        source: /home/ubuntu/storj4b/badger
        target: /app/config/storage/filestatcache

```

---

<div class="post-metadata">

**Author:** ![ItsHass](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/itshass/32/1122_2.png) [@ItsHass](https://forum.storj.io/u/ItsHass)\
**Post date:** [January 23, 2025, 5:06pm UTC](https://forum.storj.io/t/badger-cache-are-we-ready/27323/168 "2025-01-23T17:06:59Z")

</div>

do you happen to know if hashtables are anything to do with badger?

---

<div class="post-metadata">

**Author:** ![EasyRhino](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/easyrhino/32/1133_2.png) [@EasyRhino](https://forum.storj.io/u/EasyRhino)\
**Post date:** [January 23, 2025, 7:01pm UTC](https://forum.storj.io/t/badger-cache-are-we-ready/27323/169 "2025-01-23T19:01:17Z")

</div>

they are different things. The hashtable is mandatory, the badger is optional.

The hashtable, which I don’t fully understand, isn’t fully implemented yet. Eventually the badger cache might be made obsolete though?

---

<div class="post-metadata">

**Author:** ![nitrobass24](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/nitrobass24/32/1129_2.png) [@nitrobass24](https://forum.storj.io/u/nitrobass24)\
**Post date:** [January 23, 2025, 10:45pm UTC](https://forum.storj.io/t/badger-cache-are-we-ready/27323/170 "2025-01-23T22:45:06Z")

</div>

Hashtables are not mandatory. It is still opt-in.

---

<div class="post-metadata">

**Author:** ![nerdatwork](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/nerdatwork/32/1135_2.png) [@nerdatwork](https://forum.storj.io/u/nerdatwork)\
**Post date:** [January 24, 2025, 12:36am UTC](https://forum.storj.io/t/badger-cache-are-we-ready/27323/171 "2025-01-24T00:36:55Z")

</div>

> [@nitrobass24](#):
>
> It is still opt-in

True but just so everyone is on the same page.

> <https://github.com/storj/roadmap/issues/119>
>
> The purpose of this roadmap item is to prepare the new piece store implementatio…n (Hashstore) to be rolled out to the public network for all storage nodes to utilize. 
> 
> Items to consider doing as a part of this: 
> \- technical things (Steve/ Brandon to find out from eng team)?
> \- improve migration time?
> \- add endpoints for the storage node to utilize with dashboards? 
> 
> Open Questions: 
> \- do we trigger the migration? (like with a new version or something?)

---

<div class="post-metadata">

**Author:** ![Alexey](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/alexey/32/41_2.png) [@Alexey](https://forum.storj.io/u/Alexey)\
**Post date:** [January 24, 2025, 6:54am UTC](https://forum.storj.io/t/badger-cache-are-we-ready/27323/172 "2025-01-24T06:54:38Z")

</div>

It’s still under considerations. It’s used for Storj Select primarily, because it’s fast and waste less space, also GC and trash collector works faster without influence the speed. It also uses less resources if you compare with the default piecestore+badger, but the resulting speed is much better and it can handle much more high load.

---

<div class="post-metadata">

**Author:** ![snorkel](https://storj.bcdn.literatehosting.com/letter_avatar/snorkel/32/6_22734026db12803ebb3e059622ac3534.png) [@snorkel](https://forum.storj.io/u/snorkel)\
**Post date:** [January 24, 2025, 8:39am UTC](https://forum.storj.io/t/badger-cache-are-we-ready/27323/173 "2025-01-24T08:39:58Z")

</div>

I believe it’s too early to make it mandatory. More testing in necessary. Just these days it gave errors on a NFS mount to someone.

---

<div class="post-metadata">

**Author:** ![nerdatwork](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/nerdatwork/32/1135_2.png) [@nerdatwork](https://forum.storj.io/u/nerdatwork)\
**Post date:** [January 24, 2025, 10:49am UTC](https://forum.storj.io/t/badger-cache-are-we-ready/27323/174 "2025-01-24T10:49:09Z")

</div>

> [@snorkel](#):
>
> gave errors on a NFS mount

> [@ISCSI vs NFS shares for nodes?](https://forum.storj.io/t/iscsi-vs-nfs-shares-for-nodes/21121/13):
>
> The network filesystem (NFS, SMB, SSHFS, etc.) have a different files lock mechanism than a local filesystems like NTFS or ext4, thus they behave differently for storagenode. The storagenode software uses files locks in many places, starting from SQLite databases and include storage (during upload for example). So you will always have problems either with databases or with storage (especially for uploads - they may stuck), this is if we even will not talk about higher RAM usage due to worse late…

---

<div class="post-metadata">

**Author:** ![surfercool](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/surfercool/32/1122_2.png) [@surfercool](https://forum.storj.io/u/surfercool)\
**Post date:** [January 24, 2025, 6:44pm UTC](https://forum.storj.io/t/badger-cache-are-we-ready/27323/175 "2025-01-24T18:44:33Z")

</div>

I’ve fully migrated to a hash table structure. The memory optimization is substantial. Before the switch, I was utilizing approximately 2TB of storage, with a wasteful 400GB overhead due to the use of 32KB clusters to accommodate my large hard drive. Additionally, the file count was astronomical at 16 million. Following a two-day migration process (2TB SSD Defer-Write Cache), the file count has been drastically reduced to fewer than 2500. Consequently, the file system is now noticeably!!! faster and much more efficient.

---

<div class="post-metadata">

**Author:** ![Alexey](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/alexey/32/41_2.png) [@Alexey](https://forum.storj.io/u/Alexey)\
**Post date:** [January 25, 2025, 6:46am UTC](https://forum.storj.io/t/badger-cache-are-we-ready/27323/176 "2025-01-25T06:46:04Z")

</div>

Even if it’s not supported, I believe that it’s possible to configure it for locks too. I was able to do so for SMB, which is not supported too.

> [@Hashstore: bad file descriptor](https://forum.storj.io/t/hashstore-bad-file-descriptor/29062/20):
>
> For SMB I was forced to use [`nobrl`](https://linux.die.net/man/8/mount.cifs) option to make SQLite happy, this seems also allowed me to avoid the `flock` issue.

---

<div class="post-metadata">

**Author:** ![EasyRhino](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/easyrhino/32/1133_2.png) [@EasyRhino](https://forum.storj.io/u/EasyRhino)\
**Post date:** [January 27, 2025, 4:38pm UTC](https://forum.storj.io/t/badger-cache-are-we-ready/27323/177 "2025-01-27T16:38:38Z")

</div>

where are the instructions for how to try the hash migration?

my disks are using ZFS compression so inefficiency from cluster size is not a problem… but reducing the file count by millions would probably be huge performance boon for housekeeping operations.

I even have a tiny 500GB node I could sacrifice to the test…

---

<div class="post-metadata">

**Author:** ![snorkel](https://storj.bcdn.literatehosting.com/letter_avatar/snorkel/32/6_22734026db12803ebb3e059622ac3534.png) [@snorkel](https://forum.storj.io/u/snorkel)\
**Post date:** [January 27, 2025, 6:55pm UTC](https://forum.storj.io/t/badger-cache-are-we-ready/27323/178 "2025-01-27T18:55:09Z")

</div>

In the hashstore thread…  
[https://forum.storj.io/t/tech-preview-hashstore-backend-for-storage-nodes/28724?u=snorkel](https://forum.storj.io/t/tech-preview-hashstore-backend-for-storage-nodes/28724)

Take note that it’s a one way ticket. You can’t revert back to piecestore.

---

<div class="post-metadata">

**Author:** ![Toyoo](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/toyoo/32/1126_2.png) [@Toyoo](https://forum.storj.io/u/Toyoo)\
**Post date:** [January 27, 2025, 10:57pm UTC](https://forum.storj.io/t/badger-cache-are-we-ready/27323/179 "2025-01-27T22:57:52Z")

</div>

> [@snorkel](#):
>
> Take note that it’s a one way ticket. You can’t revert back to piecestore.

Not with this attitude 😛

The format is not so complex that writing a Python script, maybe even a bash script, to chop log files back into old piece files would be impossible.

---

<div class="post-metadata">

**Author:** ![snorkel](https://storj.bcdn.literatehosting.com/letter_avatar/snorkel/32/6_22734026db12803ebb3e059622ac3534.png) [@snorkel](https://forum.storj.io/u/snorkel)\
**Post date:** [January 28, 2025, 7:15am UTC](https://forum.storj.io/t/badger-cache-are-we-ready/27323/180 "2025-01-28T07:15:40Z")

</div>

I ment for regular mortals, like the rest of us. 😜

[Previous page](https://forum.storj.io/t/badger-cache-are-we-ready/27323.md?page=8)
