Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to disable client heartbeat #3329

Closed
aofei opened this issue Mar 13, 2023 · 6 comments
Closed

Add the ability to disable client heartbeat #3329

aofei opened this issue Mar 13, 2023 · 6 comments
Labels
kind/feature New feature or request

Comments

@aofei
Copy link

aofei commented Mar 13, 2023

What would you like to be added:

Please consider making juicefs mount --heartbeat 0 ... to disable the client heartbeat feature.

Why is this needed:

My use case:

$ juicefs format \
	--storage sqlite3 \
	--bucket /litestream/data-dir.jfs-bucket.db \
	sqlite3:///litestream/data-dir.jfs-meta.db \
	data-dir
$ litestream replicate -sync-interval 1 /litestream/data-dir.jfs-meta.db s3://mybkt/data-dir.jfs-meta.db &
$ litestream replicate -sync-interval 1 /litestream/data-dir.jfs-bucket.db s3://mybkt/data-dir.jfs-bucket.db &
$ juicefs mount sqlite3:///litestream/data-dir.jfs-meta.db /data

The files in /data rarely change, but I still expect JuiceFS to reflect to those two databases when it does, and Litestream to stream WALs to my S3 bucket in time. They actually do work pretty well together. Until I got my S3 bill.

Again, the files in /data are rarely change, so I'd like JuiceFS to be quiet until it does, which means it shouldn't be doing any writes to those two databases. But here comes the problem. It turns out that there is a heartbeat feature for the client here. The client always send heartbeats to meta storage at regular intervals (which defaults to 12s, and fixed in the [1, 60] interval). This means that by default every 12s Litestream will stream two WALs to my S3 bucket (I don't know why two). In other words, two S3 class A operations every 12s, or 432,000 class A operations every month, for nothing. And I have hundreds of the above setups currently active...

I know that for network meta storage, such as Redis, the client heartbeat feature is indispensable. But when it comes to SQLite meta storage, I believe this feature is unnecessary, given that there is only local disk I/O.

So I think it's reasonable to add the ability to disable the client heartbeat.

@aofei aofei added the kind/feature New feature or request label Mar 13, 2023
@solracsf
Copy link
Contributor

solracsf commented Mar 17, 2023

@aofei there is a --heartbeat option.
Have you set it to 0?

https://juicefs.com/docs/community/command_reference/#mount

@aofei
Copy link
Author

aofei commented Mar 17, 2023

Hi @solracsf! And yes, I'm aware of the --heartbeat option. But, like I said, --heartbeat 0 is actually equivalent to --heartbeat 1.

... which defaults to 12s, and fixed in the [1, 60] interval...

@solracsf
Copy link
Contributor

solracsf commented Mar 17, 2023

True

if c.Heartbeat < time.Second {
logger.Warnf("heartbeat should not be less than 1 second")
c.Heartbeat = time.Second

Indeed, for SQLite and BadgerDB 0 should be allowed.

@SandyXSD
Copy link
Contributor

Fixed by #3471

@SandyXSD
Copy link
Contributor

There is still some background updates with low frequency per volume, e.g.

if ok, err := m.en.setIfSmall("lastCleanupFiles", time.Now().Unix(), int64(time.Minute.Seconds())*9/10); err != nil {

@aofei
Copy link
Author

aofei commented Apr 13, 2023

Fixed by #3471

Thanks for the fix! ❤️

There is still some background updates with low frequency per volume, e.g.

if ok, err := m.en.setIfSmall("lastCleanupFiles", time.Now().Unix(), int64(time.Minute.Seconds())*9/10); err != nil {

I'd take that as acceptable, given that --no-bgjob is already there.

I'm going to close this issue.

@aofei aofei closed this as completed Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature New feature or request
Projects
None yet
3 participants