How does this compare to using HAProxy in TCP mode?
HAProxy is 90k loc while this is 300 loc so they really are different beasts. I would say HAPRoxy is a great general purpose proxy that has most of the features you want while this proxy server is a MVP proxy you can grow off of if you want to do something that HAProxy can't provide.
High Performance TCP Proxy Server
51–60 of 62 posts
Re: High Performance TCP Proxy Server
#52Very nice, but this is more of a demo code for boost::asio than something that is production-worthy. For example, it doesn't relay FINs between connections, doesn't disable Nagle algorithm on the upstream socket, doesn't wait for pending writes to complete before tearing down the connection, doesn't handle congestion at all (potentially leading to unbound memory use), etc.
Could you point to an open source TCP proxy that you'd consider production worthy with an approachable code base?
Re: High Performance TCP Proxy Server
#53Why not just? Linux: iptables -t nat -A PREROUTING -p tcp -s 192.168.20.200/0 -d 192.168.0.100/0 --dport 8080 -j REDIRECT --to-ports 20000 Windows: netsh interface portproxy add v4tov4 listenaddress=192.168.20.200 listenport=8080 connectaddress=192.168.0.100 connectport=20000 protocol=tcp
Re: High Performance TCP Proxy Server
#54Earlier quoted context omitted.
> If A closes, close B. If B closes, close A. It's shutdown() writes on EOFs, not close, with refcounting to also do close() when EOFs were detected on both directions (I also have written a TCP proxy). But yeah, TCP proxies are trivial, would be more interesting to see something like a tunneling proxy that sends data over multiple connections to maximize performance.
Hey, I am looking for a way of packing multiple TCP streams over a single TCP connection to a backend server. I can unpack them in application logic if necessary. Do you know what that is called? Kinda like SCTP
Probably, though, it's best to start with why you would want to do that. You could be, for example, trying to solve something where a pub/sub model would work better. Or just two separate apps, on different ports. What's driving the idea of multiplexing?
Re: High Performance TCP Proxy Server
#55Very nice, but this is more of a demo code for boost::asio than something that is production-worthy. For example, it doesn't relay FINs between connections, doesn't disable Nagle algorithm on the upstream socket, doesn't wait for pending writes to complete before tearing down the connection, doesn't handle congestion at all (potentially leading to unbound memory use), etc.
Could you point to an open source TCP proxy that you'd consider production worthy with an approachable code base?
nginx and apache only do HTTP(S). Don't support TCP.
Re: High Performance TCP Proxy Server
#56Why not just? Linux: iptables -t nat -A PREROUTING -p tcp -s 192.168.20.200/0 -d 192.168.0.100/0 --dport 8080 -j REDIRECT --to-ports 20000 Windows: netsh interface portproxy add v4tov4 listenaddress=192.168.20.200 listenport=8080 connectaddress=192.168.0.100 connectport=20000 protocol=tcp
-s 192.168.20.200/0 -d 192.168.0.100/0
That sounds wrong.You probably meant /24 or /32. Or you meant to not write anything to not filter it at all.
Re: High Performance TCP Proxy Server
#57Why not just? Linux: iptables -t nat -A PREROUTING -p tcp -s 192.168.20.200/0 -d 192.168.0.100/0 --dport 8080 -j REDIRECT --to-ports 20000 Windows: netsh interface portproxy add v4tov4 listenaddress=192.168.20.200 listenport=8080 connectaddress=192.168.0.100 connectport=20000 protocol=tcp
Use Keepalived (http://www.keepalived.org/) for HA and health checking or use Gorb (https://github.com/kobolog/gorb) and you can dynamically change services / backends using a REST API.
Re: High Performance TCP Proxy Server
#58Earlier quoted context omitted.
Could you point to an open source TCP proxy that you'd consider production worthy with an approachable code base?
HAProxy is the gold standard. nginx and apache only do HTTP(S). Don't support TCP.
That's not entirely accurate. For nginx, for example, there's the ngx_stream_core_module[1]. It's not particularly well-documented though, so I don't know much about it.
[1]: https://nginx.org/en/docs/stream/ngx_stream_core_module.html
Re: High Performance TCP Proxy Server
#59If it meets the guidelines, this might make a good 'Show HN'. Show HN guidelines: https://news.ycombinator.com/showhn.html
I felt kinda bad tearing it apart and only did so because it wasn't posted as a ShowHN. It's cool to show people an example of networking using Boost but the article and post have no mention of this being alpha quality software.
Re: High Performance TCP Proxy Server
#60Earlier quoted context omitted.
HAProxy is the gold standard. nginx and apache only do HTTP(S). Don't support TCP.
> nginx and apache only do HTTP(S). Don't support TCP. That's not entirely accurate. For nginx, for example, there's the ngx_stream_core_module[1]. It's not particularly well-documented though, so I don't know much about it. [1]: https://nginx.org/en/docs/stream/ngx_stream_core_module.html
For the sake of god, please don't have your entire site run on experimental software like that. ^^