Skip to content

Commit

Permalink
update OS and python
Browse files Browse the repository at this point in the history
  • Loading branch information
djstrong committed Jan 22, 2024
1 parent cda2709 commit 52976c2
Show file tree
Hide file tree
Showing 4 changed files with 208 additions and 28 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
- name: Install poetry
run: pipx install poetry

- name: Set up Python 3.10.5
- name: Set up Python 3.11.7
uses: actions/setup-python@v4
with:
python-version: 3.10.5
python-version: 3.11.7
cache: 'poetry'

- name: Install dependencies
Expand Down
14 changes: 12 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
# syntax=docker/dockerfile:1

FROM python:3.10.5-slim-buster as prepare
FROM python:3.11.7-slim-bookworm as prepare

WORKDIR /app

RUN pip install poetry && \
poetry config virtualenvs.create false

RUN apt-get update && \
apt-get install -y gcc && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

COPY poetry.lock pyproject.toml ./
RUN poetry install --only main --no-root --no-interaction --no-ansi
RUN poetry export -f requirements.txt -o requirements.txt
Expand All @@ -22,10 +27,15 @@ COPY conf/ conf
RUN python3 generator/download_from_s3.py


FROM python:3.10.5-slim-buster as app
FROM python:3.11.7-slim-bookworm as app

WORKDIR /app

RUN apt-get update && \
apt-get install -y gcc && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

COPY --from=prepare /app/requirements.txt ./
RUN pip3 install --no-cache-dir -r requirements.txt

Expand Down
28 changes: 4 additions & 24 deletions tests/load_tests/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Tests are made from NameGenerator docker container and logs are saved in `report
apt update
apt install vim htop
pip3 install locust
cd tests/load_tests
bash run_tests.sh > log 2>&1
```

Expand All @@ -53,26 +53,6 @@ Conclusions:
- with 4 vCPU (8 workers) and 11GB RAM we can serve 1383 requests for 6 parallel users in 1 minute with avg time 247 ms (23 req/s)
- with 2 vCPU (8 workers) and 11GB RAM we can serve 951 requests for 4 parallel users in 1 minute with avg time 243 ms (16 req/s)
- with 2 vCPU (4 workers) and 8GB RAM we can serve 906 requests for 4 parallel users in 1 minute with avg time 255 ms (15 req/s)


apt update
apt install vim htop
pip3 install locust
vim run_tests.sh
vim locust_suggestions_by_category.py


bash run_tests.sh > log 2>&1



poetry run gunicorn web_api:app --workers 1 --worker-class uvicorn.workers.UvicornWorker --timeout 120

Memory worker (VIRT, RES):
- uvicorn 1: 5,5GB 4GB 14.8-11=3.8 GB
- uvicorn 2: 2x 5,5GB 4GB 18.7-11=7.7 GB
- gunicorn 1 worker sync: 15.1-11.3=3.8 GB
- gunicorn 2 worker sync: 19.1-11.4=7.7 GB
- gunicorn 2 worker uvicorn with preload: 15.6-11.7 = 3.9 GB
- gunicorn 4 worker uvicorn with preload: 4 GB - error?
- gunicorn 8 worker uvicorn with preload: 11 GB
- threadpool is better than async for mall number of users
- 1 user: 335 req/m, avg 177 ms vs 282 req/m, avg 207 ms
- 32 users: 1146 req/m, avg 1207 ms vs 1277 req/m, avg 1086 ms
Loading

0 comments on commit 52976c2

Please sign in to comment.