I have a task to create upto ten different webstores with general admin panel. Each webstore has own account and own prices. But catalog and product are almost the same.

If I would use one server, it should be very expensive one. I would like to create one server for magento DB and each webstore must has own server and domain name.

  • 100 store views
  • Each store has 1000 visitors per day
  • Each store has 1000 categories
  • Each store has 2000 products

But I'm not clear enough how to do it? We should sync files somehow then...or not?

  • One of the big bottlenecks will be the size of the configuration XML for all the store views. Fabrizio has been working on an optimization for this, not sure if it's published or not, but you may want to check that out - fabrizio-branca.de/magento.html - he was working on getting it into the core this weekend at the bugathon. Mar 11, 2013 at 15:01

3 Answers 3


Using the multistore setup for Magento will allow you to run more frontends using the same codebase. First step would be defining the storeviews. Then you can define env variables via htaccess/httpd.conf so Magento can serve the right content based on the accessed domain:

SetEnvIf Host .*site.* MAGE_RUN_CODE=storex

This would be your starting point. For a while, you may be able to handle all the load using a single frontend. If you find that you need more, there are a few steps you need to take:

  1. Have a distributed cache backend, so all servers share the same cache. Memcache works great, there are a lot of tutorials on how to install Memcache and make it work with Magento
  2. Share the media files. You will have to share the media/ and var/ directories between all servers. I'd recommend using NFS, but there are many more ways to do this.
  3. Have a way to deploy the code. Since you want to make sure the code is the same on all servers, you'd have to do better than manually upload the code to all servers. A simple script to grab the code from the repository will do, but you can use third party services too. I personally am very happy with Beanstalk as a code deployment solution. Of course, you could just share all the root directory with NFS too.
  4. Have a load balancer. If you have multiple servers, you'd need to split the traffic between them. Again, a lot of options here. You can use third party services or do it yourself with something like pound.

The main point here is that you should start low. No point in having a server per frontend. You can start with 2 servers (so you have the multi-server setup in place) then scale based on traffic.

A more painful thing todo would be database scaling. You can easily spread frontend load as described, but they would still hit the same database. You can create a mysql master-slave setup and configure Magento to spread the reads. I'd recommend buying/renting the best hardware you can afford first though, it is way cheaper to scale the database vertically than horizontally.

  • thanks your detailed answer! so I the better way is one server for memcached and media, one for DB and one for each store, right? Which of these servers could take more traffic than others?
    – Anthony
    Mar 10, 2013 at 20:01
  • I think one server for the db and one for Memcache is ok. As for the frontends, in the setup I have described any of them can serve any store (as Magento will just display the right store based on domain) so there is no 1 to 1 relation between them. One single frontend should support quite a few 1k vistiors/day websites. I'd start with 2-3 frontends and go up if needed. As for load, the database will be by far the most loaded. Mar 10, 2013 at 21:24
  • Good point regarding the approach with a smaller number of web servers (start with 1-2 then see how it goes and increase the webservers). Memcache performs better than writing to disk, but you will soon run into alot of issues beucase of the size of the cache. NFS share - this will be a bottleneck (i/o, network). nfs for code sharing at this volume of traffic - again bottleneck. Many webservers connecting to the same db at that traffic - again network is the bottleneck. Anyway, you'll see the issues when you actually have that running. Mar 12, 2013 at 10:49

I would do it like this:

1) Set up a server running Varnish (Varnish will forward the request to the corresponding node based on the URL):

 if (req.http.host ~ "www.store1.com") {
       set req.backend = server1; }
  elseif (req.http.host ~ "www.store2.com") {
       set req.backend = server2; }
   else  {set req.backend = defaultserver;}

2) Set up a single file server that holds all your Magento code: Basically what you do is create a directory /var/whatever/you/want and put all the Magento code inside. After that you "simply" create an NFS share of this folder. (See here for a detailed guide)

3) Set up several webservers[/apache?] (one per store): This is where you mount the NFS share you just created above.

4) Mount the Magento folder from the file server onto each node (using NFS?)

  • How do you hold all magento code at one server?
    – Anthony
    Mar 11, 2013 at 12:20
  • I have added more information for the 2nd point.
    – Kenny
    Mar 11, 2013 at 15:45

Magento has a great Multi store architecture. With Magento Multi Store architecture optimum way is to just have one Db and One code set. This means all sites to be hosted on same server.This is not a compulsion but recommendation.

You will need to have copies of index.php files and .htacces for each website/store. Some sym link for images etc. Also you will need some open base dir restrictions taken care of.

If you use this setup then just adding one extension or customizing Magento one code set will make it available for all stores. Which means lesser maintenance and Magento has built Multistore with that thought.

Following link : http://www.magento-exchange.com/installation-and-configuration/magento-multiple-stores-setup-with-different-look-and-feel/ will be of some help.

  • You talk about one server. But I cannot use one server because we have too much webstores. For example we have 100 webstores and each has more than 1000 visitors per day. At the same time we have 1000 categories per webstores and more than 2000 products. It means I need or clusters or different hosting place....so the question was is it possible to do on different hosting?
    – Anthony
    Mar 10, 2013 at 17:50
  • yes in that case you will have to have same set of code base on different server but one data base.Here in your db connection node of xml make sure you place proper value.I doubt this setup will really do well in production.As any difference in code set will result in modules firing installer etc.You will need to take images from some folder on main store as admin is in main store so images uploaded will be going there.Such a huge data base handling during indexing will need a good configured setup. Mar 10, 2013 at 18:17
  • There is no need for separate index.php file. Magento uses the MAGE_RUN_CODE environment variable for a while that will allow you defining the store at Apache/web server level. Also, no need to have one server per store. Sharing the files via NFS, using memcache and same db will allow you to scale frontends up and down with no relation to the number of frontends, your only concern being how much load can you take. Mar 10, 2013 at 21:28

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.