I am recently working on a few Magento projects that require serving large volume of concurrent end users (e.g., more than 200 visitors at the same time). I have to say Magento is quite a resource consuming platform although it is quite popular, hence it’s better to make sure your Magento performance is as good as it could be.
In these few days, I am going to write down some of my experiences as well as some hosting partners that I was working with to explain how to optimize Magento performance and how to architect the servers.
Hardware that affects Magento Performance
As hardware is always first concerns of Magento performance.
The first thing your customer would raise when their projects are about going live is: What kinda of hardware do we need to server xxx amount users per second during the peak time?
In order to answer this question, you will need at least to figure out what kind of CPU you will need and how many, How many RAM you will need, How many disk space you will needs, let’s see how to calculate:
First of all, I have to say, the better (more) the CPU you have the good performance you will get. While I am writing this article, we are using Intel quad core Xeon CPU running at about 2.4GHz
For web server, You will want 500MB for OS itself, at least 200MB for APC, this is nearly about 700MB off even before starting Apache. Each PHP process for a Magento site under Apache requires roughly 200MB of memory. The total amount of memory in a server will affect the value that MaxClients/ServerLimit can be set to in Apache. The number of concurrent users you can support on a single dedicated web server is roughly 125% of the value that you can set MaxClients to. With multiple web servers (making proper use of memcache), the number of concurrent users is roughly 150% of the value that you can set MaxClients to.
Due to Magento’s CPU intensive nature makes it difficult to scale a single server up. You need to maintain a ratio along the lines of 1 CPU core per 4 GB of memory. This puts an artificial limit on how much memory should go into each individual web server. If a customer wants to minimize the number of servers used to deploy Magento (to limit their costs on the Magento license), we may need to recommend servers capable of supporting more than eight cores in order to allow them to scale up within each web server.
For database server, If a customer does not know how large their data set will be, assume a minimum of 8GB of RAM will be used by MySQL. If the customer knows the size of their data set, the memory requirement is 200% the size of the volume of InnoDB data plus about 4GB. Magento recommends that the innodb_buffer_pool_size be set to either 2GB or 200% of the size of the customer’s InnoDB data (whichever is larger). Additional memory is required for both MySQL’s shared caches (such as the query cache) and for the per-connection overhead of MySQL itself. For Cloud Servers, it is critical that devices have the appropriate amount of RAM to take advantage of caching and minimize the need to hit disk.
- The two biggest contributors to storage needs for a Magento deployment are the number of SKUs in the customer’s catalog and number of orders the database will store. Magento does not have good average sizes for either of these record types available to help size configurations. This is the missing component referred to in the intro paragraph above.
- CPU requirements are not typically as high for DB servers as they are for the web servers in Magento deployments. With MySQL properly tuned (just the basic tuning Support can provide), four CPU cores are frequently adequate for deployments with less than 500 concurrent users.