opencart / opencart

A free shopping cart system. OpenCart is an open source PHP-based online e-commerce solution.

Home Page:https://www.opencart.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nginx slow SEO URLs

lemonadvert opened this issue · comments

OpenCart 4.1.0.0 - Dev version

Describe the bug

Hello again,
We tried all the options suggested in the previous post (change of model in SEO). We found that the issue is completely different.
We are using Nginx. So the Nginx slowed down the loading speed by 3-4 seconds when we enabled the SEO URLs. We have a standard Nginx configuration. Maybe due to some settings, this issue appears.
After that, we tried to upload the project to Apache2 and we found that the loading speed was much faster, about 600 - 700 ms.

The project is in 9 languages with many SEO URLs, and that's why we noticed the problem.

Has anyone had a similar problem with Nginx and can provide any idea or solution?

Thanks!

how many products

i added index to the db table

how many products

Now much.. around 1000 with 300 categories, and 9 languages .

@lemonadvert : Have you managed to trace it down to the exact SQL query which makes it so slow? If so, run it via PHPMyAdmin, try to modify and/or optimize it there, to see what exactly causes the performance issue. Even 700 msec on Apache2 is a bit slow, too.

i added index to the db table

Can you give us an exact MySQL query for the indexes to run on phpmyadmin in our DB and then test if it works?

@lemonadvert : Have you managed to trace it down to the exact SQL query which makes it so slow? If so, run it via PHPMyAdmin, try to modify and/or optimize it there, to see what exactly causes the performance issue. Even 700 msec on Apache2 is a bit slow, too.

No, we don't. You can try to open the product from this link https://inbyo.cz/cs-cz/catalog/slevy will see the delay on the Console Network tab.

Your product page takes about 2172ms to do the initial load for https://inbyo.cz/116-cs/cs-cz/product/slevy
I can only see 1 language.

Your product page takes about 2172ms to do the initial load for https://inbyo.cz/116-cs/cs-cz/product/slevy I can only see 1 language.

Yes, I know that.
At the moment we disabled the other languages. They will be on separate domains. But the issue is the same with one or 9 languages.

You could just temporarily add some logging code with time measurements to the system/library/db/mysqli.php, in its query function, to see what exact DB query is so slow. See e.g. https://stackoverflow.com/questions/6245971/accurate-way-to-measure-execution-times-of-php-scripts on how to do that.

seems quick enough to me

The SQL query times seem to be OK, no outstanding bottlenecks in there, judging by your logs. Is it on NGinx or Apache2?

The SQL query times seem to be OK, no outstanding bottlenecks in there, judging by your logs. Is it on NGinx or Apache2?

It's Nginx only.... with standard configurations...
I just noticed that there is a lot of queries for SEO URLs.

Amost 1000 sql queries for product detail page?

Here is the vhost file:

server {
listen 80;
listen [::]:80;
listen 443 ssl http2;
listen [::]:443 ssl http2;
{{ssl_certificate_key}}
{{ssl_certificate}}
server_name www.inbyo.cz;
return 301 https://inbyo.cz$request_uri;
}

server {
listen 80;
listen [::]:80;
listen 443 ssl http2;
listen [::]:443 ssl http2;
{{ssl_certificate_key}}
{{ssl_certificate}}
server_name inbyo.cz www1.inbyo.cz;
{{root}}

{{nginx_access_log}}
{{nginx_error_log}}

if ($scheme != "https") {
rewrite ^ https://$host$uri permanent;
}

location ~ /.well-known {
auth_basic off;
allow all;
}

{{settings}}

location ~ ^/image/cache/(.).(jpg|jpeg|png|gif)$ {
add_header Access-Control-Allow-Origin "
";
add_header Cache-Control public;
add_header Cache-Control must-revalidate;
expires max;

try_files $uri /index.php?route=tool/image&file=$request_uri;    

}

location / {
{{varnish_proxy_pass}}
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_hide_header X-Varnish;
proxy_redirect off;
proxy_max_temp_file_size 0;
proxy_connect_timeout 720;
proxy_send_timeout 720;
proxy_read_timeout 720;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 256k;
}

location ~* ^.+.(css|js|jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|woff2|eot|mp4|ogg|ogv|webm|webp|zip|swf|map)$ {
add_header Access-Control-Allow-Origin "*";
expires max;
access_log off;
}

if (-f $request_filename) {
break;
}
}

geo $authentication {
default "Authentication required";
127.0.0.1 "off";
62.73.72.6 "off";
83.228.83.233 "off";
78.83.178.47 "off";
}

server {
listen 8080;
listen [::]:8080;
server_name inbyo.cz www1.inbyo.cz;
{{root}}

try_files $uri $uri/ /index.php?$args;
index index.html index.php;

# Add trailing slash to */administrator requests.
rewrite /administrator$ $scheme://$host$uri/ permanent;
location /administrator {
    index index.php;
    
    auth_basic $authentication;
    auth_basic_user_file /etc/apache2/.htpasswd;
}

location / {
    try_files $uri @opencart;
}

location @opencart {
    rewrite ^/(.+)$ /index.php?_route_=$1 last;
}

location ~ .php$ {
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
try_files $uri =404;
fastcgi_read_timeout 3600;
fastcgi_send_timeout 3600;
fastcgi_param HTTPS "on";
fastcgi_param SERVER_PORT 443;
fastcgi_pass 127.0.0.1:{{php_fpm_port}};
fastcgi_param PHP_VALUE "{{php_settings}}";
}

if (-f $request_filename) {
break;
}
}

Try it on an Apache2 server, just to see whether it makes a difference.

Try it on an Apache2 server, just to see whether it makes a difference.

We tried already, as I described in the first post:

We tried to upload the project to Apache2 and we found that the loading speed was much faster, about 600 - 700 ms.

So why aren't you using Apach2 then? Nginx has know performance issues with dynamically generated pages. It's good for heavy server loads serving static pages, but OC pages are mainly dynamic.