9

I am trying to find a way to improve Magento performance when the amount of websites/ stores exceeds 1k, and my goal is around 10k. Here are some questions; any tips/ helps are extremely welcome!

  1. Adding new websites/ stores is slow;
    I comment out $this->cleanModelCache() in _afterSave() in Mage_Core_Model_Abstract, and the situation seems better but is getting slower with increasing number of websites/ stores. And I don't know what would this affect the whole system in the future.

  2. Api calls become slow.
    One of the main processes is to place order; my customized model deals with it by processing some data, and essentially using sales/quote model and sales/service_quote models. The process begins with Oauth. Both Oauth and placing order take longer when the number of website/ store grows, and the memory consumption seems larger. Does this have something to do with Mage loading the config xml, and the fact that config data gets bigger with increasing number of websites?

  3. Opening up n98-magerun dev:console is taking longer; don't know the cause of it.

  4. Saving configuration from admin panel takes longer; don't know how to improve it.

Is it possible to reconstruct the way Magento generate and load config data to lower its memory consumption? Is this one of the factors that cause performance issue for my situation?

Current Magento instance: Version = Magento EE 1.14.2.4;
Config cache on; other cache off;
Using Mysql 5.6 and MongoDB( for catalog_category_entity, catalog_product_entity, core_website);
number of websites = number of stores = number of views = 1024;
number of product = 4501;

Thank you all in advance!

7
  • 2
    why magento support can not help you???
    – MagenX
    Commented Jun 23, 2016 at 8:03
  • How do I get help from them? I am new to the community.. thanks!
    – Jack.W
    Commented Jun 23, 2016 at 16:46
  • 1
    you have enterprise version, not sure where you get it, but if there is no magento support behind it, just wasted money and time. you must well hit them in the balls to make them run like rabbits helping you. what is the point in having enterprise version???
    – MagenX
    Commented Jun 23, 2016 at 21:16
  • 1
    but obvious answer to your query is - separate magento shops with separate databases, like batches per 10-20 shops...
    – MagenX
    Commented Jun 23, 2016 at 21:22
  • Ah right.. I am gonna ask my boss for the account..haha.
    – Jack.W
    Commented Jun 23, 2016 at 21:26

2 Answers 2

3

One of the reasons it gets slow is because the configuration for each store is duplicated from /config/websites and /config/global and the code for doing that is not efficient in the least. Any setting change may end up causing several 10's of minutes, if not hours, of reduced performance and throughput. Making it more efficient will basically mean that Ben Marks will come after you... and not in a good way.

IF you are going to go down this route the easiest way would be to have 10k Magento installations and have some kind of a broker that delegates requests to the appropriate website. Though it will, of course, depend on what your actual use case is.

[added]

Depending on the use case you might be able to use categories as pseudo stores. You could technically then use layout XML to change the theming per store. But then you would run into the limitation of checkout. All stores would need to share the checkout.

Either way, 10k Magento stores is do-able, in that it is not impossible. But it will be a difficult road whatever path you choose.

7
  • Hi Kevin, thank you for your reply! Yes I see the code that updates config tree, which is loadToXml() if I am not wrong. My thought is; and you said it is not a good idea to modify it? What do you mean by Ben Marks coming after me? Also, it seems that each http request that comes to Magento will eventually load config tree, is that correct? Any way that I can shrink the size of it? I should probably think about getting 10k Magento instances... any thoughts on how much resource that would need? Thank you very much Kevin!
    – Jack.W
    Commented Jun 23, 2016 at 16:54
  • But having 10k Magento installations means 10k mysql instances right? I have no idea how to do this, or if it is a good idea..
    – Jack.W
    Commented Jun 23, 2016 at 17:02
  • 1
    No, it would mean having 10k mysql databases, but all 10k of them could be in a single mysql instance.
    – Christian
    Commented Jun 23, 2016 at 17:43
  • 1
    The "Ben Marks" coming after you is a reference to this camo.githubusercontent.com/… Commented Jun 23, 2016 at 20:23
  • 1
    10k Magento installations means 10k MySQL databases, however that would be spread out. It would be MUCH easier to script deploying 10k individual Magento installations than it would be to make the existing core code work with 10k stores. Commented Jun 23, 2016 at 20:25
1

You can try hacking the core and enabling website cache splits. You can try hacking the database and storing configuration information in memory. You can try replacing the configuration cache with something smarter - say caching the information from the xml files[which are static and apply to all websites and stores] while retrieving the override data dynamically.

I'm a server guy, so I'd go with mucking with the database. Especially since it is trivial to do.

If you have control over your database server: Rename the core_config_data table to core_config_data_offline Create a new core_config_data table using the MEMORY storage engine http://dev.mysql.com/doc/refman/5.7/en/memory-storage-engine.html Copy all the data from core_config_data_offline to core_config_data

Setup a cron job to check to see if core_config_data exists, if it does copy all the data from there to core_config_data_offline. If it does not, create it and copy everything from core_config_data_offline to core_config_data

Turn off the config cache. With the config cache turned on, you only get a performance boost for the first time config data is read from the database - after that it is in the cache and you suffer. On the downside the xml files are no longer cached, so you traded the performance hit of unserializing huge configuration data for the performance hit of parsing a bunch of xml files.

You may also want to experiment with changing the Mage/Core/Model/Config.php file and enable individual website caches. By default each store specific configuration data is cached individually. All the website configuration data is cached in one object.

Note that this is just for the configuration overrides[the admin settings]. So if you do all your configuration changes at the store level your already set. If your using "inherit from website" and making most of your store specific configuration changes at the site level - then the cache contains every website. By splitting it you can break it out much better. protected $_cacheSections = array( 'admin' => 0, 'adminhtml' => 0, 'crontab' => 0, 'install' => 0, 'stores' => 1, 'websites' => 0 );

to

protected $_cacheSections = array(
    'admin'     => 0,
    'adminhtml' => 0,
    'crontab'   => 0,
    'install'   => 0,
    'stores'    => 1,
    'websites'  => 1
); 
13
  • Hi Gary, thank you for such a helpful reply! I have some questions: 1) From my observation, database query is not an issue, even with over 1k websites/ stores; so if that is the case, would using memory storage still help? 2) I don't know if it is correct, but config cache seems to store only system and modules information; so does it have something to do with website/ store configuration? 3) Is there a way for magento to recognize a specific store/ website id from an http request, and thus load only the corresponding config file? Thank you very much Gary!
    – Jack.W
    Commented Jun 23, 2016 at 17:48
  • 2
    These recommendations don't address the problem the OP was noting. Turning off the configuration cache will ultimately kill the system. It will cause Magento to load up all of the configuration files, merge them, then merge all of /global then merge all of /websites and then merge all of that into each /stores node. That will happen for EACH request. With 10k sites you could be looking at minutes of wall clock time per request. Commented Jun 23, 2016 at 20:22
  • Hey Kevin, thanks for the reply; Actually I am planning to move the core_config_data table into the memory, enable cache for system and module config, stop core_config_data from being merged into the config tree, and make functions that read this part of data directly query from database. What do you think?
    – Jack.W
    Commented Jun 23, 2016 at 21:25
  • 1
    The problem is not core_config_data. The problem is that store configs are merged from /websites which are merged from /global in XML The database will be perfectly fine. It is PHP that will be hating life because of the configuration merges. In your debugger step through Mage_Core_Model_Resource_Config::loadToXml paying special attention to lines 110 and following Commented Jun 23, 2016 at 21:36
  • 1
    Now to come back to my memory table. Caching data means to store it somewhere that can be accessed quickly. Magento caches configuration data into a php serialized object - if your configuration data is huge that means PHP has to deserialize a huge amount of data for every request. If you know how to use xdebug, profile some of your slower page loads and look at how much time is spent running the unserialize function: php.net/manual/en/function.unserialize.php - if it's huge[over 100ms] then "caching" the configuration is breaking your system.
    – Gary Mort
    Commented Jun 28, 2016 at 21:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.