Skip to content

Commit

Permalink
Fix ram in prod (#280)
Browse files Browse the repository at this point in the history
* fix: 🐛 reserve 256M for the API and nginx pods

The API service seems to need about 52M:

```
process_virtual_memory_bytes 7.59681024e+08
process_resident_memory_bytes 5.2195328e+07
```

* fix: 🐛 remove the PrometheusMiddleware to reduce the RAM usage

Hopefully it fixes
#279. See
tiangolo/fastapi#4041
  • Loading branch information
severo committed May 17, 2022
1 parent 2254754 commit 443f00f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 24 deletions.
4 changes: 4 additions & 0 deletions infra/charts/datasets-server/env/prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ reverseProxy:
resources:
requests:
cpu: 1
memory: "256Mi"
limits:
cpu: 1
memory: "256Mi"

api:
replicas: 2
Expand All @@ -65,8 +67,10 @@ api:
resources:
requests:
cpu: 1
memory: "256Mi"
limits:
cpu: 1
memory: "256Mi"

datasetsWorker:
replicas: 3
Expand Down
26 changes: 5 additions & 21 deletions services/api/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ huggingface-hub = "^0.5.1"
libcache = { path = "../../libs/libcache", develop = true }
libqueue = { path = "../../libs/libqueue", develop = true }
libutils = { path = "../../libs/libutils", develop = true }
prometheus-client = "^0.14.1"
python = "3.9.6"
python-dotenv = "^0.20.0"
starlette = "^0.16.0"
starlette-prometheus = "^0.9.0"
uvicorn = "^0.14.0"
watchdog = { extras = ["watchmedo"], version = "^2.1.3" }

Expand Down
3 changes: 1 addition & 2 deletions services/api/src/api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from starlette.middleware.gzip import GZipMiddleware
from starlette.routing import Mount, Route
from starlette.staticfiles import StaticFiles
from starlette_prometheus import PrometheusMiddleware

from api.config import (
APP_HOSTNAME,
Expand Down Expand Up @@ -45,7 +44,7 @@ def create_app() -> Starlette:
show_assets_dir(ASSETS_DIRECTORY)
prometheus = Prometheus()

middleware = [Middleware(GZipMiddleware), Middleware(PrometheusMiddleware, filter_unhandled_paths=True)]
middleware = [Middleware(GZipMiddleware)]
routes = [
Mount("/assets", app=StaticFiles(directory=init_assets_dir(ASSETS_DIRECTORY), check_dir=True), name="assets"),
Route("/cache-reports", endpoint=cache_reports_endpoint),
Expand Down

0 comments on commit 443f00f

Please sign in to comment.