Answer the question
In order to leave comments, you need to log in
Why does GUNICORN + DJANGO crash when there is an influx of load?
There is a VPS 12 cores 8Gig. A chat bot for VK hangs on it (up to 100rps at the peak). There are many failures in server responses
nginx config:
user www-data;
worker_processes 12;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
use epoll;
worker_connections 1666;
multi_accept on;
accept_mutex off;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 30;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
#ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
#ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log off;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
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/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
# Place this file in the `/etc/nginx/conf.d/` directory and update nginx
# configurations: sudo nginx -s reload
upstream django_project {
server unix:/home/django/projects/<hidden>.ru/world/var/run/guni.sock fail_timeout=0;
}
# конфиг прокси
server {
listen 80;
server_name www.<hidden>.ru;
return 301 http://<hidden>.ru$request_uri;
}
server {
# DEFAULTS
listen 80;
keepalive_timeout 25;
keepalive_requests 100;
client_max_body_size 50m;
client_body_timeout 15;
# If the client stops reading data, free up the stale client connection after this much time.
send_timeout 2;
server_name <hidden>.ru *.<hidden>.ru;
root /home/django/projects/<hidden>.ru/world/var/www;
access_log off;
#/home/django/projects/<hidden>.ru/world/var/log/nginx_access.log;
# access_log /home/django/projects/<hidden>.ru/world/var/log/$host;
error_log /var/log/nginx/error.log;
# OPTIMIZATION
proxy_connect_timeout 16;
proxy_send_timeout 16;
proxy_read_timeout 16;
# HANDLERS
location ~ ^/(media|static)/ {
# Buffering the static data for 7 minutes.
expires 7m;
}
location / {
# Checks for static file, if not found proxy to app.
try_files $uri @django_app_proxy;
}
location /nginx_status {
stub_status;
}
location @django_app_proxy {
# DEFAULTS
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_buffering off;
proxy_redirect off;
# OPTIMIZATION
# fastcgi_read_timeout 300;
# limit_req zone=one burst=5;
proxy_read_timeout 300;
# HANDLERS
proxy_pass http://django_project;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question