From 223a723300030bd768b2d9691d5f282ff969eb2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eugene=20=E2=80=9CAeron=E2=80=9D=20Glybin?= Date: Tue, 14 Nov 2023 20:13:47 +0100 Subject: [PATCH 1/2] [Python] Add FastAPI-Granian tests --- .../Python/fastapi/benchmark_config.json | 48 ++++++++++++++++++- .../fastapi/fastapi-granian-orjson.dockerfile | 26 ++++++++++ .../Python/fastapi/fastapi-granian.dockerfile | 25 ++++++++++ .../Python/fastapi/requirements-granian.txt | 1 + 4 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 frameworks/Python/fastapi/fastapi-granian-orjson.dockerfile create mode 100644 frameworks/Python/fastapi/fastapi-granian.dockerfile create mode 100644 frameworks/Python/fastapi/requirements-granian.txt diff --git a/frameworks/Python/fastapi/benchmark_config.json b/frameworks/Python/fastapi/benchmark_config.json index 6fbceb1f0ae..4aeab060aa4 100755 --- a/frameworks/Python/fastapi/benchmark_config.json +++ b/frameworks/Python/fastapi/benchmark_config.json @@ -1,6 +1,7 @@ { "framework": "fastapi", - "tests": [{ + "tests": [ + { "default": { "json_url": "/json", "fortune_url": "/fortunes", @@ -237,6 +238,49 @@ "display_name": "FastAPI-uvicorn-orjson", "notes": "", "versus": "None" + }, + "granian": { + "json_url": "/json", + "db_url": "/db", + "query_url": "/queries?queries=", + "update_url": "/updates?queries=", + "port": 8080, + "approach": "Realistic", + "classification": "Micro", + "database": "Postgres", + "framework": "FastAPI", + "language": "Python", + "flavor": "Python3", + "orm": "Raw", + "platform": "asyncio", + "webserver": "Granian", + "os": "Linux", + "database_os": "Linux", + "display_name": "FastAPI-granian", + "notes": "", + "versus": "None" + }, + "granian-orjson": { + "json_url": "/json", + "db_url": "/db", + "query_url": "/queries?queries=", + "update_url": "/updates?queries=", + "port": 8080, + "approach": "Realistic", + "classification": "Micro", + "database": "Postgres", + "framework": "FastAPI", + "language": "Python", + "flavor": "Python3", + "orm": "Raw", + "platform": "asyncio", + "webserver": "Granian", + "os": "Linux", + "database_os": "Linux", + "display_name": "FastAPI-granian-orjson", + "notes": "", + "versus": "None" } - }] + } + ] } diff --git a/frameworks/Python/fastapi/fastapi-granian-orjson.dockerfile b/frameworks/Python/fastapi/fastapi-granian-orjson.dockerfile new file mode 100644 index 00000000000..b6d210bb32d --- /dev/null +++ b/frameworks/Python/fastapi/fastapi-granian-orjson.dockerfile @@ -0,0 +1,26 @@ +FROM python:3.11 + +WORKDIR /fastapi + +RUN python -m venv /opt/venv +ENV PATH="/opt/venv/bin:$PATH" + +COPY requirements.txt requirements-granian.txt requirements-orjson.txt ./ + +RUN pip3 install \ + -r requirements.txt \ + -r requirements-granian.txt \ + -r requirements-orjson.txt + +COPY . ./ + +EXPOSE 8080 + +CMD granian \ + --host=0.0.0.0 \ + --port=8080 \ + --interface=asgi \ + --loop=uvloop \ + --workers=$(nproc) \ + --log-level=error \ + app:app diff --git a/frameworks/Python/fastapi/fastapi-granian.dockerfile b/frameworks/Python/fastapi/fastapi-granian.dockerfile new file mode 100644 index 00000000000..53427123b78 --- /dev/null +++ b/frameworks/Python/fastapi/fastapi-granian.dockerfile @@ -0,0 +1,25 @@ +FROM python:3.11 + +WORKDIR /fastapi + +RUN python -m venv /opt/venv +ENV PATH="/opt/venv/bin:$PATH" + +COPY requirements.txt requirements-granian.txt ./ + +RUN pip3 install \ + -r requirements.txt \ + -r requirements-granian.txt + +COPY . ./ + +EXPOSE 8080 + +CMD granian \ + --host=0.0.0.0 \ + --port=8080 \ + --interface=asgi \ + --loop=uvloop \ + --workers=$(nproc) \ + --log-level=error \ + app:app diff --git a/frameworks/Python/fastapi/requirements-granian.txt b/frameworks/Python/fastapi/requirements-granian.txt new file mode 100644 index 00000000000..8ca60d3ace0 --- /dev/null +++ b/frameworks/Python/fastapi/requirements-granian.txt @@ -0,0 +1 @@ +granian==0.7.1 From 550dfd822e9b2af0f98ff9a7df8e3de23aa0d2d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eugene=20=E2=80=9CAeron=E2=80=9D=20Glybin?= Date: Tue, 14 Nov 2023 21:33:18 +0100 Subject: [PATCH 2/2] [Python] Update FastAPI-Granian tests Add fortune URL to the `granian` test. --- frameworks/Python/fastapi/benchmark_config.json | 1 + 1 file changed, 1 insertion(+) diff --git a/frameworks/Python/fastapi/benchmark_config.json b/frameworks/Python/fastapi/benchmark_config.json index 4aeab060aa4..0f51898981a 100755 --- a/frameworks/Python/fastapi/benchmark_config.json +++ b/frameworks/Python/fastapi/benchmark_config.json @@ -241,6 +241,7 @@ }, "granian": { "json_url": "/json", + "fortune_url": "/fortunes", "db_url": "/db", "query_url": "/queries?queries=", "update_url": "/updates?queries=",