Skip to content

Commit 5cf5fd9

Browse files
committed
tune nginx worker settings
1 parent 464421b commit 5cf5fd9

File tree

1 file changed

+29
-20
lines changed

1 file changed

+29
-20
lines changed

frameworks/Python/aiohttp/nginx-entrypoint.sh

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,44 @@ for i in $(seq 0 $((CORES-1))); do
1818
done
1919
done
2020

21-
# Generate Nginx configuration
22-
cat > /etc/nginx/conf.d/default.conf <<EOF
23-
keepalive_requests 10000000;
21+
cat > /aiohttp/nginx.conf <<EOF
22+
worker_processes auto;
2423
25-
upstream aiohttp {
26-
least_conn;
24+
events {
25+
worker_connections 65535;
26+
}
27+
28+
http {
29+
keepalive_requests 10000000;
30+
31+
upstream aiohttp {
32+
least_conn;
2733
EOF
34+
2835
for i in $(seq 0 $((CORES-1))); do
29-
echo " server 127.0.0.1:$((8000 + i));" >> /etc/nginx/conf.d/default.conf
36+
echo " server 127.0.0.1:$((8000 + i));" >> /aiohttp/nginx.conf
3037
done
31-
cat >> /etc/nginx/conf.d/default.conf <<EOF
32-
keepalive 32;
33-
}
3438

35-
server {
36-
listen 8080;
39+
cat >> /aiohttp/nginx.conf <<EOF
40+
keepalive 32;
41+
}
42+
43+
server {
44+
listen 8080 reuseport;
3745
38-
access_log off;
39-
error_log stderr error;
46+
access_log off;
47+
error_log stderr error;
4048
41-
location / {
42-
proxy_pass http://aiohttp;
43-
proxy_http_version 1.1;
44-
proxy_set_header Connection "";
45-
proxy_redirect off;
46-
proxy_buffering off;
49+
location / {
50+
proxy_pass http://aiohttp;
51+
proxy_http_version 1.1;
52+
proxy_set_header Connection "";
53+
proxy_redirect off;
54+
proxy_buffering off;
55+
}
4756
}
4857
}
4958
EOF
5059

5160
echo "Starting Nginx..."
52-
nginx -g "daemon off;"
61+
nginx -c /aiohttp/nginx.conf -g "daemon off;"

0 commit comments

Comments
 (0)