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

Delay fork() if another instance in the same box is fork()ing already #4055

Open
antirez opened this issue Jun 14, 2017 · 6 comments
Open

Delay fork() if another instance in the same box is fork()ing already #4055

antirez opened this issue Jun 14, 2017 · 6 comments

Comments

@antirez
Copy link
Contributor

antirez commented Jun 14, 2017

When multiple Redis instances are running on the same box, it is a good idea for them to coordinate so that different instances will persist on disk at different times, avoiding to create a child process and to do a lot of disk I/O at the same time. While in general running multiple very busy Redis instances in multi-tenancy is anyway more complex to get right, this alone could reduce significantly the problems that normally users face. This is especially important in Redis Cluster where it happens often (even if not always a good idea) that multiple cluster nodes are grouped in the same physical systems or VMs.

In order to implement such a feature, some kind of inter-process locking primitive should be used, possibly the one posing the lowest latency concerns. Also instances should be able to detect if a lock is no longer valid because the instance locking the resource is not operating correctly, or crashed, or any other problem, and in that case re-acquire the lock. In the simple case of a lock file, the process holding the lock could refresh the time of the lock as the lock file content so that stale lock detection could be simple.

The feature would be disabled by default. Potentially the lock name could be configured so that different instances groups could be locked independently of others. This is useful, for instance, in the case of multiple disks in the same machine.

@mp911de
Copy link

mp911de commented Jun 14, 2017

You should consider multi-disk systems in your thoughts. If you have as many Redis processes as disks, then you don't run necessarily into I/O contention.

@antirez
Copy link
Contributor Author

antirez commented Jun 14, 2017

@mp911de thanks, comment updated to reflect this. Specifying the lock name allows to group instances. Also the feature is off by default.

@dvirsky
Copy link
Contributor

dvirsky commented Jun 14, 2017

@mp911de it still creates a CPU and RAM overhead that is considerable. Perhaps it should be tunable what the maximum allowed number of concurrent forks at once.

@wooparadog
Copy link

wooparadog commented Jun 14, 2017

@dvirsky Using a named lock can limit concurrency.

--
edit: limit to the number of locks.

@dvirsky
Copy link
Contributor

dvirsky commented Jun 14, 2017

@antirez another thing to keep in mind - multiple containers running a single redis instance each - all on the same machine. So just using some filesystem based thingie might be harder. Not sure what the optimal solution is, but just something to keep in mind when considering trade-offs.

@antirez
Copy link
Contributor Author

antirez commented Jun 14, 2017

@dvirsky yep... good point. Maybe it's possible to create a shared memory chunk or alike. There is to evaluate all the IPC possibilities.

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

No branches or pull requests

4 participants