8 ms·
Nucleon, a dynamic TCP load balancer written in Rust
- jaytaylor 11y agoIs 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.
- jdub 11y agoYeah, 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
- steveklabnik 11y agoYes, 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".
- jaytaylor 11y agoThanks for explaining. I definitely like the pattern accounting for integration tests! That is really nice.
- arthursilva 11y agoGreat performance numbers, specially seeing that it only uses a single thread.
- joshbaptiste 11y agohmm.. nice and small .. trying this out now for some internal socks5 hacks
- halayli 11y agohaproxy 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.
- nicolaslem 11y agoNicolas 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.
- derefr 11y agoI 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.
- halayli 11y agoI 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.
- halayli 11y agoWhen 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..
- michaelmior 11y agoI'm surprised that dynamic backend management is based on Redis. This seems very heavyweight. Why not just a simple HTTP API?
- jerf 11y agoWhile 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.
- 15155 11y ago> 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 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)
- derefr 11y agoI 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.
- nicolaslem 11y agoRedis 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.
- madbiz 11y agoCombined with dns SRV lookups it could be a nice alternative to connectable [0]. [0] https://github.com/gliderlabs/connectable https://github.com/gliderlabs/connectable
- dave_ops 11y agoThis has a redis service dependency? That is weird.
- zaroth 11y agoAs opposed to what, implementing your own proprietary control socket? Redis is extremely compact and stable, and relatively tiny.