Troubleshooting Site Slowness on a Nginx + Gunicorn + Django Stack

前端 未结 3 548
孤独总比滥情好
孤独总比滥情好 2020-12-30 02:11

Issue I Was Having

I was having an issue where some sites were taking a long time to load (By \"long time\" I mean up to 16 seconds). Sometimes they might timeout

3条回答
  •  萌比男神i
    2020-12-30 02:33

    1) Not sure what you mean by inactive? As in, disabled by nginx? Or just too slow to work?

    2 and 3) django-debug-toolbar and django-debug-logging will be a good place to start. If this doesn't help, it's time to move to server-level profiling to see which processes are causing the problem.

    4) Use top: How to find out which processes are swapping in linux?

    5) Yes - benchmarking. Pick a benchmarking tool (e.g. apachebench) and run tests against your current configuration. Tweak something. Run the tests again. Repeat until your performance problems are gone! For best results, use traffic which is similar to your live traffic (in terms of URL distribution, GET/POST, etc).

    6) Yes, at both the nginx and app levels. You will probably get most benefit by profiling each site and improving its memory usage (see 2).

提交回复
热议问题