Slow performance on EC2 t3.medium (Amazon Linux 2)


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.

  1. I follow this instruction: except, I use amazon linux extras for postgres9.6 and I did not configure SELinux ( getenforce => Disabled )

  2. Indico runs fine except that it is very very slow

  3. So, I try modifying the configuration a bit, but it doesn’t help anyway:


#uid = uwsgi
#gid = uwsgi
#pidfile = /run/uwsgi/
#emperor = /etc/uwsgi.d
#stats = /run/uwsgi/stats.sock
#chmod-socket = 660
#emperor-tyrant = true
#cap = setgid,setuid

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


server {
        listen 80;
        listen [::]:80;
        return 301 https://$server_name$request_uri;

server {
        listen       *:443 ssl http2;
        listen       [::]:443 ssl http2 default ipv6only=on;

        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_prefer_server_ciphers on;

        access_log            /opt/indico/log/nginx/access.log combined;
        error_log             /opt/indico/log/nginx/error.log;

        location /.xsf/indico/ {
                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;


user nginx;
worker_processes 1; # modified
error_log /var/log/nginx/error.log;
pid /run/;

# 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
    # 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 {
  1. 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

Just a single process for uwsgi may be problematic since that means only one request can be served at the same time - and while most are fast, this may still cause some slowdowns.

SSH responds slowly, top runs slowly, etc.
nginx serves both indico app page and static file slowly

This sounds like a general problem… unfortunately I have no idea what it might be since you mentioned that CPU and RAM usage look fine…

I found out that I just need another EC2 instance for proxy.
Everything runs fast now.
Thank you.