Skip to content

Commit 794e049

Browse files
committed
♻️(tray) split websocket and asgi apps in tray
We have detected a memory leak in the websocket application. An issue exists on the django channels github repo about this topic. We also detected that this memory leak can have side effect on the asgi application, the application can become slower leading to timeout. To remove this side effect we decided to create a deploy dedicated to the websocket application and nginx is reponsible to use the right backend based on the request path. django/channels#2094
1 parent 8161193 commit 794e049

File tree

5 files changed

+67
-1
lines changed

5 files changed

+67
-1
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ Versioning](https://semver.org/spec/v2.0.0.html).
1212

1313
- Add peertube transcript generation
1414

15+
### Changed
16+
17+
- Split websocket and asgi apps in tray
18+
1519
### Fixed
1620

1721
- Allow to change username if one is persisted on classroom join
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{% set service_variant = "ws" %}
2+
{% set marsha_replicas = marsha_ws_replicas %}
3+
{% set marsha_livenessprobe = {
4+
"httpGet": {
5+
"path": "/__heartbeat__",
6+
"port": "django-port",
7+
"httpHeaders": [{
8+
"name": "Host",
9+
"value": marsha_hosts[0],
10+
}],
11+
},
12+
"initialDelaySeconds": 60,
13+
"periodSeconds": 30 ,
14+
} %}
15+
{% set marsha_readynessprobe = {
16+
"httpGet": {
17+
"path": "/__lbheartbeat__",
18+
"port": "django-port",
19+
"httpHeaders": [{
20+
"name": "Host",
21+
"value": marsha_hosts[0],
22+
}],
23+
},
24+
"initialDelaySeconds": 10,
25+
"periodSeconds": 5,
26+
} %}
27+
{% set marsha_resources = marsha_ws_resources %}
28+
29+
{% include "./_deploy_base.yml.j2" with context %}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
labels:
5+
app: marsha
6+
service: ws
7+
version: "{{ marsha_image_tag }}"
8+
deployment_stamp: "{{ deployment_stamp }}"
9+
name: marsha-ws-{{ deployment_stamp }} # name of the service should be host name in nginx
10+
namespace: "{{ namespace_name }}"
11+
spec:
12+
ports:
13+
- name: {{ marsha_django_port }}-tcp
14+
port: {{ marsha_django_port }}
15+
protocol: TCP
16+
targetPort: {{ marsha_django_port }}
17+
selector:
18+
app: marsha
19+
deployment: "marsha-ws-{{ deployment_stamp }}"
20+
type: ClusterIP

src/tray/templates/services/nginx/configs/marsha.conf.j2

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ upstream marsha-backend {
44
server marsha-app-{{ deployment_stamp }}:{{ marsha_django_port }} fail_timeout=0;
55
}
66

7+
upstream marsha-ws {
8+
server marsha-ws-{{ deployment_stamp }}:{{ marsha_django_port }} fail_timeout=0;
9+
}
10+
711
upstream marsha-xapi {
812
server marsha-xapi-{{ deployment_stamp }}:{{ marsha_django_port }} fail_timeout=0;
913
}
@@ -62,7 +66,7 @@ server {
6266
}
6367

6468
location /ws/ {
65-
proxy_pass http://marsha-backend;
69+
proxy_pass http://marsha-ws;
6670

6771
proxy_http_version 1.1;
6872
proxy_set_header Connection "Upgrade";

src/tray/vars/all/main.yml

+9
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ marsha_image_name: "fundocker/marsha"
3333
marsha_image_tag: "3.23.0"
3434
marsha_django_port: 8000
3535
marsha_app_replicas: 1
36+
marsha_ws_replicas: 1
3637
marsha_xapi_replicas: 1
3738
marsha_celery_replicas: 1
3839
marsha_django_configuration: "Development"
@@ -123,6 +124,14 @@ marsha_app_resources:
123124
cpu: 0.8
124125
memory: 1Gi
125126

127+
marsha_ws_resources:
128+
requests:
129+
cpu: 0.3
130+
memory: 500Mi
131+
limits:
132+
cpu: 0.8
133+
memory: 1Gi
134+
126135
marsha_xapi_resources:
127136
requests:
128137
cpu: 0.3

0 commit comments

Comments
 (0)