r4m0n changed the topic of #kspmodders to: Technical discussion ONLY (KSP related or not), for random shit-talking, join #shitshow (seriously)
VanDisaster has quit [Ping timeout: 383 seconds]
VanDisaster has joined #kspmodders
GlassYuri has joined #kspmodders
fcbayerndm has quit [Quit: fcbayerndm]
fcbayerndm has joined #kspmodders
Nekark has joined #kspmodders
Kracc has quit [Ping timeout: 190 seconds]
fcbayerndm has quit [Quit: fcbayerndm]
mkv has joined #kspmodders
m4v has quit [Ping timeout: 186 seconds]
mkv is now known as m4v
angavrilov has joined #kspmodders
kronal_ has quit [Read error: Connection reset by peer]
kronal has joined #kspmodders
Supernovy has quit [Quit: Goodnight.]
RandomJeb has quit [Ping timeout: 190 seconds]
GlassFragments has joined #kspmodders
GlassYuri has quit [Ping timeout: 186 seconds]
xEvilReeperx has joined #kspmodders
GlassFragments has quit [Quit: Leaving]
xEvilReeperx has quit [Quit: Web client closed]
fcbayerndm has joined #kspmodders
Rokker has quit [Quit: Connection closed for inactivity]
<Majiir>
Is there a way (on Linux) to bring up a new process listening on a TCP port and have that seamlessly take over any new connections?
<Majiir>
without already having a whole load balancer in place
<r4m0n>
you mean with a process already listening on it?
<r4m0n>
if so, nothing pretty... but you could write an iptables rule to "load balance" that. start the new process on another port, redirect half the connections that way randomly with iptables
<Majiir>
Hum
<Majiir>
Yeah, that would work quite well actually.
<r4m0n>
you're probably looking for a REDIRECT rule, probably on PREROUTING, with --random
<Majiir>
Is that more or less just DNAT?
<Majiir>
Routing 100% of the traffic to the new process would be fine too, and then once I bring the old one down, I can have the new one bind on the original ports
<Majiir>
(or repeat the dance again)
<r4m0n>
then just a straight redirect will do. might be on the INPUT table
<r4m0n>
the random one would lose some packets as the other process go down
<r4m0n>
it's quite blind, it'll just rewrite the packets
<SilverFox>
so all that's negative about it is some packet loss during switching?
<Majiir>
If you redirect everything, there shouldn't be any packet loss
<r4m0n>
yep
<Majiir>
The downside is iptables is a bit clumsy compared to a proper balancer. It'll be a bit of digging up commands to find out when all the open connections are drained.
<Majiir>
The process in question is nginx, so that's actually easy; it can just stop and wait for connections to close on its own.
<r4m0n>
just netstat will do to track the currently open ones
<r4m0n>
I'm assuming this is all very mission-critical, 99% of admins just restart the thing and let connections bounce for as bit XD
<Majiir>
Oh I know very well how poorly this is done in real production systems
<Majiir>
I like to practice with paranoia on my personal crap where it doesn't matter so I have the experience to yell at the ops guys who just took down production for half our users when I'm at work
<r4m0n>
this is pretty good thinking overall, haven't actually never thought of doing it this way
<r4m0n>
though you have to setup a secondary webserver to handle the traffic while the main one updates/gets replaced
<Majiir>
The use case here is I'm moving nginx into a Docker container, and then later migrating that over to a different host. For my sites to work properly, nginx needs to bind on the host network directly, which means I need to bring up the container on ports other than 80/443 at first.
<Majiir>
It's easy to say I have zero people using my services so downtime doesn't matter. It's fun to practice zero DT though.
<SilverFox>
zero downtime is nice
<r4m0n>
so something like bring the docker one on port 888, redirect 80 to it, kill old process, add port 80 to the docker one, reload config, kill iptables rule, remove port 888, reload rules
<Majiir>
Yep. Since the nginx container needs to be directly on the host network, I should be able to have it bind to 80 after reload without restarting the container.
<r4m0n>
just check that ports under 1024 need root permission to bind
<Majiir>
Shouldn't be an issue since Docker is privileged anyway
<r4m0n>
as long it isn't on paranoid permissions, everything should be fine :-)
Majiir is now known as Snoozee
kronal has quit [Ping timeout: 190 seconds]
Rokker has joined #kspmodders
Technicalfool_ has joined #kspmodders
Technicalfool has quit [Ping timeout: 383 seconds]
pizzaoverhead has joined #kspmodders
kronal has joined #kspmodders
fcbayerndm has quit [Quit: fcbayerndm]
kronal_ has joined #kspmodders
kronal has quit [Ping timeout: 182 seconds]
angavrilov has quit [Remote host closed the connection]
kronal_ has quit [Read error: Connection reset by peer]
kronal has joined #kspmodders
Supernovy has joined #kspmodders
kronal has quit [Read error: Connection reset by peer]
kronal has joined #kspmodders
fcbayerndm has joined #kspmodders
pizzaoverhead has quit [Read error: Connection reset by peer]