Hello,
I am trying out indico for the first time, on an EC2 t3.medium (Amazon Linux 2 (btw ubuntu did not do the trick either)) instance, and I am experiencing a performance issue. Since I have almost none experience with uWSGI and nginx, I am in complete lost.
-
I follow this instruction: https://docs.getindico.io/en/latest/installation/production/centos/nginx/ except, I use amazon linux extras for postgres9.6 and I did not configure SELinux (
getenforce
=>Disabled
) -
Indico runs fine except that it is very very slow
-
So, I try modifying the configuration a bit, but it doesn’t help anyway:
/etc/uwsgi.ini
#[uwsgi]
#uid = uwsgi
#gid = uwsgi
#pidfile = /run/uwsgi/uwsgi.pid
#emperor = /etc/uwsgi.d
#stats = /run/uwsgi/stats.sock
#chmod-socket = 660
#emperor-tyrant = true
#cap = setgid,setuid
[uwsgi]
uid = indico
gid = nginx
umask = 027
processes = 1 # since it is 2 cores I figured 1 process could be better? one for uwsgi, one for nginx
enable-threads = false # modified
chmod-socket = 770
socket = /opt/indico/web/uwsgi.sock
stats = /opt/indico/web/uwsgi-stats.sock # I tried uwsgitop but the process is idle most of the time anyway
protocol = uwsgi
master = true
auto-procname = true
procname-prefix-spaced = indico
disable-logging = true
plugin = python
single-interpreter = true
touch-reload = /opt/indico/web/indico.wsgi
wsgi-file = /opt/indico/web/indico.wsgi
virtualenv = /opt/indico/.venv
vacuum = true
buffer-size = 20480
memory-report = true
max-requests = 2500
harakiri = 900
harakiri-verbose = true
reload-on-rss = 2048
evil-reload-on-rss = 8192
/etc/nginx/conf.d/indico.conf
server {
listen 80;
listen [::]:80;
server_name ec2-13-250-103-67.ap-southeast-1.compute.amazonaws.com;
return 301 https://$server_name$request_uri;
}
server {
listen *:443 ssl http2;
listen [::]:443 ssl http2 default ipv6only=on;
server_name ec2-13-250-103-67.ap-southeast-1.compute.amazonaws.com;
ssl on;
ssl_certificate /etc/ssl/indico/indico.crt;
ssl_certificate_key /etc/ssl/indico/indico.key;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS;
ssl_prefer_server_ciphers on;
access_log /opt/indico/log/nginx/access.log combined;
error_log /opt/indico/log/nginx/error.log;
location /.xsf/indico/ {
internal;
alias /opt/indico/;
add_header X-inwwin-location xsf;
}
location ~ ^/(images|fonts)(.*)/(.+?)(__v[0-9a-f]+)?\.([^.]+)$ {
alias /opt/indico/web/static/$1$2/$3.$5;
access_log off;
add_header X-inwwin-location img-fonts;
}
location ~ ^/(css|dist|images|fonts)/(.*)$ {
alias /opt/indico/web/static/$1/$2;
access_log off;
add_header X-inwwin-location css-dist-img-fonts;
}
location /robots.txt {
alias /opt/indico/web/static/robots.txt;
access_log off;
add_header X-inwwin-location robot;
}
location / {
add_header X-inwwin-location root;
root /var/empty/nginx;
include /etc/nginx/uwsgi_params;
uwsgi_pass unix:/opt/indico/web/uwsgi.sock;
uwsgi_param UWSGI_SCHEME $scheme;
uwsgi_read_timeout 15m;
# uwsgi_buffers 32 32k;
# uwsgi_busy_buffers_size 128k;
# uwsgi_hide_header X-Sendfile;
client_max_body_size 1G;
}
}
/etc/nginx/nginx.conf
user nginx;
worker_processes 1; # modified
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
server_names_hash_bucket_size 128;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile off; # on or off it is still slow
sendfile_max_chunk 512k;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
gzip on;
gzip_min_length 1100;
# gzip_buffers 4 8k;
gzip_types text/plain text/css application/x-javascript application/javascript;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
- The thing is when I first restart the services
systemctl restart uwsgi.service nginx.service indico-celery.service
everything is fine.
At this stage if I try downloading static file in e.g. /dist/js, it takes a few hundreds millisecond to load which is normal.
But if I start accessing any page that is in indico application e.g. accessing / or /admin/, everything in my server slows down.:
- SSH responds slowly,
top
runs slowly, etc. - nginx serves both indico app page and static file slowly, for example /dist/js/common.97c499cc.bundle.js takes 10 seconds TTFB and another 20 seconds to download, which is pretty unnormal
- on the other hand
top
shows that cpu utilisation is no more than a few perecnt and plenty of ram is still available
Could anyone help me? I suppose It may have something to do with optimising my uwsgi and nginx setting, but since I am beginner I am not sure where to start.
Thank you