Page 1 of 1

Performance issue discovered on all VM versions

PostPosted: Thu Mar 14, 2019 2:17 pm
by admin
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:

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


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

adds 3 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() :
Code: Select all
$orderBy = 'ORDER BY RAND()';


with:
Code: Select all
$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" :
Code: Select all
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:

Code: Select all
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 ... prise-you/

best regards, stan