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

fsync just once a second is a very bad idea. #3

Closed
funny-falcon opened this issue Jul 20, 2016 · 4 comments
Closed

fsync just once a second is a very bad idea. #3

funny-falcon opened this issue Jul 20, 2016 · 4 comments

Comments

@funny-falcon
Copy link

You should at least mention in a README, that user can loose whole second of changes.

@tidwall
Copy link
Owner

tidwall commented Jul 20, 2016

Thanks for mentioning this. I agree that some more clarification can be made around this topic. I also look forward to providing optional fsync policies of Always, EverySecond, and Never.

Salvatore Sanfilippo talks about the same thing. http://redis.io/topics/persistence#how-durable-is-the-append-only-file

@tidwall tidwall closed this as completed Jul 20, 2016
@tidwall
Copy link
Owner

tidwall commented Jul 20, 2016

I updated the README and added a SyncPolicy which can be set to Always for fsyncing after every write. b4e23eb

@funny-falcon
Copy link
Author

Redis is awful database to learn from. Just keep it in mind. It did almost all wrong internally. Single thing it did well is user API.

You may batch and pipeline fsync requests:

  • several request made within 1ms are batched, written and fsync request is sent. Batch waits on this particular fsync to return. (you may consider using Future: https://godoc.org/github.com/Workiva/go-datastructures/futures#Selectable )
  • next batch will sent next fsync request without waiting for previous batch to return. Modern Linux systems performs well this way.

Combining batching with pipelining you may reach acceptable throughput without sacrificing durability.

Of course, it will not as fast as fsyncing once a second, and it will have large latency.

@tidwall
Copy link
Owner

tidwall commented Jul 20, 2016

Very helpful information. Thank you for sharing with me. I'm starting to lean towards setting the sync policy to Always by default. Then the user can choose what's best for their application, even turning it off altogether.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants