Skip to content

Commit bf8082b

Browse files
authored
balancer: let balancer containers scale when using docker compose (#1431)
* balancer: let balancer containers scale when using docker compose * adjust response parsing
1 parent a1336db commit bf8082b

File tree

3 files changed

+58
-8
lines changed

3 files changed

+58
-8
lines changed

docker/nginx.conf

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# This configuration is specifically for testing in a development environment.
2+
# It is not suitable for production use.
3+
4+
worker_processes auto;
5+
6+
events {
7+
worker_connections 2048;
8+
multi_accept on;
9+
}
10+
11+
http {
12+
map $http_upgrade $connection_upgrade {
13+
default upgrade;
14+
'' close;
15+
}
16+
17+
server {
18+
listen 80 default_server;
19+
http2 on;
20+
21+
location / {
22+
proxy_pass http://balancer:8081;
23+
proxy_http_version 1.1;
24+
proxy_set_header Upgrade $http_upgrade;
25+
proxy_set_header Connection "upgrade";
26+
proxy_set_header Host $host;
27+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
28+
proxy_set_header X-Forwarded-Proto $scheme;
29+
proxy_set_header X-Forwarded-Host $host;
30+
proxy_cache_bypass $http_upgrade;
31+
proxy_pass_header Set-Cookie;
32+
33+
proxy_connect_timeout 7d;
34+
proxy_read_timeout 7d;
35+
proxy_send_timeout 7d;
36+
37+
proxy_socket_keepalive on;
38+
}
39+
}
40+
}
41+

docker/with-balancer.docker-compose.yml

+8-4
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ services:
3737
dockerfile: deploy/balancer.Dockerfile
3838
args:
3939
- DEPLOY_TARGET=ott-balancer-docker
40-
ports:
41-
- 8080:8081
4240
restart: "${DOCKER_RESTART_POLICY:-unless-stopped}"
4341

4442
collector:
@@ -48,8 +46,6 @@ services:
4846
dockerfile: deploy/collector.Dockerfile
4947
args:
5048
- DEPLOY_TARGET=ott-collector-docker
51-
links:
52-
- balancer
5349
ports:
5450
- 8000:8000
5551
restart: "${DOCKER_RESTART_POLICY:-unless-stopped}"
@@ -81,6 +77,14 @@ services:
8177
- db-data-postgres:/var/lib/postgresql/data
8278
restart: "${DOCKER_RESTART_POLICY:-unless-stopped}"
8379

80+
nginx:
81+
image: nginx:alpine
82+
volumes:
83+
- ./nginx.conf:/etc/nginx/nginx.conf
84+
ports:
85+
- 8080:80
86+
restart: "${DOCKER_RESTART_POLICY:-unless-stopped}"
87+
8488
# shared volume
8589
volumes:
8690
db-data-redis:

tests/load/utils.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,16 @@ export function createRoom(name, token, roomOptions = {}, options = { doCheck: t
6565
if (r.status === 201) {
6666
return true;
6767
}
68-
let body = JSON.parse(r.body);
69-
if (body.error && body.error.name === "RoomNameTakenException") {
70-
return true;
68+
try {
69+
let body = JSON.parse(r.body);
70+
if (body.error && body.error.name === "RoomNameTakenException") {
71+
return true;
72+
}
73+
return false;
74+
} catch (e) {
75+
console.log(`Failed to parse response body as json: ${r.body}`);
76+
return false;
7177
}
72-
return false;
7378
},
7479
});
7580
}

0 commit comments

Comments
 (0)