Skip to content

Commit b7c2f18

Browse files
committed
perf: Use Granian as app server
Much more performant and secure, made in Rust.
1 parent 1fcbdec commit b7c2f18

File tree

4 files changed

+49
-102
lines changed

4 files changed

+49
-102
lines changed

Makefile

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,15 @@ tunnel:
107107
devtunnel host $(tunnel_name)
108108

109109
dev:
110-
VERSION=$(version_full) PUBLIC_DOMAIN=$(tunnel_url) uv run gunicorn app.main:api \
111-
--access-logfile - \
112-
--bind 0.0.0.0:8080 \
113-
--graceful-timeout 60 \
114-
--proxy-protocol \
110+
VERSION=$(version_full) PUBLIC_DOMAIN=$(tunnel_url) uv run granian \
111+
--host 0.0.0.0 \
112+
--interface asgi \
113+
--log-level info \
114+
--port 8080 \
115115
--reload \
116-
--reload-extra-file .env \
117-
--reload-extra-file config.yaml \
118-
--timeout 60 \
119-
--worker-class uvicorn.workers.UvicornWorker \
120-
--workers 2
116+
--workers 2 \
117+
--workers-kill-timeout 60 \
118+
app.main:api
121119

122120
build:
123121
DOCKER_BUILDKIT=1 docker build \

cicd/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ ARG VERSION
3333
ENV VERSION=${VERSION}
3434

3535
# Starting the backend
36-
CMD gunicorn app.main:api --bind 0.0.0.0:8080 --graceful-timeout 60 --proxy-protocol --timeout 60 --worker-class uvicorn.workers.UvicornWorker --workers 4
36+
CMD ["granian", "--interface", "asgi", "--host", "0.0.0.0", "--port", "8080", "--log-level", "critical", "--workers-kill-timeout", "60", "--workers", "4", "app.main:api"]

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ dependencies = [
2323
"azure-storage-queue~=12.12", # Azure Storage Queue
2424
"django-htmlmin~=0.11", # Minify HTML
2525
"fastapi~=0.115", # Web framework
26-
"gunicorn~=23.0", # Application server
26+
"granian~=2.3", # Application server
2727
"jinja2~=3.1", # Template engine, used for prompts and web views
2828
"json-repair~=0.30", # Repair JSON files from LLM
2929
"mistune~=3.0", # Markdown parser for web views
@@ -46,13 +46,13 @@ dependencies = [
4646
"tiktoken~=0.8", # Tokenization library for OpenAI models
4747
"twilio~=9.3", # Twilio SDK, used for SMS
4848
"typing-extensions~=4.12", # Typing extensions for Python 3.6+
49-
"uvicorn[standard]~=0.32", # Application middleware
5049
]
5150

5251
[project.optional-dependencies]
5352
dev = [
5453
"deepeval~=0.21", # LLM model evaluation
5554
"deptry~=0.20", # Dependency tree testing
55+
"granian[reload]", # Granian with reload support for development
5656
"pyright~=1.1", # Static type checker
5757
"pytest-assume~=2.4", # Pytest plugin for conditional tests
5858
"pytest-asyncio~=0.24", # Pytest plugin for async tests

0 commit comments

Comments
 (0)