load balancing – How to improve TTFB on NGINX?
I have a long TTFB (1.6 sec) and find the reason for this.
My stack is server (nginx + php-fpm) and load balancer on Hetzner and Cloudflare.
Are there too many redirects and therefore the waiting time is long?
nginx.conf
server {
listen 80;
server_name www.example.com api.example.com;
return 301 https://www.example.com$request_uri;
}
server {
listen 443 ssl http2;
server_name www.example.com api.example.com;
root /var/www/app/public_html/web;
ssl_certificate /etc/letsencrypt/live/example.com-0001/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com-0001/privkey.pem;
ssl_dhparam /etc/nginx/ssl/dh2048.pem;
ssl_session_timeout 5m;
ssl_session_cache shared:TLS:2m;
ssl_buffer_size 4k;
add_header Strict-Transport-Security "max-age=31536000;" always;
include "conf.d/server_ssl.conf";
include conf.d/drupal-prelive.conf;
include conf.d/php_fpm_status-prelive.conf;
access_log /var/log/nginx/nginx-app1.log main;
error_log /var/log/nginx/nginx-app1-error.log;
proxy_buffer_size 1024k;
proxy_buffers 4 1024k;
proxy_busy_buffers_size 1024k;
proxy_read_timeout 300;
proxy_connect_timeout 300;
proxy_send_timeout 300;
}
Read more here: Source link