Skip to content

Commit 7341e2e

Browse files
authored
Increase number of workers and configure resources (#121)
* parameterise uvicorn workers * configure resources and replicas * Fix tox config
1 parent 6bcbeb2 commit 7341e2e

File tree

5 files changed

+41
-12
lines changed

5 files changed

+41
-12
lines changed

helm/daq-config-server/templates/deployment.yaml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,20 @@ spec:
7373
nodeSelector:
7474
{{- toYaml . | nindent 8 }}
7575
{{- end }}
76-
{{- with .Values.affinity }}
7776
affinity:
78-
{{- toYaml . | nindent 8 }}
79-
{{- end }}
77+
podAntiAffinity:
78+
requiredDuringSchedulingIgnoredDuringExecution:
79+
- labelSelector:
80+
matchExpressions:
81+
- key: app.kubernetes.io/name
82+
operator: In
83+
values:
84+
- daq-config-server
85+
- key: app.kubernetes.io/instance
86+
operator: In
87+
values:
88+
- {{ .Release.Name }}
89+
topologyKey: "kubernetes.io/hostname"
8090
{{- with .Values.tolerations }}
8191
tolerations:
8292
{{- toYaml . | nindent 8 }}

helm/daq-config-server/values.yaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
replicaCount: 1
1+
replicaCount: 2
22

33
image:
44
repository: ghcr.io/diamondlightsource/daq-config-server
@@ -37,7 +37,13 @@ ingress:
3737
hosts:
3838
- daq-config.diamond.ac.uk
3939

40-
resources: {}
40+
resources:
41+
limits:
42+
cpu: 1
43+
memory: 2Gi
44+
requests:
45+
cpu: 500m
46+
memory: 1Gi
4147

4248
livenessProbe:
4349
httpGet:
@@ -50,6 +56,8 @@ readinessProbe:
5056

5157
# Send logs to the dodal graylog stream for now until a more suitable stream exists
5258
config:
59+
uvicorn_config:
60+
workers: 2
5361
logging_config:
5462
graylog:
5563
enabled: true
@@ -63,4 +71,3 @@ volumeMounts: []
6371
volumes: []
6472
nodeSelector: {}
6573
tolerations: []
66-
affinity: {}

pyproject.toml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ readme = "README.md"
1818
requires-python = ">=3.11"
1919

2020
dependencies = [
21-
"pyyaml",
21+
"pyyaml",
2222
"fastapi",
2323
"uvicorn",
24-
"redis",
24+
"redis",
2525
"hiredis",
2626
"cachetools",
2727
"graypy",
@@ -78,8 +78,10 @@ markers = """
7878
"""
7979

8080
# https://iscinumpy.gitlab.io/post/bound-version-constraints/#watch-for-warnings
81-
filterwarnings = ["error",
82-
"ignore:Exception ignored in.*sqlite3.Connection:pytest.PytestUnraisableExceptionWarning"] #See https://github.com/pytest-dev/pytest-cov/issues/694
81+
filterwarnings = [
82+
"error",
83+
"ignore:Exception ignored in.*sqlite3.Connection:pytest.PytestUnraisableExceptionWarning",
84+
] #See https://github.com/pytest-dev/pytest-cov/issues/694
8385

8486
# Doctest python code in docs, python code in src docstrings, test functions in tests
8587
testpaths = "docs src tests"
@@ -98,7 +100,7 @@ legacy_tox_ini = """
98100
[tox]
99101
skipsdist=True
100102
101-
[testenv:{pre-commit,type-checking,unit_tests,docs}]
103+
[testenv:{pre-commit,type-checking,unit_tests,docs,system_tests}]
102104
# Don't create a virtualenv for the command, requires tox-direct plugin
103105
direct = True
104106
passenv = *

src/daq_config_server/app.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,4 +177,9 @@ def main():
177177

178178
set_up_logging(config.logging_config)
179179

180-
uvicorn.run(app="daq_config_server.app:app", host="0.0.0.0", port=8555)
180+
uvicorn.run(
181+
app="daq_config_server.app:app",
182+
host="0.0.0.0",
183+
port=8555,
184+
workers=config.uvicorn_config.workers,
185+
)

src/daq_config_server/config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,10 @@ class LoggingConfig(BaseModel):
2121
stream_log: StreamLogConfig = StreamLogConfig()
2222

2323

24+
class UvicornConfig(BaseModel):
25+
workers: int = 2
26+
27+
2428
class Config(BaseModel):
2529
logging_config: LoggingConfig = LoggingConfig()
30+
uvicorn_config: UvicornConfig = UvicornConfig()

0 commit comments

Comments
 (0)