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
Allow selecting random port #7652
Comments
Hello @Phantal Thanks for proposing this feature request. The problem with your suggestion is that historically the value of 0 means that Redis will not listen on TCP ports, so if we make the change we'll break the contract with the userbase. This, however, can be easily solved by using a different value, e.g. -1, or even a new config flag. That said, I'm not totally clear on the use case here. As Redis is a non-discoverable service, in the sense that a remote client needs beforehand knowledge of its address and port, a random choice of port seems unneeded. Please clarify how this can be used in the wild. |
Our use case is a multi process application in a multi tenant environment
without something like kubernetes [yet] available.
The IPC mechanisms our predecessors came up with are many and varied.
We're attempting to standardize on Redis.
Unfortunately, the multi tenancy means we cannot just choose a port.
Without this feature the only other option I've found and like is to bind
port zero, query the socket, close it, then launch Redis with that port.
This is contingent upon Redis using SO_REUSEADDR, something I have not yet
verified.
Another less palatable option is domain sockets. This is less palatable in
that some of the processes are on remote machines. I could forward the
domain socket with SSH, but that strays into the realm of hokey, not to
mention possibly adding latency.
…On Wed, Aug 12, 2020, 05:49 Itamar Haber ***@***.***> wrote:
Hello @Phantal <https://github.com/Phantal>
Thanks for proposing this feature request. The problem with your
suggestion is that historically the value of 0 means that Redis will not
listen on TCP ports, so if we make the change we'll break the contract with
the userbase. This, however, can be easily solved by using a different
value, e.g. -1, or even a new config flag.
That said, I'm not totally clear on the use case here. As Redis is a
non-discoverable service, in the sense that a remote client needs
beforehand knowledge of its address and port, a random choice of port seems
unneeded. Please clarify how this can be used in the wild.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#7652 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACG4TLUAR4DRGSQ3V4C3EFTSAJ6V3ANCNFSM4P4FVHJQ>
.
|
this could also possibly be a solution to a problem we are / were facing with our test suite. the code we have now is some loop that tries to find a free port (see @yossigo what do you think Note that in the non-cluster tests this is not a good solution, since we must have each test thread use a different port range so that in some races in the test teardown servers will not try to replicate from ones in a different test. |
I am not in favor of this for several reasons:
@oranagra I think solving the tests issues externally would be anyway simpler and more reliable. @Phantal Do processes in your environment continuously race each other for resources (TCP ports)? If they don't do that, I guess a simpler approach would be to wrap Redis with some script that handles it:
The only other potential solution I see is to be support run-time This could get tricky, in particular now that we have both TCP and TLS, etc.. But it could also be simplified by allowing a port to be set if it was not previously configured. So, you could start with no TCP port configured, then attempt random This would have the benefits of (a) allocation is atomic, so it works well in a dynamic environment; (b) it MIGHT be marginally useful in some other cases. |
Hello, we are facing the same situation. @yossigo May be it is acceptable to write bound port value in the file specified by the config? It should be enough in most cases. |
@sergey-komissarov I'm not sure I understand your suggestion, do you mean specify a port range Redis should allocate from? How do you plan to determine the mapping between ports and instances if it's random? |
@yossigo I thought about config or command line option 'port-file' with absolute path to the file where server writes port number as text. Of course file path must be unique for each instance on the node, but this may be handled by node maintaners. |
@sergey-komissarov Your proposal is valid, but I think it goes a relatively long way (new config option) to solve a very specific problem. I am more in favor of simply making |
Hello, just chiming in to say that would be useful to us @BelledonneCommunications as well, because we use redis in our automated test suite. Both being able to ask for the port to be dynamic (and then e.g. parsing stdout to get it) or being able to |
redis/src/server.c
Line 2807 in 6f11acb
I am requesting that the allowed values for the port be changed as follows:
0 has special meaning: select an unused port. This port can then be queried with tools like lsof, netstat, ss, etc.
The text was updated successfully, but these errors were encountered: