Skip to content

Commit 0f39fb5

Browse files
committed
use nginx as default aiohttp server
1 parent 355cd28 commit 0f39fb5

File tree

8 files changed

+48
-38
lines changed

8 files changed

+48
-38
lines changed

frameworks/Python/aiohttp/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ This will switch which database engine the app uses to execute queries with test
3535

3636
### Server
3737

38-
gunicorn+uvloop on CPython
38+
nginx+uvloop on CPython
3939

4040
## Test URLs
4141

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM python:3.13
2+
3+
ADD ./ /aiohttp
4+
5+
WORKDIR aiohttp
6+
7+
RUN pip3 install cython==3.0.11 && \
8+
pip3 install -r /aiohttp/requirements.txt
9+
10+
ENV CONNECTION=RAW
11+
12+
EXPOSE 8080
13+
14+
CMD python3 -O -m gunicorn app.gunicorn:app -c gunicorn_conf.py

frameworks/Python/aiohttp/aiohttp-nginx.dockerfile

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
FROM python:3.13
22

3-
ADD ./ /aiohttp
3+
RUN apt-get update && apt-get install -y nginx
44

5-
WORKDIR aiohttp
5+
ADD ./requirements.txt /aiohttp/requirements.txt
66

77
RUN pip3 install cython==3.0.11 && \
88
pip3 install -r /aiohttp/requirements.txt
99

10+
ADD ./ /aiohttp
11+
12+
WORKDIR /aiohttp
13+
14+
ENV CONNECTION=ORM
15+
1016
EXPOSE 8080
1117

12-
CMD python3 -O -m gunicorn app.gunicorn:app -c gunicorn_conf.py
18+
RUN chmod +x /aiohttp/nginx-entrypoint.sh
19+
20+
ENTRYPOINT ["/aiohttp/nginx-entrypoint.sh"]
21+
22+
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
FROM python:3.13
22

3-
ADD ./ /aiohttp
3+
RUN apt-get update && apt-get install -y nginx
44

5-
WORKDIR aiohttp
5+
ADD ./requirements.txt /aiohttp/requirements.txt
66

77
RUN pip3 install cython==3.0.11 && \
88
pip3 install -r /aiohttp/requirements.txt
99

10+
ADD ./ /aiohttp
11+
12+
WORKDIR /aiohttp
13+
1014
ENV CONNECTION=RAW
1115

1216
EXPOSE 8080
1317

14-
CMD python3 -O -m gunicorn app.gunicorn:app -c gunicorn_conf.py
18+
RUN chmod +x /aiohttp/nginx-entrypoint.sh
19+
20+
ENTRYPOINT ["/aiohttp/nginx-entrypoint.sh"]

frameworks/Python/aiohttp/benchmark_config.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
"flavor": "Python3",
1818
"orm": "Raw",
1919
"platform": "asyncio",
20-
"webserver": "gunicorn",
20+
"webserver": "nginx",
2121
"os": "Linux",
2222
"database_os": "Linux",
2323
"display_name": "aiohttp",
2424
"notes": "uses asyncpg for database access"
2525
},
26-
"nginx": {
26+
"gunicorn": {
2727
"json_url": "/json",
2828
"db_url": "/db",
2929
"query_url": "/queries/",
@@ -42,8 +42,8 @@
4242
"webserver": "nginx",
4343
"os": "Linux",
4444
"database_os": "Linux",
45-
"display_name": "aiohttp-nginx",
46-
"notes": "uses nginx as proxy server",
45+
"display_name": "aiohttp-gunicorn",
46+
"notes": "uses gunicorn as proxy server",
4747
"versus": "default"
4848
},
4949
"orm": {
@@ -60,7 +60,7 @@
6060
"flavor": "Python3",
6161
"orm": "Full",
6262
"platform": "asyncio",
63-
"webserver": "gunicorn",
63+
"webserver": "nginx",
6464
"os": "Linux",
6565
"database_os": "Linux",
6666
"display_name": "aiohttp-orm",

frameworks/Python/aiohttp/config.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ database_os = "Linux"
1515
os = "Linux"
1616
orm = "Raw"
1717
platform = "asyncio"
18-
webserver = "gunicorn"
18+
webserver = "nginx"
1919
versus = "None"
2020

21-
[nginx]
21+
[gunicorn]
2222
urls.plaintext = "/plaintext"
2323
urls.json = "/json"
2424
urls.db = "/db"
@@ -32,8 +32,8 @@ database_os = "Linux"
3232
os = "Linux"
3333
orm = "Raw"
3434
platform = "asyncio"
35-
webserver = "nginx"
36-
versus = "None"
35+
webserver = "gunicorn"
36+
versus = "default"
3737

3838
[orm]
3939
urls.db = "/db"
@@ -47,5 +47,5 @@ database_os = "Linux"
4747
os = "Linux"
4848
orm = "Full"
4949
platform = "asyncio"
50-
webserver = "gunicorn"
50+
webserver = "nginx"
5151
versus = "default"

frameworks/Python/aiohttp/nginx-entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ for i in $(seq 0 $((CORES-1))); do
1414
SOCKET="/run/aiohttp-$i.sock"
1515
until [ -S "$SOCKET" ]; do
1616
echo "Waiting for socket $SOCKET..."
17-
sleep 0.1
17+
sleep 0.2
1818
done
1919
chown root:www-data "$SOCKET"
2020
chmod 660 "$SOCKET"

0 commit comments

Comments
 (0)