0

Magento 1.9.2.2 is very slow on product save within an NGINX enviroment. I use following settings: PHP-FPM 5.6.8 / 5.6.2

Php.ini

memory_limit = 2048M
max_execution_time = 1800

upload_max_filesize = 100M
session.auto_start = off
suhosin.session.cryptua = off
zend.ze1_compatibility_mode = Off

apc.shm_size=1024M
apc.num_files_hint=10000
apc.user_entries_hint=10000
apc.max_file_size=5M
apc.stat=0
apc.optimization=0
apc.include_once_override=1
apc.ttl=48000
apc.user_ttl=48000

realpath_cache_size = 32k
realpath_cache_ttl = 7200
default_socket_timeout = 90
pdo_mysql.cache_size = 2000
output_buffering = 4096

NGINX DIRECTIVES

    location /{FOLDER} {
    client_max_body_size 100M;

    index index.html index.php; ## Allow a static html file to be shown first
    #try_files $uri $uri/ /{FOLDER}index.php$is_args$args; ## If missing pass the URI to Magento's front handler
    try_files $uri $uri/ @handler{FOLDERMD5}; ## If missing pass the URI to Magento's front handler
    expires 30d; ## Assume all files are cachable


    ## These locations would be hidden by .htaccess normally
    location /{FOLDER}app/                { deny all; }
    location /{FOLDER}includes/           { deny all; }
    location /{FOLDER}lib/                { deny all; }
    location /{FOLDER}media/downloadable/ { deny all; }
    location /{FOLDER}pkginfo/            { deny all; }
    location /{FOLDER}report/config.xml   { deny all; }
    location /{FOLDER}var/                { deny all; }
    location /{FOLDER}dev/                { deny all; }

    location /{FOLDER}var/export/ { ## Allow admins only to view export folder
        auth_basic           "Restricted"; ## Message shown in login window
        auth_basic_user_file /var/www/magento-demo.timmehosting.de/.htpasswd; ## See /etc/nginx/htpassword
        autoindex            on;
    }

    location /{FOLDER}downloader/ {
        index index.php;
    }

    location ~ \.php/ { ## Forward paths like /js/index.php/x.js to relevant handler
        rewrite ^(.*\.php)/ $1 last;
    }

    location /{FOLDER}skin/m/ {
        rewrite ^/{FOLDER}skin/m/([0-9]+)(/.*\.(js|css))$ /{FOLDER}lib/minify/m.php?f=$2&d=$1 last;
    }

    location ~ \.php$ {
        try_files $uri =404;
        include /etc/nginx/fastcgi_params;
        {FASTCGIPASS}
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        #fastcgi_param PATH_INFO $fastcgi_script_name;
        fastcgi_intercept_errors on;

        fastcgi_param  HTTPS $fastcgi_https;
        #fastcgi_param  MAGE_RUN_CODE default; ## Store code is defined in administration > Configuration > Manage Stores
        fastcgi_param  MAGE_RUN_TYPE store;
        fastcgi_temp_file_write_size 10m;
        fastcgi_busy_buffers_size    512k;
        fastcgi_buffer_size          512k;
        fastcgi_buffers           16 512k;
        fastcgi_read_timeout 1200;
        <tmpl_if name='php' op='==' value='hhvm'>error_page 500 501 502 503 = @phpfallback{FOLDERMD5};</tmpl_if>

    }
}

location @handler{FOLDERMD5} { ## Magento uses a common front handler
    rewrite / /{FOLDER}index.php;
}

<tmpl_if name='php' op='==' value='hhvm'>
location @phpfallback{FOLDERMD5} {
    client_max_body_size 100M;
    try_files $uri =404;
    include /etc/nginx/fastcgi_params;
    {PHPFALLBACKFASTCGIPASS}
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    #fastcgi_param PATH_INFO $fastcgi_script_name;
    fastcgi_intercept_errors on;

    fastcgi_param  HTTPS $fastcgi_https;
    #fastcgi_param  MAGE_RUN_CODE default; ## Store code is defined in administration > Configuration > Manage Stores
    fastcgi_param  MAGE_RUN_TYPE store;
    fastcgi_temp_file_write_size 10m;
    fastcgi_busy_buffers_size    512k;
    fastcgi_buffer_size          512k;
    fastcgi_buffers           16 512k;
    fastcgi_read_timeout 1200;
}
</tmpl_if>
  pagespeed on;
  pagespeed FileCachePath /var/ngx_pagespeed_cache;
  #pagespeed FetchHttps enable,allow_self_signed;

  # let's speed up PageSpeed by storing it in the super duper fast memcached
  pagespeed MemcachedThreads 1;
  pagespeed MemcachedServers "localhost:11211";

  # Filter settings
  pagespeed RewriteLevel CoreFilters;
  pagespeed EnableFilters collapse_whitespace,remove_comments;

  #  Ensure requests for pagespeed optimized resources go to the pagespeed
  #  handler and no extraneous headers get set.
  location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
    add_header "" "";
    access_log off;
  }
  location ~ "^/ngx_pagespeed_static/" {
    access_log off;
  }
  location ~ "^/ngx_pagespeed_beacon$" {
    access_log off;
  }
  location /ngx_pagespeed_statistics {
    allow 127.0.0.1;
    deny all;
    access_log off;
  }
  location /ngx_pagespeed_global_statistics {
    allow 127.0.0.1;
    deny all;
    access_log off;
  }
  location /ngx_pagespeed_message {
    allow 127.0.0.1;
    deny all;
    access_log off;
  }
  location /pagespeed_console {
    allow 127.0.0.1;
    deny all;
    access_log off;
  }
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
    expires 30d;
    add_header Pragma public;
    add_header Cache-Control "public";
}

It is very fast in frontend. But on save it is very slow.

Do you have any recommendations for a fix?

4
  • "NGINX enviroment" has nothing to do with it, your problem is custom extension or database configuration. you need github.com/AOEpeople/Aoe_Profiler or xdebug or strace
    – MagenX
    Commented Nov 23, 2015 at 8:58
  • btw your nginx config is wrong, if you copy-pasted it from web and have no idea how it works, you better switch to Apache immediately.
    – MagenX
    Commented Nov 23, 2015 at 9:02
  • Thanks @MagenX for your comments. I'll check it out with the profiler. The config is actually a template of the server provider. What's so wrong about it? Commented Nov 23, 2015 at 11:02
  • www.magereport.com
    – MagenX
    Commented Nov 23, 2015 at 11:05

2 Answers 2

0

First your product save is primarily going to be dictated by the speed of you server and your MySQL server. Since you admin doesn't care if your pages are cached or not they still have to process the php so your response from the server is not going to be much different in Nginx or Apache.

You need to look for at how many CPU's you have in your server and the amount of RAM. Of course SSD helps and having a dedicated rather than a VPS will also help. You should consider replacing the standard MySQL server with Percona.

You "Very fast frontend" is a result of the static pages that Nginx is serving up, the fact that your Admin is not static and relies on the server itself tell me that you need to increase the size of your server.

0

I managed to bring down the save speed from about 30-45 seconds to only 3 by enabeling HHVM instead of PHP-FPM.

The only thing not working was the image upload button. This issue can be resolved with https://github.com/facebook/hhvm/issues/4993#issuecomment-79039837

Thanks for everybody supporting here.

1
  • this is impossible... it is not a fix afterall
    – MagenX
    Commented Dec 3, 2015 at 9:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.