listen port auto allocation questions

52 views
Skip to first unread message

Vasiliy Tolstov

unread,
Jul 13, 2019, 5:11:43 PM7/13/19
to golan...@googlegroups.com
Hi. I have busy system with more then 20000 ports in use.
I need to run 20-50 microservices and each of them need to listen tcp port.
I want to use listen port auto allocation by specify as listen port :0
Sometimes i have errors like already listening on []:22925 that
happened because port already in use when start by other service.
How can i'm avoid such errors and not specify ports by hand?

--
Vasiliy Tolstov,
e-mail: v.to...@selfip.ru

Andrew Pillar

unread,
Jul 13, 2019, 5:30:34 PM7/13/19
to Vasiliy Tolstov, golan...@googlegroups.com
> How can i'm avoid such errors and not specify ports by hand?
Perhaps you could use some kind of central store for storing the most
recently used port? Simply take that port from the store, increment it,
and place it back into the store for the next micro-service to use.

I think etcd [1], may be a good use case for this.

[1] - https://github.com/etcd-io/etcd


--
Andrew

Vasiliy Tolstov

unread,
Jul 13, 2019, 5:45:07 PM7/13/19
to Andrew Pillar, Vasiliy Tolstov, golan...@googlegroups.com
вс, 14 июл. 2019 г. в 00:30, Andrew Pillar <m...@andrewpillar.com>:
>
> > How can i'm avoid such errors and not specify ports by hand?
> Perhaps you could use some kind of central store for storing the most
> recently used port? Simply take that port from the store, increment it,
> and place it back into the store for the next micro-service to use.
>
> I think etcd [1], may be a good use case for this.

I think about it, but then we pass to kernel port 0, it allocates free
port, but this is not mean that after millisecond this port not be
used by other service....
Reply all
Reply to author
Forward
0 new messages