# Katran **Repository Path**: skymysky/Katran ## Basic Information - **Project Name**: Katran - **Description**: Katran 是 Facebook 开源的高性能第 4 层负载均衡器,目前在 Facebook 内部处于孵化阶段 - **Primary Language**: Unknown - **License**: GPL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 6 - **Created**: 2018-05-30 - **Last Updated**: 2024-05-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # katran [](https://travis-ci.org/facebookincubator/katran) Katran is a C++ library and [`BPF`](https://en.wikipedia.org/wiki/Berkeley_Packet_Filter) program to build high-performance layer 4 load balancing forwarding plane. Katran leverages [`XDP infrastructure`](https://www.iovisor.org/technology/xdp) from the kernel to provide an in-kernel facility for fast packet's processing. ### Katran's key features: 1. Blazing fast (especially w/ XDP in driver mode). 2. Performance scaling linearly with a number of NIC's RX queues. 3. RSS friendly encapsulation. See the detailed features' description below - ### Documentation's sections: 1. [`README`](README.md) (this file) - a generic overview of katran. 2. [`USAGE`](USAGE.md) - the detailed description of how katran's library can be used, configured or changed. 3. [`DEVELOPING`](DEVELOPING.md) - description of how developing process looks like: how to build and test katran. 4. [`EXAMPLE`](EXAMPLE.md) - output of how to run provided examples (thrift and [`gRPC services`](https://grpc.io/docs/), which leverage katran library) ### Examples of usage: We provide simple examples of katran library usage w/ thrift and gRPC endpoints. Please refer to [`Examples`](EXAMPLES.md) for more detailed information. ### Installation: We provide a shell script that automates the build of katran for Ubuntu 18.04. To build and install katran library and thrift/gRPC examples - you need to run `build_katran.sh` script. It should take care of all the required dependencies. If you need to build it for other Linux distributions, you need to make sure that - 1. it runs on recent linux kernel (4.13+) 2. you have installed: - [`folly`](https://github.com/facebook/folly) - recent version of clang compiler (6.0+) - glog/gtest/gflags/elf libraries - [`wangle`](https://github.com/facebook/wangle) - recent version of [`linux kernel src`](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git) Additionally, if you want to build examples, [`fbthrift`](https://github.com/facebook/fbthrift) and [`gRPC`](https://github.com/grpc/grpc) must be installed, as well! ### Motivation behind layer 4 load balancing: Layer 4 load balancer (lb) enables to easily scale out Layer7 load balancers (the ones which terminate TCP sessions). Benefits of L4 lb over other techniques for scaling L7 lb is that it is - 1. compared to DNS it doesn't need to wait for TTL to redirect traffic from failed L7 lb. 2. compared to anycast-based solution, L4 lbs are more resilient to the networking related issues (which triggers mass ECMP reshuffle)/ enable better handling of adding/removing of L7 lbs from the pool as well as provide better support for unequal load balancing. ### Environment requirements for katran to run: There are special requirements for katran to work properly. However, we do believe that most of the potential users of the library can easily satisfy them: 1. katran works only in DSR (direct service response) mode. 2. Network topology should be L3 based (everything above the top of the rack switch should be routed). This is because we are 'offloading' routing decision for sending packets to the real server to first routing device (by unconditionally sending all packets from katran there.) 3. katran doesn't support fragmentation (it cannot forward the fragmented packet, nor it can fragment them by itself if resulting packet size is bigger then MTU). This could be mitigated either by increasing MTU inside your network or by changing advertising TCP MSS from L7 lbs (this is recommended even if you have increased MTU, as it will prevent fragmentation related issues towards some of the client. For example, if instead of default TCP MSS 1460 (for ipv4) you will advertise 1450 - it will help clients behind [`PPPoE`](https://en.wikipedia.org/wiki/Point-to-Point_Protocol_over_Ethernet) connection). 4. katran doesn't support packets w/ IP options set. 5. Maximum packet size cannot be bigger than 3.5k (and 1.5k by default). 6. katran is built with the assumption that it's going to be used in a "load balancer on a stick" scenario: where single interface would be used both for traffic "from user to L4 lb (ingress)" and "from L4 lb to L7 lb (egress)."