0

I'm not sure how to properly specify this problem, I'm not really a server expert. I will be glad to provide additional data on demand.

I have a PHP web-application running on Ubuntu Server with nginx and PHP-FPM (communicating via socket file). This application talks to another backend server via curl. And I have this one request that is taking a minute to complete. When I hit this request the whole server becomes unresponsive. While this long request is pending no other requests can be completed. When I restart PHP-FPM or this connection dies by itself - all becomes normal again.

I've tried to change some nginx and PHP FPM parameters related to concurrency but to no avail.

nginx server configuration:

server {
    listen 80;
    server_name example.com;
    root /var/www/example.com/web;

    # removing trailing dot
    if ($http_host ~ "\.$" ) {
        rewrite ^(.*) $scheme://$host$1 permanent;
    }

    location / {
        # try to serve file directly, fallback to rewrite
        try_files $uri @rewriteapp;
    }

    location /js/which.js {
        rewrite . /which.php last;
    }

    location @rewriteapp {
        # rewrite all to app_dev.php
        rewrite ^(.*)$ /app_dev.php/$1 last;
    }

    location ~ ^/(app_dev\.php|which\.php)(/|$) {
        fastcgi_pass unix:/var/run/php-fpm/example.com.sock;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param HTTPS off;
        fastcgi_buffer_size 128k;
        fastcgi_buffers 4 256k;
        fastcgi_busy_buffers_size 256k;
    }

    gzip on;
    gzip_http_version 1.1;
    gzip_vary on;
    gzip_comp_level 6;
    gzip_proxied any;

    gzip_types
        text/plain
        text/css
        application/json
        application/x-javascript
        text/xml
        application/xml
        application/xml+rss
        text/javascript
        application/javascript
        text/x-js
    ;

    gzip_buffers 16 8k;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    # Logging configuration.
    error_log /var/www/example.com/var/logs/nginx/error.log info;
}

PHP FPM configuration:

[example.com]

user = fpm-example.com
group = fpm-example.com
listen = /var/run/php-fpm/example.com.sock
listen.owner = nginx
listen.group = nginx

pm = dynamic
pm.max_children = 100
pm.start_servers = 10
pm.min_spare_servers = 10
pm.max_spare_servers = 30

request_terminate_timeout = 35s

catch_workers_output = yes

# Logging
php_flag[display_errors] = off
php_admin_value[error_log] = /var/www/example.com/var/logs/php-fpm/errors.log
php_admin_flag[log_errors] = on

What could be the reason for this?

2
  • What are the contents of nginx and PHP logs during this situation? Aug 30, 2014 at 23:01
  • There are no errors in the logs. All other requests to the server is blocked until this one finishes successfully or dies due to timeout. Aug 30, 2014 at 23:25

1 Answer 1

0

I'm sorry, it wasn't actually a server problem. After some additional tests it become apparent that this is the problem with the application itself and not the server. I've created another question on StackOverflow to narrow down this issue.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .