What is the simplest two web server, single DB load balancing?

Will this work for community out-of-the box?

I assume, at minimum, I would have to store sessions in the database rather than filesystem?

Any other considerations?


The simplest server would be the following:

1 Load Balancer

2 Web Servers

1 DB server

As far as session storage goes, it is not recommended to store in the Database. While it is fully supported, it places an additional load on the DB. Redis or Memcache would be better suited for this task. They are also fully supported out of the box for Community Edition.

A couple of tips:

  1. Have both web servers leverage bytecode caching such as APC or OPCache.
  2. Strip Apache of all unused modules to optimize memory consumption. By default, you should only need mod_php, mod_expires, mod_deflate, mod_mime, mod_dir, mod_authz_host, and mod_authz_user.
  3. Configure your dedicated database server to maximize innodb_buffer_pool_size, query_cache_limit, query_cache_size, thread_cache_size, max_connections, and thread_concurrency.

A few more tips (your results may vary):

  1. Have the Load Balancer set to Round-Robin instead of Sticky sessions, (random distribution of load).
  2. Turn off AllowOverride All and place your .htaccess values inside of your VirtualHost configuration for apache (fewer file requests).

There are guides available from Magento to give you more details about configurations: http://www.magentocommerce.com/whitepaper/

  • 1
    Small correction, round robin isn't even distribution. It's randomized, which means there will be streaks favoring a server. Tip: if you can afford it, deploy the commercial version of nginx for this task. It's upstream selection utilities are phenomenal. – Melvyn Feb 9 '15 at 18:16
  • @RyanStreet Thanks for the tip, as a Magento beginner i wonder if there is a step by step tutorial for this (it'd be nice if it is done in AWS). – Jeremy Apr 29 '16 at 16:46

Centralized cache and sessions. Magento comes with optional Redis storage backends for those. Only one node can run updates. Parts of or all of media may need to be shared because of just in time image resizing and or JS/css merging (the generated result may be requested from the other server).

Those are the key issues I can think of, let us know if you have specific questions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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