
Katran: A high-performance layer 4 load balancer - SriniK
https://github.com/facebookincubator/katran
======
hacknat
So before anyone gets excited about using this, XDP has to be enabled at the
driver level to work, because basically is allows you to write your own
program to handle incoming packets from the driver, taking the kernel out as
the middle man. The list of supported drivers is small:

[http://prototype-
kernel.readthedocs.io/en/latest/networking/...](http://prototype-
kernel.readthedocs.io/en/latest/networking/XDP/implementation/drivers.html)

I’m actually working on porting XDP into the Xen net front end driver to see
if I can’t get something like this working in AWS. If I do it, I’ll likely
post an example about it here:

[https://github.com/newtools/ebpf](https://github.com/newtools/ebpf)

As an aside cloudflare is using that repo for an XDP load balancer as well.

------
edf13
This is where Facebook actually does some good... their open source efforts
are really good...

[https://github.com/facebookincubator](https://github.com/facebookincubator)
And... [https://github.com/facebook](https://github.com/facebook)

~~~
airesQ
Their papers[1] are also quite good.

[1] -
[https://research.fb.com/publications/](https://research.fb.com/publications/)

------
nickcw
An interesting idea to load balance at L4 so as not to terminate the TCP
sessions (for speed). Normally this constrains the network rather as you can't
route the output packets normally after that (they need to be routed to a
vLAN) but encapsulating with IPIP means the load balancer output can go
straight back into the normal routing layer.

Not constraining the output of the load balancer to a single vLAN really helps
for larger networks.

Reading the readme I see they've made every effort to process the packets as
little as possible to it seems likely that this will run at line speed.

For L4 the main competitor is LVS which scales pretty well in my experience
but probably not as well as this.

------
IMTDb
They talk about being compatible with RSS.

What is RSS in this context, ? My guess is that it's not this RSS
[https://en.wikipedia.org/wiki/RSS](https://en.wikipedia.org/wiki/RSS) because
I do not see how/why you should need any rule at L4 to maintain compatibility
with an XML based protocol.

Is it possible they talk about :
[https://en.wikipedia.org/wiki/Network_interface_controller#R...](https://en.wikipedia.org/wiki/Network_interface_controller#RSS)
?

~~~
jauer
Receive Side Scaling, not the syndication format :)

There's more info at [https://code.facebook.com/posts/1906146702752923/open-
sourci...](https://code.facebook.com/posts/1906146702752923/open-sourcing-
katran-a-scalable-network-load-balancer/)

------
bdahz
What is the difference with IPVS kernel module in Linux? Both are layer 4 load
balancers and IPVS has come a long time and is proven to be good. Any
performance comparisons available?

~~~
hacknat
IPVS cannot be dynamic like XDP can, which can be powered by a reactive bpf
program. XDP bypasses every kernel function and basically takes over packet
processing at the driver level, so the performance tends to be pretty good.
Julia Evans wrote a blog post and has some performance numbers at the bottom
of her post: [https://jvns.ca/blog/2017/04/07/xdp-bpf-
tutorial/](https://jvns.ca/blog/2017/04/07/xdp-bpf-tutorial/)

------
nubb
Fun project. Would anyone actually ever run something like this in production
over something like HAProxy?

~~~
sanxiyn
Congrats, you won HN humor of the day award.

FYI, Facebook runs Katran in production:
[https://code.facebook.com/posts/1906146702752923/open-
sourci...](https://code.facebook.com/posts/1906146702752923/open-sourcing-
katran-a-scalable-network-load-balancer/)

~~~
kondro
Yeah, but will it scale to the 9 billion users my growth chart has me at by
year 3?

