Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimisation suggestions for nginx #5798

Open
wants to merge 4 commits into
base: next
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 78 additions & 6 deletions bin/config/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
user www-data;
worker_processes 4;
worker_processes auto; # Changed to auto to match CPU cores
worker_cpu_affinity auto;
worker_rlimit_nofile 40000;
pid /var/run/nginx.pid;

events {
worker_connections 20000;
# multi_accept on;
use epoll;
multi_accept on; # Added multi_accept with accept_mutex off and epoll
accept_mutex off;
}

http {
Expand All @@ -23,6 +26,21 @@ http {
server_tokens off;
proxy_pass_header Server;

# Proxy buffering settings
proxy_request_buffering off; # Optimization for large buffers`
proxy_buffering on; # Enable buffering for responses for throughput optimization
proxy_buffer_size 16k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;


# Sets the HTTP protocol version for proxying. By default, version 1.0 is used. Version 1.1 is recommended for use with keepalive connections
proxy_http_version 1.1;
proxy_set_header Connection "";

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

Expand All @@ -34,7 +52,36 @@ http {
##

access_log off;
error_log /var/log/nginx/error.log;
error_log /var/log/nginx/error.log error; # Added log level

##
# Brotli Settings
##

brotli on;
brotli_comp_level 6;
brotli_static on;
brotli_min_length 256;
brotli_types
application/javascript
application/json
application/vnd.ms-fontobject
application/x-font-opentype
application/x-font-truetype
application/x-font-ttf
application/x-javascript
font/eot
font/opentype
font/otf
font/truetype
image/svg+xml
image/vnd.microsoft.icon
image/x-icon
image/x-win-bitmap
text/css
text/javascript
text/plain
text/xml;

##
# Gzip Settings
Expand All @@ -46,9 +93,34 @@ http {
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_min_length 256; # Added minimum length
gzip_types
application/atom+xml
application/javascript
application/json
application/vnd.ms-fontobject
application/x-font-opentype
application/x-font-truetype
application/x-font-ttf
application/x-javascript
application/xml
font/eot
font/opentype
font/otf
font/truetype
image/svg+xml
image/vnd.microsoft.icon
image/x-icon
image/x-win-bitmap
text/css
text/javascript
text/plain
text/xml;

# Request body settings
client_body_buffer_size 16k;
client_body_timeout 30s;
client_max_body_size 100m;

##
# Virtual Host Configs
Expand Down
Loading