News:

Support the VirtueMart project and become a member

Main Menu

Performance issue discovered on all VM versions

Started by stAn99, March 14, 2019, 13:19:04 PM

Previous topic - Next topic

stAn99

Hello, while building new server and hosting enviroment for a single site we discovered a huge performance issue with all current VM versions. the current VM version examined is VirtueMart 3.4.2

while doing tests on a dedicated server with apache benchmark:


ab -s300 -k -r -t300 -c50 -n50 https://yourdomain.com/


we discovered that using "rand()" within
\administrator\components\com_virtuemart\models\product.php

adds a few second load during out 50 concurrent visits testing !

we use:
- php7.3
- mariadb 10.3 + replication/binlog
- centos + cpanel + apache2.4-worker + fpm
- custom linux kernel 5
- sessions on ramdisk
- joomla's cache directory on ramdisk
- nvme hdds in raid1 + mq IO scheduler
- 1gbps dedicated ethernet card with guaranteed bandwidth
- 128gb ram (16gb preallocated for mysql + 16gb as tmpfs for each ramdisk)
- fpm dynamic with minimum concurrency 50 (start_servers)
- http2 + php file sessions

this is our suggested fix:

raplace all occurances of rand() :

$orderBy = 'ORDER BY RAND()';


with:

$orderBy = 'ORDER BY p.`created_on`';


there is one line that you may to leave as is IF YOU ARE USING RANDOM ORDER of products at category level which is ENABLED BY DEFAULT but not shown on most commercial templates (for this reason we also suggest the change as you may not be aware of executing this query per each category view)

so if you know that you really want to display random product, you may leave portion of the file "as is" :

case 'random':
$orderBy = 'ORDER BY RAND() '; //LIMIT 0, '.(int)$nbrReturnProducts ; //TODO set limit LIMIT 0, '.(int)$nbrReturnProducts;
break;


if you do not need, or plan to use the random order of the products intentionally you may just modify it as well:


case 'random':
$orderBy = 'ORDER BY p.`created_on` '; //LIMIT 0, '.(int)$nbrReturnProducts ; //TODO set limit LIMIT 0, '.(int)$nbrReturnProducts;
break;


further reading:
https://www.percona.com/blog/2018/12/05/nondeterministic-functions-in-mysql-i-e-rand-can-surprise-you/

best regards, stan
----
RuposTel.com
www.rupostel.com
Your customized checkout solution for Virtuemart