Hikashop works slow after 4.5.0 update

  • Posts: 215
  • Thank you received: 6
  • Hikashop Business
2 years 8 months ago #340186

-- HikaShop version -- : 4.5.0
-- Joomla version -- : 3.10.6
-- PHP version -- : 7.4.27
-- Browser(s) name and version -- : chrome

Hi ,
It is seems like Hikashop works slow after 4.5.0 update
the products pages in browser lagging while loading

how to check it ?

We noticed sql query

SELECT product_id as id,product_alias,product_name  FROM hikashop_product WHERE product_type = 'main'
while opening pages, where are about 20k products in hikashop_product table

Did you changed any sql code in 4.5.0 update wich may work slow ?

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 8 months ago #340191

Hi,

Your pages display fast on my end and we didn't change much with the SQL queries.
Do you still have the problem ? On which pages ?
Where are you located and where is the server located ?
Your website seems to be in Russian. So it's possible that you're just being affected by the restrictions put in place against Russia with what's happening in Ukraine, leading to the loading of the pages being slowed down.

Please Log in or Create an account to join the conversation.

  • Posts: 215
  • Thank you received: 6
  • Hikashop Business
2 years 8 months ago #340199

we are locating in Kazakhstan also as our web server locating

we are observing about 5-10 sec lag while opening any product page
for example any product from this category aketo.kz/chastotnye-preobrazovateli/2-2-kvt

the restrictions against russians cannot affect cous this different countris

Tellingly, lags are observed specifically when opening web pages with goods. Category pages and other pages seem to load the same as before.

Last edit: 2 years 8 months ago by Bender.

Please Log in or Create an account to join the conversation.

  • Posts: 2143
  • Thank you received: 747
2 years 8 months ago #340201

Hi,

aketo.kz is hosted on gohost.kz, which has its datacenter in KZ, supposedly, but is a Russian company, has Russian contact numbers, etc.
Depending on where site visitors are, it might well be that traffic is routed through Russia, and that its affected as per Nicolas' indication.

Ping your domain, and/or do a traceroute to see what's happening.
(A traceroute to aketo.kz from where I am actually does include a Russian server with IP 178.210.33.91)

On top of that, it's normal that some web pages take longer to render than others. Your browser's development tools will give you more information on this, plus there are on-line tools which can help you to analyse what's going on.


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )
Last edit: 2 years 8 months ago by lousyfool.

Please Log in or Create an account to join the conversation.

  • Posts: 215
  • Thank you received: 6
  • Hikashop Business
2 years 8 months ago #340202

Thank you, we understand and will check in this direction. Through DevTools, we have already determined that Waiting (TTFB) has increased to 11 seconds on average, this seems to be really a network or server influence than the Hikashop engine

Last edit: 2 years 8 months ago by Bender.

Please Log in or Create an account to join the conversation.

  • Posts: 215
  • Thank you received: 6
  • Hikashop Business
2 years 8 months ago #340204

The network was checked, the traffic goes only through local networks, so that's not the point.

Have you noticed that when loading the product page, php loads all cores at 100%, Is it seems that the new code may eat more resources?

Please Log in or Create an account to join the conversation.

  • Posts: 2143
  • Thank you received: 747
2 years 8 months ago #340205

Hi again,

When loading a product details page (e.g. aketo.kz/datchiki/temperatury/termosopro...ct/dts3225-rt1000-v2 ), basically all of the waiting time is spent with staring at this in the browser window's bottom left corner:



Apparently, that's for mc.yandex.ru/metrika/tag.js and maybe similar (I haven't checked each and every bit). Just look at such page's waterfall. Again, there are plenty of analytical tools around, you only need to use and read them correctly.

Nothing related to HikaShop. Get rid of the other hold-ups on your site, at least temporarily for testing purposes if other tools don't work for you, and see/verify. If you still need them in the long run, consider loading such time consuming stuff after all other code (= defer respective code lines to the very end of page).


Need help with customisations of layouts, style or other site development? PM me!
(Don't forget to turn on "E-mail notification of new messages" )
Attachments:
Last edit: 2 years 8 months ago by lousyfool.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 8 months ago #340207

Hi,

While javascript/CSS files being loaded from Russia could indeed be a problem, it's hard to conclude that it is the same for the main HTML page request.
On other pages it loads in a few hundred microseconds, while on the product pages pointed by Bender it takes 7-8 seconds on my end.
So that would indicate something not right on the website/server itself.
To better understand the source of that delay, I would recommend temporarily activating the "debug system" setting of the Joomla configuration. Then, display again the product details page with the issue and look at the debug information at the bottom.
There, you'll see more precisely where the problem is located: MySQL queries, or modules, or others. And if Joomla generates the page in a few hundred microseconds but it takes 7- 8 seconds to get it, then the problem is not on the website but on the server / network.

Please Log in or Create an account to join the conversation.

  • Posts: 215
  • Thank you received: 6
  • Hikashop Business
2 years 8 months ago #340218

Nicolas is probably more right indeed.

We enabled Joomla debug console and found what on product pages - aplication AfterRoute use a lot of time and memory - about 6000-11000 ms (an example is here drive.google.com/file/d/1WGhFrTqUlfCVWpt...u9_/view?usp=sharing )

We didn't made big changes in content on website also as we didn't downgrade of any server's hardware. Website worked fast enought on previous Hikashop's versions with actually same amount of content and hardware. So it seems like the problem may be in onAfterRoute function or something what linked with.

P.S. Component / com_hikashop/router.php may be the reason (step 5 and 6)
like preparing wrong or too much data for onAfterRoute in step 7

see debug drive.google.com/file/d/1JDXIBW4dhgVMAdW...N_Z/view?usp=sharing

Last edit: 2 years 8 months ago by Bender.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 8 months ago #340228

Hi,

Your first screenshot indeed points at the routing being the culprit. Do you use any SEF extension, like sh404SEF ?

The routing is not only made by that file. Also your screenshot doesn't indicate a problem in that file.
In fact, the only relevant modification made to that file for the 4.5.0 is this:
i.imgur.com/6fE3MeR.png
which was made to fix this: www.hikashop.com/forum/product-category-...gories.html?start=20
And it only affects HikaShop Starter.
I assume you're using the Business edition so it won't change anything for your website.

Normally, in the debug data, you should have timings as well, which would help narrow down the issue:
i.imgur.com/5dXTPcZ.png
But I don't see these on your screenshot. Is it your frontend template removing them ?
It would be great to be able to see these.

Please Log in or Create an account to join the conversation.

  • Posts: 215
  • Thank you received: 6
  • Hikashop Business
2 years 8 months ago #340235

We dont use any SEF extension except embedded in Joomla.
here is zip file with saved debug 2 pages
the first on english and the second on russian =
the lang of website is russian also as all content

also afterroute lag in russian is 6600 ms and on afterroute lag on english is 2200 ms = difference is 4000 ms !
it's bad

drive.google.com/file/d/1awC_KHY234mfg4A...sox/view?usp=sharing

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 8 months ago #340239

Hi,

From what I can see in the query debug data, it comes from a change with made last summer following this thread in order to allow URLs without the id to use translated aliases :
www.hikashop.com/forum/5-support-en-fran...ias-de-produits.html
For that to work properly (which wasn't the case until then), we have to load a cache of the all the aliases of all the products. Since you have a lot of products it requires loading a big table of data of 20000 entries in memory and that's what's slowing down the whole thing.

A simple solution to this is to turn off the "Remove products and categories id in URLs" setting in the HikaShop configuration.
That way, the URLs will include the id of the products and the system won't have to search for the matching alias.

For a more complex solution, I've rewritten the code:

function getOriginalId($type, $name, $dynamic=false) {
		$lang = JFactory::getLanguage();
		$tag = $lang->getTag();
		if($this->falang) {
			$lang_id = $this->getId($tag);
			$condition = 'reference_field='.$this->database->Quote($type.'_alias').' AND value = '.$this->database->Quote(str_replace(':','-',$name));
			if($dynamic) {
				$name_regex = '^ *p?'.str_replace(array('-',':'),'.+',$name).' *$';
				$condition = '((reference_field='.$this->database->Quote($type.'_alias').' AND (value = '.$this->database->Quote(str_replace(':','-',$name)).' OR value REGEXP '.$this->database->Quote($name_regex).')) OR (reference_field='.$this->database->Quote($type.'_name').' AND value REGEXP '.$this->database->Quote($name_regex).'))';
			}
			$query = 'SELECT reference_id FROM '.hikashop_table('falang_content',false).' WHERE language_id='.(int)$lang_id.' AND reference_table='.$this->database->Quote('hikashop_'.$type).' AND '. $condition;
			$this->database->setQuery($query);
			$retrieved_id = $this->database->loadResult();
			return $retrieved_id;
		}
		

		static $elements = array();
		if(!isset($elements[$type])) {
			$condition = '';
			if($type == 'product') {
				$condition = ' WHERE product_type = \'main\'';
			}
			$query = 'SELECT '.$type.'_id as id,'.$type.'_alias,'.$type.'_name  FROM '.hikashop_table($type). $condition;
			$this->database->setQuery($query);
			$elements[$type] = $this->database->loadObjectList('id');
		}
		if(empty($elements[$type]))
			return false;

		$class = hikashop_get('class.'.$type);
		foreach($elements[$type] as $k => $v) {
			if(!isset($v->alias)) {
				$key = $type.'_id';
				$elements[$type][$k]->$key = $v->id;
				$class->addAlias($elements[$type][$k]);
			}
			if($elements[$type][$k]->alias == str_replace(':','-',$name)) {
				return $k;
			}
		}
		return false;
	}
to:
function getOriginalId($type, $name, $dynamic=false, $forceRefresh=false) {
		$lang = JFactory::getLanguage();
		$tag = $lang->getTag();
		if($this->falang) {
			$lang_id = $this->getId($tag);
			$condition = 'reference_field='.$this->database->Quote($type.'_alias').' AND value = '.$this->database->Quote(str_replace(':','-',$name));
			if($dynamic) {
				$name_regex = '^ *p?'.str_replace(array('-',':'),'.+',$name).' *$';
				$condition = '((reference_field='.$this->database->Quote($type.'_alias').' AND (value = '.$this->database->Quote(str_replace(':','-',$name)).' OR value REGEXP '.$this->database->Quote($name_regex).')) OR (reference_field='.$this->database->Quote($type.'_name').' AND value REGEXP '.$this->database->Quote($name_regex).'))';
			}
			$query = 'SELECT reference_id FROM '.hikashop_table('falang_content',false).' WHERE language_id='.(int)$lang_id.' AND reference_table='.$this->database->Quote('hikashop_'.$type).' AND '. $condition;
			$this->database->setQuery($query);
			$retrieved_id = $this->database->loadResult();
			return $retrieved_id;
		}

		if(!isset($_SESSION['hikashop_alias_cache']))
			$_SESSION['hikashop_alias_cache'] = array();
		
		if(!isset($_SESSION['hikashop_alias_cache'][$type]) || $forceRefresh) {
			$condition = '';
			if($type == 'product') {
				$condition = ' WHERE product_type = \'main\'';
			}
			$query = 'SELECT '.$type.'_id as id,'.$type.'_alias,'.$type.'_name  FROM '.hikashop_table($type). $condition;
			$this->database->setQuery($query);
			$_SESSION['hikashop_alias_cache'][$type] = $this->database->loadObjectList('id');
			if(!empty($_SESSION['hikashop_alias_cache'][$type])) {
				$class = hikashop_get('class.'.$type);
				foreach($_SESSION['hikashop_alias_cache'][$type] as $k => $v) {
					$key = $type.'_id';
					$_SESSION['hikashop_alias_cache'][$type][$k]->$key = $v->id;
					$class->addAlias($_SESSION['hikashop_alias_cache'][$type][$k]);
				}
			}
		}
		if(empty($_SESSION['hikashop_alias_cache'][$type]))
			return false;

		foreach($_SESSION['hikashop_alias_cache'][$type] as $k => $v) {
			if($_SESSION['hikashop_alias_cache'][$type][$k]->alias == str_replace(':','-',$name)) {
				return $k;
			}
		}

		if(!$forceRefresh) {
			return $this->getOriginalId($type, $name, $dynamic, true);
		}

		return false;
	}
in the file administrator/components/com_hikashop/helpers/translation.php
That will move the cache of the aliases in the session instead of in a static variable. That way, the system will only have to load that table of aliases once per user session. So the first product page displayed will be slow, but after that, it should be fast again.
Could you try the modification on your end ? Does it help ?
Unfortunately, I don't see a solution where we wouldn't need to load the aliases table in memory in such cases.

Last edit: 2 years 8 months ago by nicolas.

Please Log in or Create an account to join the conversation.

  • Posts: 215
  • Thank you received: 6
  • Hikashop Business
2 years 8 months ago #340253

The first simple solutin works, but if to use it, then there will be seo problems with search engines,
and we need to configure the web server to redirect, we don't know how to do it right yet.

I'll try second modification and will answer you about it a bit later

Is it possible completely disable the translation function in the router ?
Or to add condition smth like $condition = ' WHERE product_type = \'main\ and product_alias = $variable'';
there $variable is product alias from url ?

$condition = ' WHERE product_type = \'main\ and product_alias = '\'.(explode(':',$name))[1].''\ ';
on line 148 translation.php v4.5.0 and now it takes more less ms for Application: afterRoute

Last edit: 2 years 8 months ago by Bender.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 8 months ago #340255

Hi,

Doing that solves your problem since you only load the product if the alias in the hikashop_product table matches with the alias in the URL.
However, this break several things:
- you can't use the product_name as the alias
- you can't use translated aliases anymore as aliases
- you can't use translated product names as aliases either
So basically it breaks more things than it solves.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 8 months ago #340285

Hi,

I've worked on this a bit more. I've updated the code of the function in www.hikashop.com/forum/install-update/90...0-update.html#340239 so that it works properly.
So if you're testing the changes, make sure you use that new version.

Please Log in or Create an account to join the conversation.

  • Posts: 215
  • Thank you received: 6
  • Hikashop Business
2 years 8 months ago #340295

Applayed the code of the new version, it seems to work. We'll test.

Would you make a toogle switcher in Hikashop settings to disable utilize multilang completely?
We're not sure what we're actually using these features:
- you can't use translated aliases anymore as aliases
- you can't use translated product names as aliases either

We gonna upload more products so website's quick response prefferable for us

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 8 months ago #340304

Hi,

Well, if my modified code solves the problem for you, then I don't see why a toggle would be necessary anymore ?

Please Log in or Create an account to join the conversation.

  • Posts: 215
  • Thank you received: 6
  • Hikashop Business
2 years 8 months ago #340354

If to increase the number of sessions and the number of products, the new modified code, still face slow Hikashop and high server loads, also still first interaction of the page problem remains.

Such a switcher will give Hikashop's users (medium and big stores) which are not use the translation of aliases, Falang, etc. more optimization (rendering and router time, cpu time, disk space and so on) .

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 8 months ago #340362

Hi,

Why not. I'll look into it.

Please Log in or Create an account to join the conversation.

  • Posts: 215
  • Thank you received: 6
  • Hikashop Business
2 years 7 months ago #340400

Thank you

Please Log in or Create an account to join the conversation.

Time to create page: 0.110 seconds
Powered by Kunena Forum