Random slow APIs

Hello everyone, I hope you can help me.

I have configuration problems with my server, basically, randomly, some APIs that usually take 200-600ms to execute, take 10-20 seconds.

Thanks to logs and several tests, I ruled out that the problem was the connection to the Database, in fact even APIs that do not query the DB but return a static string give me the same problem if called several times.

Here are some cases and tests carried out:

My back-end is written with Laravel, my hosting is Contabo and has already migrated the server and improved performance, but the problem persists.

These are some configurations I have, if you need more details let me know::


Timeout 30
KeepAlive Off
MaxKeepAliveRequests 100
KeepAliveTimeout 10


    sendfile                        on;
    tcp_nopush                      on;
    tcp_nodelay                     on;
    client_header_timeout           180s;
    client_body_timeout             180s;
    client_header_buffer_size       2k;
    client_body_buffer_size         256k;
    client_max_body_size            256m;
    large_client_header_buffers     4 8k;
    send_timeout                    60s;
    keepalive_timeout               30s;
    keepalive_requests              100000;
    reset_timedout_connection       on;
    server_tokens                   off;
    server_name_in_redirect         off;
    server_names_hash_max_size      512;
    server_names_hash_bucket_size   512;
    charset                         utf-8;

    # FastCGI settings
    fastcgi_buffers                 8 256k;
    fastcgi_buffer_size             256k;
    fastcgi_busy_buffers_size       256k;
    fastcgi_temp_file_write_size    256k;
    fastcgi_connect_timeout         30s;
    fastcgi_read_timeout            450s;
    fastcgi_send_timeout            300s;
    fastcgi_cache_lock              on;
    fastcgi_cache_lock_timeout      5s;
    fastcgi_cache_background_update on;
    fastcgi_cache_revalidate        on;
    # Proxy settings
    proxy_redirect                  off;
    proxy_set_header                Host $host;
    proxy_set_header                X-Real-IP $remote_addr;
    proxy_set_header                X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass_header               Set-Cookie;
    proxy_buffers                   32 4k;
    proxy_connect_timeout           30s;
    proxy_read_timeout              300s;
    proxy_send_timeout              180s;

I hope you can help me, because I’m going crazy.