Git Product home page Git Product logo

clb.ko's Introduction

[WORK IN PROGRESS!!!] clb.ko

Load-balance connect(2)ions transparently to the application, with zero overhead after establishment.

Motivation

Client Side Loadbalancing with iptables or IPVS has some overhead.

Baseline Performance

Client: 192.168.111.11

$ taskset -c 1 redis-benchmark -h 192.168.111.1 -p 6379 -c 100 -P 1 -t ping -n 10000000
^CNG_INLINE: 115972.19

Server: 192.168.111.1

$ taskset -c 0 redis-server --port 6379 --save '' --bind 0.0.0.0

IPVS Performance

Client: 192.168.111.11 with -g (Direct Routing):

$ sudo ipvsadm -A -t 10.0.0.1:6379 -s rr
$ sudo ipvsadm -a -t 10.0.0.1:6379 -r 192.168.111.1:6379 -g
$ taskset -c 1 redis-benchmark -h 10.0.0.1 -p 6379 -c 100 -P 1 -t ping -n 10000000
^CNG_INLINE: 111467.13

Client: 192.168.111.11 with -m (NAT):

$ sudo ipvsadm -A -t 10.0.0.1:6379 -s rr
$ sudo ipvsadm -a -t 10.0.0.1:6379 -r 192.168.111.1:6379 -m
$ taskset -c 1 redis-benchmark -h 10.0.0.1 -p 6379 -c 100 -P 1 -t ping -n 10000000
^CNG_INLINE: 103044.31

iptables Performance

Client: 192.168.111.11 (without SNAT)

$ sudo iptables -t nat -A OUTPUT -m statistic --mode random --probability 1.0 -m tcp -p tcp -d 10.0.0.1 --dport 6379 -j DNAT --to-destination 192.168.111.1:6379
$ taskset -c 1 redis-benchmark -h 10.0.0.1 -p 6379 -c 100 -P 1 -t ping -n 10000000
^CNG_INLINE: 95377.39

Features

Pros

  • Performance. There's no overhead after the connection is established.
  • Can connect to different port on the real servers. This is what ipvs cannot when using direct routing.

Cons

  • There is some overhead on connect(2) and close(2). This shouldn't be noticeable if you don't establish > 100 thousands of connections per second.
  • Cannot mix IPv4 and IPv6 sevices. IPv4 virtual server can only be served by IPv4 real servers. Same for IPv6.
  • This is a client-side load balancing solution and works only for locally-originated connect(2)ions. Use iptables or IPVS if you want to accept remote connections.
  • This is a layer-4 load balancer. Cannot balance load per-request basis. i.e.) all HTTP requests on the same connection goes to the same backend server.

Requirements

  • Arch: x86_64

Usage

TBD

Caveats

  • While connect(2) are load-balanced transparently to the application, getpeername(2) on the socket will return the real server address, not the virtual one, breaking some transparency.

License

The GNU General Public License v2.0

clb.ko's People

Contributors

eiiches avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.