Web performance has become the most critical factor for SEO (Search Engine Optimization) and user experience (UX) in 2026 . Google's Core Web Vitals metrics, specifically LCP (Largest Contentful Paint) and INP (Interaction to Next Paint) scores are directly tied to server response time.
In this guide, Linux Hosting We will examine step by step how to turn Nginx, the most preferred web server in infrastructures, into a performance monster by going beyond its default settings. Whether SSD VDS Regardless of whether you use a physical server, these settings will allow your website to handle its traffic more efficiently.
/etc/nginx/nginx.conf is done on the file. Before making changes, be sure to cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak Take a backup with the command. 1. Worker Processes and Connection Management
Nginx has an event-driven architecture. This means that it can process thousands of connections asynchronously, rather than creating a new process or thread for each connection like Apache. However, for this it is necessary to configure it correctly.
Worker Processes
This directive determines how many worker processes Nginx will run. 2026 in modern server architectures, best practice is to set this value equal to the number of CPU cores on the server.
user www-data; # Worklemci çekirdek sayısına göre otomatik ayarlar worker_processes auto; # Açık dosya limitini artırır (ulimit -n değerinden yüksek olmamalı) worker_rlimit_nofile 100000; events { # Her worker'ın same anda kabul edebileceği bağlantı sayısı worker_connections 4096; # Linux for en verimli event modeli use epoll; # Aynı anda birden fazla bağlantıyı kabul et multi_accept on; }
Accountlama: Maximum Number of Customers = worker_processes * worker_connections. For example, a 4 core Physical Server for 4 * 4096 = 16.384 simultaneous connection can theoretically be handled.
2. Buffer and Timeout Settings
If buffer sizes are too low, Nginx will constantly write to disk, killing performance. If it is too high, RAM consumption increases and you may be vulnerable to DDoS attacks. A balanced configuration is essential.
http { # --- Buffer Settings --- client_body_buffer_size 10K; client_header_buffer_size 1k; client_max_body_size 8m; # Dosya upload limiti large_client_header_buffers 2 1k; # --- Timeout Settings (Saniye) --- # Linkyı gereksiz yere açık tutmamak for düşürün client_body_timeout 12; client_header_timeout 12; # Keepalive süresi - çok yüksek olması RAM şişirir keepalive_timeout 15; send_timeout 10; # Dosya gönderimi optimizasyonları sendfile on; tcp_nopush on; # Pricingi tam dolu gönder tcp_nodelay on; # Keepalive bağlantılarında gecikmeyi önle }
3. Gzip and Brotli Compression
Compressing data reduces bandwidth usage and increases your site's loading speed. In 2026 BrotliIt is becoming the standard because it offers better compression rates than Gzip. If you don't have Brotli module on your server, optimize Gzip first.
gzip on; gzip_comp_level 5; # 1-9 arası. 5 ideal denge noktasıdır. gzip_min_length 256; gzip_proxied any; gzip_vary on; gzip_types application/atom+xml application/javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/plain text/x-component;
brotli on; and brotli_comp_level 6; By adding the commands, you can provide extra compression of up to %20 in text-based files. 4. FastCGI Cache (Micro Caching)
If you're using PHP-based systems like WordPress or Laravel, the best way to reduce PHP operations is to use FastCGI Cache. This is done by presenting dynamic pages like static HTML. TTFB (Time to First Byte) dramatically reduces its duration.
First create the cache directory:
mkdir -p /var/cache/nginx/fastcgi_temp chown -R www-data:www-data /var/cache/nginx
Then nginx.conf or add to your vhost file:
# Cache yolunu tanımla (http bloğu fore) fastcgi_cache_path /var/cache/nginx/fastcgi_temp levels=1:2 keys_zone=WORDPRESS:100m inactive=60m; fastcgi_cache_key "$scheme$request_method$host$request_uri"; server { # ... diğer ayarlar ... location ~ \.php$ { fastcgi_pass unix:/var/run/php/php8.3-fpm.sock; fastcgi_cache WORDPRESS; fastcgi_cache_valid 200 301 302 60m; fastcgi_cache_use_stale error timeout updating invalid_header http_500; fastcgi_cache_min_uses 1; fastcgi_cache_lock on; # Cache bypass kuralları (Admin paneli, çerezler vb. for) fastcgi_cache_bypass $skip_cache; fastcgi_no_cache $skip_cache; add_header X-FastCGI-Cache $upstream_cache_status; include fastcgi_params; } }
5. Keepalive and Upstream Optimization
To prevent Nginx from opening a new connection every time it talks to the backend (PHP-FPM or Node.js) keepalive you should use This eliminates SSL handshake costs and TCP connection setup times.
upstream php-handler { server unix:/var/run/php/php8.3-fpm.sock; keepalive 16; }
6. SSL/TLS and Security Tuning
HTTPS is now the standard, but misconfigured SSL can slow down the server. HTTP/2 and new generation HTTP/3 (QUIC) Provide parallel data flow by activating protocols. For security SSL Certificates You can review our page.
server { listen 443 ssl http2; # SSL Session Cache (El sıkışma süresini azaltır) ssl_session_cache shared:SSL:50m; # ~20.000 oturum ssl_session_timeout 1d; ssl_session_tickets off; # Modern şifreleme algoritmaları ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256...'; ssl_prefer_server_ciphers on; # OCSP Stapling (DNS sorgu süresini azaltır) ssl_stapling on; ssl_stapling_verify on; }
7. Linux Kernel (Sysctl) Settings
No matter how well Nginx is tuned, if the underlying operating system (Linux) is not tuned to accept thousands of connections, a bottleneck will occur. /etc/sysctl.conf Optimize the network stack by editing the file.
# Maksimum açık dosya sayısı fs.file-max = 2097152 # Link kuyruğu limiti (Backlog) net.core.somaxconn = 65535 net.core.netdev_max_backlog = 65535 # TIME_WAIT durumundaki soketleri yeniden kullan net.ipv4.tcp_tw_reuse = 1 # TCP Keepalive ayarları net.ipv4.tcp_keepalive_time = 600 net.ipv4.tcp_keepalive_probes = 5 net.ipv4.tcp_keepalive_intvl = 15 # TCP Pencere boyutları (Yüksek bant genişliği for) net.ipv4.tcp_rmem = 4096 87380 67108864 net.ipv4.tcp_wmem = 4096 65536 67108864 # SYN Flood koruması net.ipv4.tcp_syncookies = 1
To apply settings: sysctl -p run the command.
8. Monitoring and Log Management
If you can't measure performance, you can't improve it. Nginx stub_status Follow the number of instant connections by activating the module. However, access log Writing can create high disk I/O. Writing access logs by buffering them on high-traffic sites increases performance.
# Logları bellekte biriktirip toplu yaz (Diski yormaz) access_log /var/log/nginx/access.log main buffer=16k flush=2m; # Statik dosyalar for log tutmayı kapat location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ { access_log off; expires 365d; }
Conclusion and Recommendations
Nginx optimization is not a one-time process but one that requires constant monitoring and fine-tuning. As Eka Sunucu, all Server Optimization We apply these advanced techniques in our services.
Alternatives such as LiteSpeed Web Server are also assertive in terms of performance. If Nginx configuration seems complicated, What is LiteSpeed? You can evaluate the alternatives by reviewing our article.