Experimental, Zero allocation Balancing machine that can be plugged anywhere
Balancer helps you to balance jobs/requests/messages between workers. It is well tested, ready to be used in production under high throughput.
*Balancer is not a reverse proxy, it is a router, so you balance things between any type of Node Pool.
The interface of balancer is as simple as,
Selector is one of selection policies:
- RoundRobin - selects next available upstream on every request
- Hash - matches client using consistent hashing by its own id (any string like ip address or user id)
- LeastConnection - selects the node that has the lowest active connection (using Node.Load)
- LeastTime - selects the node that has the lowest response time (using Node.AverageResponseTime)
Any type of object that satisfies Node Interface will work as node
You decide the selection policy on init like;
Add nodes and balancer machine will decide the next upstream based on the policy
Those results are for 10 upstreams where half of them are down but still in pool. (see balancer_test.go for details) I tried to keep mocking as a real example as possible (Increasing current load, load times and kep half of them down all the time). So those results are worst case of finding the best upstream in pool.
Real World Examples
-- coming soon
is a high performance Layer-4 load balancer based on DPDK. It's derived from Linux Virtual Server LVS and its modification alibaba/LVS.
Notes: The name comes from "DPDK-LVS".
Several techniques are applied for high performance:
- Kernel by-pass (user space implementation).
- Share-nothing, per-CPU for key data (lockless).
- RX Steering and CPU affinity (avoid context switch).
- Batching TX/RX.
- Zero Copy (avoid packet copy and syscalls).
- Polling instead of interrupt.
- Lockless message for high performance IPC.
- Other techs enhanced by DPDK.
Major features of including:
- L4 Load Balancer, including FNAT, DR, Tunnel, DNAT modes, etc.
- SNAT mode for Internet access from internal network.
- NAT64 forwarding in FNAT mode for quick IPv6 adaptation without application changes.
- Different schedule algorithms like RR, WLC, WRR, MH(Maglev Hashing), Conhash(Consistent Hashing) etc.
- User-space Lite IP stack (IPv4/IPv6, Routing, ARP, Neighbor, ICMP ...).
- Support KNI, VLAN, Bonding, Tunneling for different IDC environment.
- Security aspect, support TCP syn-proxy, Conn-Limit, black-list， white-list.
- QoS: Traffic Control.
feature modules are illustrated as following picture.
This quick start is tested with the environment below.
- Linux Distribution: CentOS 7.2
- Kernel: 3.10.0-327.el7.x86_64
- CPU: Intel(R) Xeon(R) CPU E5-2650 v3 @ 2.30GHz
- NIC: Intel Corporation Ethernet Controller 10-Gigabit X540-AT2 (rev 03)
- Memory: 64G with two NUMA node.
- GCC: gcc version 4.8.5 20150623 (Red Hat 4.8.5-4)
Other environments should also be OK if DPDK works, please check dpdk.org for more info.
Notes: To let dpvs work properly with multi-cores, rte_flow items must support "ipv4, ipv6, tcp, udp" four items, and rte_flow actions must support "drop, queue" at least.
Well, let's start from DPDK then.
Currently, is recommended for , and we will not support dpdk version earlier than dpdk-20.11 any more. If you are still using earlier dpdk versions, such as , and , please use earlier dpvs releases, such as v1.8.10.
Notes: You can skip this section if experienced with DPDK, and refer the link for details.
There are some patches for DPDK to support extra features needed by DPVS. Apply them if needed. For example, there's a patch for DPDK driver for hardware multicast, apply it if you are to launch on device.
Notes: Assuming we are in DPVS root directory and dpdk-stable-20.11.1 is under it, please note it's not mandatory, just for convenience.
Tips: It's advised to patch all if your are not sure about what they are meant for.
DPDK build and install
Use meson-ninja to build DPDK libraries, and export environment variable for DPDK app (DPVS). The in DPVS checks the presence of libdpdk.
Tips: You can use script dpdk-build.sh to facilitate dpdk build. Run for the usage of the script.
Next is to set up DPDK hugepage. Our test environment is NUMA system. For single-node system please refer to the link.
Install kernel modules and bind NIC with driver. Quick start uses only one NIC, normally we use two for FNAT cluster, even four for bonding mode. For example, suppose the NIC we would use to run DPVS is eth0, in the meantime, we still keep another standalone NIC eth1 for debugging.
- An alternative to the is , which is moved to a separated repository dpdk-kmods.
- A kernel module parameter is added to since DPDK v18.11, and the default value for it is "off". We need to load with the extra parameter to make KNI devices work properly.
can be used to unbind driver and switch it back to Linux driver like . You can also use or to check the NIC PCI bus-id. Please refer to DPDK site for more details.
Notes: PMD of Mellanox NIC is built on top of libibverbs using the Raw Ethernet Accelerated Verbs AP. It doesn't rely on UIO/VFIO driver. Thus, Mellanox NICs should not bind the driver. Refer to Mellanox DPDK for details.
It's simple, just set and build it.
- Build dependencies may be needed, such as (version 0.29.2+),, , , , and . You can install the missing dependencies by using the package manager of the system, e.g., (CentOS).
- Early versions (v0.29.2 before) may cause dpvs build failure. If so, please upgrade this tool.
Output files are installed to .
- is the main program.
- is the tool to set IP address, route, vlan, neigh, etc.
- and come from LVS, both are modified.
Now, must locate at , just copy it from .
and start DPVS,
Check if it's get started ?
If you see this message. Well done, is working with NIC !
Don't worry if you see this error:
It means the NIC count of DPVS does not match . Please use to adjust the NIC number or modify . We'll improve this part to make DPVS more "clever" to avoid modify config file when NIC count does not match.
What config items does support? How to configure them? Well, maintains a config item file which lists all supported config entries and corresponding feasible values. Besides, some config sample files maintained as show the configurations of dpvs in some specified cases.
Test Full-NAT (FNAT) Load Balancer
The test topology looks like the following diagram.
Set VIP and Local IP (LIP, needed by FNAT mode) on DPVS. Let's put commands into . You do some check by , .
Access VIP from Client, it looks good!
More configure examples can be found in the Tutorial Document. Including,
- WAN-to-LAN reverse proxy.
- Direct Route () mode setup.
- Master/Backup model () setup.
- OSPF/ECMP cluster model setup.
- mode for Internet access from internal network.
- Virtual Devices (, , , /).
- module to get real UDP client IP/port in .
- ... and more ...
We also listed some frequently asked questions in the FAQ Document. It may help when you run into problems with DPVS.
Our test shows the forwarding speed (pps) of DPVS is several times than LVS and as good as Google's Maglev.
Please refer to the License file for details.
Please refer to the CONTRIBUTING file for details.
Currently, DPVS has been widely accepted by dozens of community cooperators, who have successfully used and contributed a lot to DPVS. We just list some of them alphabetically as below.
is developed by iQiYiQLB team since April 2016. It's widely used in iQiYi IDC for L4 load balancer and SNAT clusters, and we have already replaced nearly all our LVS clusters with DPVS. We open-sourced DPVS at October 2017, and are excited to see that more people can get involved in this project. Welcome to try, report issues and submit pull requests. And please feel free to contact us through Github or Email.
- email: (Please remove the white-spaces and replace with ).
Welcome to Balancer Simulations!
Balancer Simulations is a project of TE-AMM and the Token Engineering Community, funded by grants from Balancer and PowerPool, and kicked off by EthicHub.
It aims to build infrastructure and knowledge for rigorous Balancer Token Engineering to leverage the full power of Balancer Pools as a core building block in DeFi. We invite any project building on Balancer Pools to join our Discord Channel, use the model, and benefit from Balancer Simulations.
- Analyze existing Balancer Pools using on-chain transaction data, understand pool characteristics, strengths, and weaknesses
- Gain intuition by exploring pool variants, observe system behavior over time, derive the most valuable monitoring metrics for your use case
- Run experiments based on historical transactions, mix historical and synthetic transactions to model particular market scenarios
- Develop and test adaptive Dynamic AMM solutions, like Dynamic Weights Changing, test and optimize controls and feedback loops
- Model agent behavior and apply Reinforcement Learning to run stress tests for a proposed system design
All research and models are available through open source repositories, and will be further developed by TE-AMM.
For detailed information, please visit the Balancer Simulations Documentation.
This repository contains Balancer Protocol V2's core smart contract, the , along with auxiliary contracts such as the .
For a high-level introduction to Balancer V2, see Introducing Balancer V2: Generalized AMMs.
Active development occurs in this repository, which means some contracts in it may not be production-ready. Proceed with proper care.
- : source code for all smart contracts in the system.
- stores the contract, which is split across many files for separation of concerns and clarity.
- keeps the code for the different Pool types and related contracts, such as factories.
- holds contracts that are only used for testing purposes, often with lax access control patterns and other unsafe properties.
- : unit tests for each smart contract, using ethers and waffle chai matchers. The subdirectory holds utilities used to simplify writing assertions, deploying test contracts, etc., with the overall goal of making tests more ergonomic and less verbose.
- : miscellaneous files used for deployment, gas benchmarking, testing and so on.
This repository will soon be migrated into a monorepo, making the different contracts, interfaces and libraries easier to use by third parties. Stay tuned!
Multiple independent reviews and audits were performed by Certora, OpenZeppelin and Trail of Bits. The latest reports from these engagements are located in the directory.
Bug bounties apply to most of the smart contracts hosted in this repository: head to Balancer V2 Bug Bounties to learn more.
Most of the source code is licensed under the GNU General Public License Version 3 (GPL v3): see .
- All files under , are based on the OpenZeppelin Contracts library, and as such are licensed under the MIT License: see LICENSE.
- is licensed under the MIT License.
- All other files under and are unlicensed.
BigBlueButton is an open source web conferencing system for online learning.
Scalelite is an open source load balancer that manages a pool of BigBlueButton servers. It makes the pool of servers appear as a single (very scalable) BigBlueButton server. A front-end, such as Moodle or Greenlight, sends standard BigBlueButton API requests to the Scalelite server which, in turn, distributes those request to the least loaded BigBlueButton server in the pool.
A single BigBlueButton server that meets the minimum configuration supports around 200 concurrent users.
For many schools and organizations, the ability to 4 simultaneous classes of 50 users, or 8 simultaneous meetings of 25 users, is enough capacity. However, what if a school wants to support 1,500 users across 50 simultaneous classes? A single BigBlueButton server cannot handle such a load.
With Scalelite, a school can create a pool of 4 BigBlueButton servers and handle 16 simultaneous classes of 50 users. Want to scale higher, add more BigBlueButton servers to the pool.
BigBlueButton has been in development for over 10 years now. The latest release is a pure HTML5 client, with extensive documentation. There is even a BigBlueButton install script called bbb-install.sh that lets you setup a BigBlueButton server (with a Let's Encrypt certificate) in about 15 minutes. Using you can quickly setup a pool of servers for management by Scalelite.
To load balance the pool, Scalelite periodically polls each BigBlueButton to check if it is reachable online, ready to receive API requests, and to determine its current load (number of currently running meetings). With this information, when Scalelite receives an incoming API call to create a new meeting, it places the new meeting on the least loaded server in the pool. In this way, Scalelite can balance the load of meeting requests evenly across the pool.
Many BigBlueButton servers will create many recordings. Scalelite can serve a large set of recordings by consolidating them together, indexing them in a database, and, when receiving an incoming getRecordings, use the database index to return quickly the list of available recordings.
Before you begin
The Scalelite installation process requires advanced technical knowledge. You should, at a minimum, be very familar with
- Setup and administration of a BigBlueButton server
- Setup and administration of a Linux server and using common tools, such as , to manage processes on the server
- How the BigBlueButton API works with a front-end
- How docker containers work
- How UDP and TCP/IP work together
- How to administrate a Linux Firewall
- How to setup a TURN server
If you are a beginner, you will have a difficult time getting any part of this deployment correct. If you require help, see Getting Help
Architecture of Scalelite
There are several components required to get Scalelite up and running:
- Multiple BigBlueButton Servers
- Scalelite LoadBalancer Server
- NFS Shared Volume
- PostgreSQL Database
- Redis Cache
An example Scalelite deployment will look like this:
Minimum Server Requirements
For the Scalelite Server, the minimum recommended server requirements are:
For each BigBlueButton server, the minimum requirements can be found here.
For the external Postgres Database, the minimum recommended server requirements are:
- 2 CPU Cores
- 2 GB Memory
- 20 GB Disk Space (should be good for tens of thousands of recordings)
For the external Redis Cache, the minimum recommended server requirements are:
- 2 CPU Cores
- 0.5GB Memory
- Persistence must be enabled
Setup a pool of BigBlueButton Server
To setup a pool of BigBlueButton servers (minimum recommended number is 3), we recommend using bbb-install.sh as it can automate the steps to install, configure (with SSL + Let's Encrypt), and update the server when new versions of BigBlueButton are released.
To help users who are behind restrictive firewalls to send/receive media (audio, video, and screen share) to your BigBlueButton server, you should setup a TURN server and configure each BigBlueButton server to use it.
Again, bbb-install.sh can automate this process for you.
Setup a shared volume for recordings
See Setting up a shared volume for recordings
Setup up a PostgreSQL Database
Setting up a PostgreSQL Database depends heavily on the infrastructure you use to setup Scalelite. We recommend you refer to your infrastructure provider's documentation.
Ensure the that you set in (in the next step) matches the connection url of your PostgreSQL Database.
For more configuration options, see configuration.
Setup a Redis Cache
Setting up a Redis Cache depends heavily on the infrastructure you use to setup Scalelite. We recommend you refer to your infrastructure provider's documentation.
Ensure the that you set in (in the next step) matches the connection url of your Redis Cache.
For more configuration options, see configuration.
Deploying Scalelite Docker Containers
See Deploying Scalelite Docker Containers
Configure your Front-End to use Scalelite
To switch your Front-End application to use Scalelite instead of a single BigBlueButton server, there are 2 changes that need to be made
- should be set to the url of your Scalelite deployment
- should be set to the value that you set in
Layer 4 load balancer with dynamic configuration loading featuring proxy, passthrough and direct server return modes
- Stats page (at /stats) with basic connection/bytes counters and backend server pool statuses
- Dynamic configuration re-loading of backend servers and associated weights. Configuration is loaded via a .toml file (see sample.toml for a full example).
- Tcp-based health checking of backend servers at a configured interval. If a server fails its health check it will be automatically removed from selection and added back once its health checks are successful.
- Event-driven TCP load balancer built on tokio.
- Weighted round-robin load balancing. For uniform round robin simply leave out the weights or set them to be equal.
- TCP connection termination
Passthrough and Direct Server Return (DSR) Features
- Packet forwarding (no TCP termination)
- Minimal internal connection tracking
For passthrough mode we need a couple iptables rules on the convey load balancer to handle ingress packets from the client and responses from the backend load balanced servers. Since TCP is not terminating we need to ensure the OS does not send a RST in response to any packets destined for a port that does not have a process bound to it. We need to do the same for any packets came back through from a backend server. Convey internally assigns ephemeral ports 32768-61000 to map connections to clients.
For passthrough mode on the convey load balancer
For dsr mode we need the same iptables rule for ingress packets. Responses from the backend load balanced servers will be going directly to the clients. The "listening" port on the convey load balancer must match the backend load balanced servers listening ports in this mode.
For dsr mode on the convey load balancer
In dsr mode the backend servers "participate" in that their response packets must be sent directly to the client. Convey does not do any encapsulation so, for example, a gre tunnel is not an option. Instead, Traffic Control can be used as an egress nat.
For dsr mode on backend servers
No special setup neccessary
The easiest way to run tests is to run them as superuser. This is because some of the tests spin up test servers as well as a convey load balancer instance.
The branch is a WIP using AF_XDP to loadbalance in passthrough and DSR modes. For now it will be maintained in a separate branch since it requires kernel versions 5.4 or greater.
You will also like:
- Maya node
- Motorcycle lapel pin
- Locked diary book
- Boston original vinyl
- Chevy natchitoches
- Carvana camaro zl1
Ampl Elastic Configuration Rights Pool
- Extension of Balancer labs' configurable rights pool (smart-pool).
When the Ampleforth protocol adjusts supply it expects market actors to propagate this information back into price. However, un-informed AMMs like Uniswap and Balancer do this automatically as they price assets by the relative pool balances. This lets arbitrageurs extract value from liqudity providers in these platforms.
We aim to create a Balancer smart pool which mitigates this problem by adjusting pool weights proportional to rebase. This ensures that the price of Amples in the smart-pool is unaffected by rebase induced supply adjustments.
The method is invoked atomically, just after rebase from Ampleforth's Orchestrator.