Skip to content

Dynamic Load Balancing demo for introducing OpenResty.

License

Notifications You must be signed in to change notification settings

Triple-Z/dlb-demo

Repository files navigation

DLB Demo

Dynamic Load Balancing demo for introducing OpenResty.

First used in #18 A2OS Weekly.

Table of Contents

Quickstart

$ git clone https://github.com/Triple-Z/dlb-demo
$ cd dlb-demo/
$ docker-compose up

Then visit the http://localhost:8888 continuously, you will find out the response content number is changing all the time :P

Or use for i in {1..10} ; do curl http://localhost:8888 ; done instead.

Example Results

Backend server configs:

servers = {
    {
        host = "172.28.0.101",
        port = 80,
        weight = 5, -- backend 1
    },
    {
        host = "172.28.0.102",
        port = 80,
        weight = 3, -- backend 2
    },
    {
        host = "172.28.0.103",
        port = 80,
        weight = 2, -- backend 3
    },
}

Results:

# Round-robin (rr)
$ for i in {1..10} ; do curl http://localhost:8888 ; done
response from backend 1
response from backend 2
response from backend 3
response from backend 1
response from backend 2
response from backend 3
response from backend 1
response from backend 2
response from backend 3
response from backend 1

# Weighted round-robin (wrr)
$ for i in {1..10} ; do curl http://localhost:8888 ; done
response from backend 1
response from backend 1
response from backend 1
response from backend 1
response from backend 1
response from backend 2
response from backend 2
response from backend 2
response from backend 3
response from backend 3

# Smooth weighted round-robin (swrr)
$ for i in {1..10} ; do curl http://localhost:8888 ; done
response from backend 1
response from backend 2
response from backend 3
response from backend 1
response from backend 1
response from backend 2
response from backend 1
response from backend 3
response from backend 2
response from backend 1

TODO

  • Round-robin
  • weighted round-robin
  • smooth weighted round-robin
  • Health check
  • IP hash
  • consistency hash

Copyright

Copyright © 2020 Triple-Z

This project is open sourced by MIT License.

About

Dynamic Load Balancing demo for introducing OpenResty.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages