Page 1 of 1

Performance tuning tips

Posted: Sun Aug 08, 2010 7:11 am
by rich06
Hi All

I am preparing a OC (1.4.8) site that will have around 3-4000 categories and around 12 million products... just wondering if anyone has a similarly sized site and what (if any) performance issues were encountered...?

FWIW I have already some issues with the categories (which are quite heavily nested) build/display on the catalog index page and I needed to add an index on category.parent_id to get it to perform...

So anyone running a similar sized OC site that has any tips?

TIA
rich

Re: Performance tuning tips

Posted: Sun Aug 08, 2010 3:01 pm
by Xsecrets
I think that will be by far the largest opencart install, so you will be very much in uncharted territory. But some performance issues that I know of. The catalog dropdown from the search causes problems sometimes. There are several tables that need to have indexes added to product_id (these are going to be added in 1.4.9). Beyond that who knows what you will run into with that large of a database. Just out of curiosity how are you going to get that many products into the store, and what in the world are you selling with that many products? I think amazon only has about 2 million products.

Re: Performance tuning tips

Posted: Sun Aug 08, 2010 5:36 pm
by i2Paq
Whas there not a mod/topic somewhere that addressed the same question/issue?

This Is what I've found:
Caching of categories:

in catalog/controller/common/header.php
Find:

Code: Select all

$this->data['categories'] = $this->getCategories(0);
 
Replace with:

Code: Select all

    $category_tree_data = $this->cache->get('categories.0');
        if(!$category_tree_data) {
          $category_tree_data = $this->getCategories(0);
          $this->cache->set('categories.0', $category_tree_data);
        }
        $this->data['categories'] = $category_tree_data;
 

in catalog/controller/product/search.php

Find:

Code: Select all

$this->data['categories'] = $this->getCategories(0);        
 
Replace with:

Code: Select all

        $category_tree_data = $this->cache->get('categories.0');
        if(!$category_tree_data) {
          $category_tree_data = $this->getCategories(0);
          $this->cache->set('categories.0', $category_tree_data);
        }
        $this->data['categories'] = $category_tree_data;
 
After this you will find in system/cache/ a file called cache.categories.0

Re: Performance tuning tips

Posted: Mon Aug 09, 2010 12:25 am
by Moggin
Xsecrets wrote:Just out of curiosity how are you going to get that many products into the store, and what in the world are you selling with that many products? I think amazon only has about 2 million products.
:o I was about to ask - are you Amazon, rich06? : ) I guess you won't be typing all the products in via the admin panel.
Good luck, and tell us how it goes.

Re: Performance tuning tips

Posted: Mon Aug 09, 2010 3:09 am
by JAY6390
lol that many products will take days to insert even automated

Re: Performance tuning tips

Posted: Mon Aug 09, 2010 4:17 am
by Moggin
:) Too right! I feel like a yokel chewing a straw, but this has really piqued my curiosity. 12 million products..

Re: Performance tuning tips

Posted: Mon Aug 09, 2010 5:43 pm
by rich06
Thanks for the tips everyone..! The site will be an online bookstore and the client has subscribed to a data feed service that catalogs every book title published in the US and UK -- I have prepared a multi threaded database load script when the supplier provided some sample data but the real data will be delivered to the client next week sometime so that will be the first time I will use my script in anger ... gulp!

The data suppliers advised me below...

>>The counts for last month’s load were as follows. You can expect a slight increase.

>>US=6,518,319
>>UK=4,372,571

Incredible numbers which I too find hard to believe but there you go...
Will keep you posted, but any other tips - apart from run away...! :) - will be gratefully received.

Rich

Re: Performance tuning tips

Posted: Thu Sep 16, 2010 6:17 am
by rich06
Just an update on this OC install if anyone's interested... :)

Once my data load process had finished the product/product_description tables have 7.1m records (a few million less than originally anticipated thankfully).

Naturally the code/database hit many brick walls with this volume of data and I have resolved many by adding indexes and denormalising where necessary and changing the database design with associated code changes.. still have loads to do I will need to integrate the OS Sphinx search engine (http://sphinxsearch.com/) for keyword searches as MySQL fulltext indexes can't really cope ...

Just want to say that OC code is very well organised and very easy to understand how it hangs together which has made my task a damned sight easier.

Fun times :)
Cheers
Rich

Re: Performance tuning tips

Posted: Mon Mar 14, 2011 8:20 pm
by lotek
Hi Rich
Are there any news/updates about your performance optimizing stuff? Is it possible to see how you integrated sphinx (or available as extension?). Just curious.

bye
Marcel

Re: Performance tuning tips

Posted: Mon Mar 14, 2011 9:09 pm
by mystifier
Opencart is multi-store. This could be thought of as mulit-department which all come under one store with different templates for each (eg different colour for each department) with everything managed by a single admin.

It is an extra level of hierachy that I think could really help a very big shop with both product organisation and performance.

Re: Performance tuning tips

Posted: Sun Mar 20, 2011 1:01 am
by rich06
lotek wrote:Hi Rich
Are there any news/updates about your performance optimizing stuff? Is it possible to see how you integrated sphinx (or available as extension?). Just curious.

bye
Marcel
Hi Marcel

Well I downloaded and compiled Sphinx v0.9.9 http://sphinxsearch.com/downloads/release/ and I also installed the sphinx client PECL extension http://pecl.php.net/package/sphinx. Then it was a case of looking at what search options were to be made available to the site user -- as my site was an online book store the search options were

Author name
Title
Multiple ISBN numbers
Publisher
Categories

Then it is a question of defining the SQL queries to obtain the required results and putting them in the sphinx configuration file so it can build the indexes based on the queries. Below is an example:-
source getProductsByPublisher
{
type = mysql
sql_host = xxxxx
sql_user = xxxxx
sql_pass = xxxxx
sql_db = xxxxx
sql_port = 3306 # optional, default is 3306
sql_sock = /tmp/mysql.sock

sql_query = \
SELECT p.product_id, m.name \
FROM product AS p \
INNER JOIN manufacturer AS m ON (m.manufacturer_id = p.manufacturer_id)

sql_query_info = \
SELECT p.product_id, m.name \
FROM product AS p \
INNER JOIN manufacturer AS m ON (m.manufacturer_id = p.manufacturer_id) \
WHERE p.product_id = $id
}

In my case as the product data is loaded by a batch process I had to rebuild the sphinx indexes after each load process using the sphinx tool as follows --> <installdir>/bin/indexer --all. Also the sphinx listener daemon (searchd) needs to be running which passes data between Opencart and the sphinx engine however it must be shutdown when the re-indexing operation is running.

Next the Opencart product model code needs to be altered to use Sphinx rather than querying the MySQL database directly -- below is an example:-

$sphinx = new SphinxClient; // Instantiate PECL client
$sphinx->setServer('hostname',9999); // Hostname and port number that searchd is listening on

$mode = (strpos($keyword,'"') !== false ? SPH_MATCH_PHRASE : SPH_MATCH_ANY); // See if a phrase is being searched for

$sphinx->setMatchMode($mode);
$sphinx->setMaxQueryTime(100);
$sphinx->setLimits(0,2000,0,0);

// Get results from sphinx
$results = $sphinx->query($keyword,'getProductsByTitle');

$results['matches'] will contain an array of product ID values of all the matching products so when the Opencart query is issued the query's 'WHERE' clause should have added 'AND product.product_id IN (999,999,999) where 999 is the imploded list of IDs returned from Sphinx. There is also a command line tool (bin/search) supplied with Sphinx to test search queries.

In my case the products table is around 8.5 million rows now and sphinx performs really well so it is definitely worth using if you have a large product table.

Hope the above is of interest!
Cheers
Rich

Re: Performance tuning tips

Posted: Wed Sep 07, 2011 7:33 am
by Leszekem
Amazing!!

Re: Performance tuning tips

Posted: Sat Sep 10, 2011 1:13 am
by rich06
rich06 wrote:
In my case the products table is around 8.5 million rows now and sphinx performs really well so it is definitely worth using if you have a large product table.
Make that 12.5 million rows now.... :)

Rich

Re: Performance tuning tips

Posted: Sat Sep 10, 2011 4:10 am
by Moggin
rich06 wrote:
rich06 wrote:
In my case the products table is around 8.5 million rows now and sphinx performs really well so it is definitely worth using if you have a large product table.
Make that 12.5 million rows now.... :)

Rich
Not a word I use frequently, but that is awesome. :D

As a side note - I'd love to see Sphinx integrated as part of Opencart some time, or maybe as an extension.

Re: Performance tuning tips

Posted: Sat Sep 10, 2011 5:47 am
by Xsecrets
Maybe an extension, but you can't integrate something they you are guaranteed almost no host will ever have installed by default into the core.

Re: Performance tuning tips

Posted: Sat Sep 10, 2011 7:46 am
by Moggin
Xsecrets wrote:Maybe an extension, but you can't integrate something they you are guaranteed almost no host will ever have installed by default into the core.
Ohh, point taken. So for technical reasons it's not a runner (as we say over here). I guess I've only read about what it can do, not how it's installed.

Re: Performance tuning tips

Posted: Tue Oct 11, 2011 6:37 pm
by aledmann
Am I the only one interested in actually seeing the site? URL please!! ;D

Re: Performance tuning tips

Posted: Thu Dec 22, 2011 1:31 pm
by vivek.g
Hi Rich,

Really interesting site...plz share the URL.

Regards,
Vivek

Re: Performance tuning tips

Posted: Mon May 06, 2013 11:15 pm
by coalesce
There is Sphinx Search module for Opencart FYI

http://www.opencart.com/index.php?route ... n_id=11734