News for hackers. Stuff that matters.
Re:Nucleon, a dynamic TCP load balancer written in Rust by halayli on Tuesday October 20, 2015 @02:20PM (#10420816)
haproxy can be configured in so many ways. Without providing your haproxy config and testing environment these numbers won't make sense.

For example, configure haproxy with tcp splicing, and now you eliminated all the userland/kernel copies between client/server, and haproxy goes as fast as your kernel + network IO can go.

Re:Nucleon, a dynamic TCP load balancer written in Rust by nicolaslem on Tuesday October 20, 2015 @03:39PM (#10421284)
Nicolas from Nucleon here. You are right, I probably shouldn't have put these numbers there as haproxy can be configured way better than it is with its default configuration.

I put them because I was impressed that Rust and mio, with little to no optimization, can compete with the best softwares out there.

Re:Nucleon, a dynamic TCP load balancer written in Rust by derefr on Tuesday October 20, 2015 @04:18PM (#10421546)
I think it's useful to to have "untuned HAProxy" as a reference benchmark, to have a goal to measure pre-1.0 development progress against. When a project hits that order-of-magnitude of speed, you can assume it isn't screwing anything major up in its design.
Re:Nucleon, a dynamic TCP load balancer written in Rust by halayli on Tuesday October 20, 2015 @11:24PM (#10423501)
I am not saying to tune HAProxy to win the benchmark. When you want to compare, it's a good idea to compare apples to apples.

Like I said in my previous comment, HAProxy is a doing a lot more than what it's being compared with. HAProxy has timeout schedulers that are activated on every packet received, maintain stats, logging, and a lot more.

Re:Nucleon, a dynamic TCP load balancer written in Rust by halayli on Tuesday October 20, 2015 @11:22PM (#10423487)
When proxying network IO, there's not much that the language is doing. The burden is more on the OS.

However, the comparison is not fair because what you are doing is just passing data in and out while haproxy is running a scheduler to maintain timeouts, logging, checking acl rules on connection establishment, maintaining stats, etc..

Re:Nucleon, a dynamic TCP load balancer written in Rust by michaelmior on Tuesday October 20, 2015 @02:52PM (#10421006)
I'm surprised that dynamic backend management is based on Redis. This seems very heavyweight. Why not just a simple HTTP API?
Re:Nucleon, a dynamic TCP load balancer written in Rust by jerf on Tuesday October 20, 2015 @03:15PM (#10421134)
While I'm sure someone, somewhere in the world has it, it would be an odd use case where the "heavyweightness" of the run-time configuration interface actually matters to anyone.

And, well, actually, if I had to bet, I'd bet Redis is actually lighter weight than an HTTP request, honestly. HTTP is really quite inefficient for small requests, and requires a massive pile of code to deal with endless, endless corner cases than an application-specific protocol doesn't.

Re:Nucleon, a dynamic TCP load balancer written in Rust by 15155 on Tuesday October 20, 2015 @03:36PM (#10421265)
> I'd bet Redis is actually lighter weight than an HTTP request

It is.

Here's a cool, non-relevant example of one implementing a Redis clone in Haskell (on HN a month or so ago):

https://honza.ca/2015/09/building-a-redis-clone-in-haskell

The relevant portion is where they parse the protocol, not bad at all (especially compared to HTTP)

Re:Nucleon, a dynamic TCP load balancer written in Rust by derefr on Tuesday October 20, 2015 @04:24PM (#10421583)
I wouldn't compare Redis pub/sub on a persistent Redis socket to straight HTTP requests; it's more like an HTTP Server-Sent-Event stream, which looks pretty similar at the protocol level.
Re:Nucleon, a dynamic TCP load balancer written in Rust by nicolaslem on Tuesday October 20, 2015 @03:47PM (#10421347)
Redis in Pub/Sub is quite lightweight in fact. It's just a TCP connection between your application and the Redis database. Once opened, you can get notifications almost for free.

I was thinking on adding a separate HTTP API to control the load balancer that would read and write to Redis, notifying the load balancer when changes should be applied.

Re:Nucleon, a dynamic TCP load balancer written in Rust by dave_ops on Tuesday October 20, 2015 @07:55PM (#10422695)
But it's a SPoF and an extra remote or local service that has to be configured, maintained, etc. The thing that's coming online has to publish a message to redis anyway, so why not just maintain the service map inside the Rust application and open up a socket that allows those things to speak straight to Nucleon for mutating its configuration?
Re:Nucleon, a dynamic TCP load balancer written in Rust by michaelmior on Tuesday October 27, 2015 @12:12AM (#10456281)
That's more what I was getting at, not "heavyweight" in the sense that I see it as a performance concern.
Re:Nucleon, a dynamic TCP load balancer written in Rust by halayli on Wednesday October 21, 2015 @04:13AM (#10424220)
What happens if your connection to redis dropped and a pub was made in between?
Re:Nucleon, a dynamic TCP load balancer written in Rust by jedisct1 on Tuesday October 20, 2015 @06:03PM (#10422131)
What not NATS instead? There's even a very nice Rust client library for NATS :)
Re:Nucleon, a dynamic TCP load balancer written in Rust by jaytaylor on Tuesday October 20, 2015 @05:15PM (#10421853)
Is putting the unit-tests inline with the code standard best practice in rust?

Overall it's an interesting project and seems like a nice showcase of actual rust src code.

Re:Nucleon, a dynamic TCP load balancer written in Rust by jdub on Tuesday October 20, 2015 @05:19PM (#10421885)
Yeah, it's one of the methods supported by Cargo. You can put them in the code or in separate modules. Cargo will also test your documentation examples. :-D
Re:Nucleon, a dynamic TCP load balancer written in Rust by steveklabnik on Wednesday October 21, 2015 @10:18AM (#10425546)
Yes, the pattern used here is usual. However, you can also pull any module out to another file, if it gets too big. But the pattern is "Unit tests with the code, integration tests in a separate tests directory".
Re:Nucleon, a dynamic TCP load balancer written in Rust by jaytaylor on Wednesday October 21, 2015 @03:18PM (#10427870)
Thanks for explaining. I definitely like the pattern accounting for integration tests! That is really nice.
Re:Nucleon, a dynamic TCP load balancer written in Rust by dave_ops on Tuesday October 20, 2015 @07:47PM (#10422659)
This has a redis service dependency? That is weird.
Re:Nucleon, a dynamic TCP load balancer written in Rust by zaroth on Thursday October 22, 2015 @01:35AM (#10430551)
As opposed to what, implementing your own proprietary control socket? Redis is extremely compact and stable, and relatively tiny.
Re:Nucleon, a dynamic TCP load balancer written in Rust by madbiz on Tuesday October 20, 2015 @04:03PM (#10421456)
Combined with dns SRV lookups it could be a nice alternative to connectable [0].

[0] https://github.com/gliderlabs/connectable

Re:Nucleon, a dynamic TCP load balancer written in Rust by arthursilva on Tuesday October 20, 2015 @02:00PM (#10420701)
Great performance numbers, specially seeing that it only uses a single thread.
Re:Nucleon, a dynamic TCP load balancer written in Rust by joshbaptiste on Tuesday October 20, 2015 @02:08PM (#10420752)
hmm.. nice and small .. trying this out now for some internal socks5 hacks