0

This is on a server running Ubuntu 16.04.3 LTS, serving an Angular web application. The sites works completely fine, but is very slow to load pages, taking a number of minutes at times. I've tried various solution including This. Which did significantly speed up the site but made some pages inaccessible. Any help or tips would be greatly appreciated, thank you!

server {
   listen 80 default_server;
   listen [::]:80 default_server;

   listen 443 ssl; 
   ssl_certificate /location/ 
   ssl_certificate_key /location/

    root /location/;

    index index.html index.htm index.nginx-debian.html;

    server_name site.net;

    add_header Strict-Transport-Security max-age=500;

location / {
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header Host $http_host;
            proxy_http_version 1.1;
            proxy_set_header Connection "upgrade";
            proxy_pass http://localhost:1337/;
            proxy_buffering off;
           }
}
1

A well performing web server often is the result of many small optimizations. But page loads taking multiple minutes(!) looks more like a misconfiguration than missing performance optimizations.

As you did not tell exactly what parts of your page loads are slow … this is what I would do:

  1. Check for slow network connection on client: https://fast.com

    • Is it really the server? Or is it your connection to the server?
  2. Check for page loading times on https://www.webpagetest.org

    • TTFB slow? -> Check DNS. Check SSL negotiation. Check caches on server.

    • Completing the initial request takes long? -> Check for slow database queries. Check for missing database table indexes. Check application code.

    • Check for initial redirects often making slow sites even slower. -> Check for consistent usage of trailing slashes in nginx config and application code.

  3. Check nginx vhost config.

    • Placing both listening on :80 and :443 in one server block seems no ok. You would like to redirect :80 requests to :443 for sure, so you should split :80 and :443 into two 'server' blocks.
    • Server not listening to IPv6 on :443 seems not ok.

    • Maybe add http2 support 443 listen parameter

  4. Check nginx log files.

    • Maybe use advanced logging features and add timing information to log_format. See here.

    • Turn off logging in production if not needed.

  5. Check nginx.conf.

    • Values for worker_processes and worker_connections ok?

    • Rate limiting active?

  6. Check for performance difference when serving the application directly instead of through proxy_pass.

  7. Check caching on server.

  8. Check more for more performance tuning options with nginx here.

  9. Check Ubuntu logs eg. syslog for other issues like failing hard drives, fail2ban problem …

  10. Good luck!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.