8 ms·
One of my coworkers wrote a really cool bit of software to do this. I want him to open source it. Basically, you can share a single socket amongst many server
by implicit 12y ago
One of my coworkers wrote a really cool bit of software to do this. I want him to open source it.
Basically, you can share a single socket amongst many servers. The OS ensures that just one process accepts each connection.
You can therefore have a manager process that owns the socket and passes it on to application processes.
To update, start new processes, then politely tell the old ones to go away.
- samstokes 12y agoeinhorn [1] implements this model and is pretty effective. Used in production at Stripe and other places. (It's written in Ruby, but can run application processes in any language.) [1] https://github.com/stripe/einhorn https://github.com/stripe/einhorn
- dllthomas 12y agoOne really cool thing in Linux is that you can actually pass file descriptors between processes over unix domain sockets.
- enigmo 12y agoWindows has supported this for ~14 years too.
- dllthomas 12y agoGood to know. Does it work for everything that's an fd in Linux? I know you've got to treat sockets and files differently in some cases (or at least did once)...
- enigmo 12y agoIt works for most kernel handles, sockets might be a little more normal starting with Win7 but I stopped doing Windows development around then. Here are the official docs: http://msdn.microsoft.com/en-us/library/windows/desktop/ms724251(v=vs.85).aspx http://msdn.microsoft.com/en-us/library/windows/desktop/ms72...
- dllthomas 12y agoLooks like there's a separate function for sockets. Still, cool stuff there too.