When it comes to an enterprise solution, performance and scalability are the most important aspects, it’s the same with Magento. Magento is known to bring out the best in your eCommerce website. Even though most of the eCommerce website owners are happy with the utilities provided by Magento, there are some concerns regarding the scalability of Magento at a level where a large number of orders can be executed and huge catalogues can be accommodated. In order to make your Magento store more scalable, all you need is a little information about the software stack and the process of custom development for optimizing the performance of Magento. This post will provide you information with getting the most out of a single server or a virtual machine.

The quick fixes mentioned below are very efficient and in most of the cases they will be sufficient for providing more scalability to the Magento shop. Along with selecting the best website hosting for business, it is important to implement these quick fixes for the Magento store for making it more efficient. Your Magento store will get the ability to scale some serious visitor numbers on a daily basis.

Make Sure That The Magento Caches Are Enabled

MySQL comprises of a query cache that can save the result of the ‘SELECT’ queries for a short span of time, until any changes are made to the database. The amount of benefit that you can receive from the query cache is strongly dependent on the kind of application you use – this is the main reason why the query cache is not turned on by default. In case of Magento, many tests have been conducted that show how extra scalability can be achieved by enabling this option.

In order to enable query caching, go to you’re my.cnf and set the following options in the mysqld section:

query_cache_type=1
query_cache_size=64M

Now save the changes and restart the MySQL server – You will notice that you are getting more requests per second once this change is made!

Enable Expires Headers

The cache feature is used by the browsers extensively. This feature of your browser can safeguard many elements included in the website locally so that they can be served from the browser’s cache instead of creating a new request in the web server. This can be a substantial move for reducing the load times. The only issue here is that the browser must know when a particular file can be served from the cache and when not; as the local copy is outdated. In order to solve this issue, the browsers depend on two HTTP headers – Expires and Cache-Control.

The default ‘.htaccess’ provided by Magento already configures the file in accordance with the Yahoo’s Performance Recommendations; however it does not enable them by default. In order to enable them, you will have to add the following commands to your Apache Server Configuration (generally found in /etc/apache2/apache.conf.)

<IfModule mod_expires.c>

ExpiresActive On

</IfModule>

In case you don’t have the access to server configuration, you can also add the commands mentioned above to the ‘.htaccess’ file. However, while performing this process it is important to ensure that the changes do not get lost.

Use APC As The Cache Backend

By default the Magento cache data is stored in the file system. This is usually appropriate for the small websites, but as your website expands and starts getting more and more requests, the functions like reading and writing to the file system become slow. This specifically holds true in case your Magento is stored on a network drive. In case you are using APC, you can improvise on the output of Magento by storing the cache data in APC’s cache instead. Open the app/etc/local.xml and add the commands mentioned below:

<global>
<cache>
<backend>apc</backend>
<prefix>MAGE_</prefix>
</cache>
</global>

Save the changes that you have made and make sure to refresh the configuration cache through the admin panel.

Measure Your Magento – Stimulating real time users with Siege

Siege is an open source tool developed in Perl programming language that enables you to simulate the visitors who are surfing your website. This is a great way to find out the amount of load that can be handled by your application server, given its current configuration. Some of the administrators and developers determine the scalability of their website by over loading the server with requests. Basically, this goes on to say that a single URL is called again and again in order to check how many requests get through in one second. This can also be done with the Apache Benchmark tool ab2.

A problem with this technique is that the behavior of the real users does not have a fixed pattern, therefore the numbers you get are highly misleading. First you enable the caching tool, ab2 that will tell you about the scalability of your application in case the cache hit rate is nearly 100%. The reality is that the hit rate will be lower as the visitors move to different pages on the website at the same time; this proves that ab2 overestimates the scalability.

Having said that it is also true that it is difficult to interpret the numbers you get. For instance, let’s say that your server has the capacity to handle only 5 dynamic requests per second; does this mean that you can only have 5 people browsing your website simultaneously? Ofcourse not! The rate at which humans move on the website is slower as compared to the benchmarking tool. The number of sessions that your server can make is difficult to estimate as it depends on a number of factors. Simulating the user sessions directly is the most appropriate solution for this issue, and using a tool like Siege is highly recommended before you make the Magento store live.

Performance and scalability are the most crucial aspects for any website. The pointers mentioned above will enable you to get more out iof the existing Magento infrastructure.