Multistore – How to Use Different Hosting Accounts for One Magento Engine

multistore

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?

Best Answer

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.

Related Topic