dlb demo
1.0.0
توازن موازنة التحميل الديناميكي لتقديم OpenResty.
المستخدمة لأول مرة في #18 A2OS أسبوعي.
$ git clone https://github.com/Triple-Z/dlb-demo
$ cd dlb-demo/
$ docker-compose upثم تفضل بزيارة http: // localhost: 8888 بشكل مستمر ، ستكتشف أن رقم محتوى الاستجابة يتغير طوال الوقت: p
أو استخدمها
for i in {1..10} ; do curl http://localhost:8888 ; doneبدلا من ذلك.
يتكوين خادم الخلفية:
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
},
}نتائج:
# 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حقوق الطبع والنشر © 2020 Triple-Z
هذا المشروع مفتوح مصدره ترخيص معهد ماساتشوستس للتكنولوجيا.