Friday, September 3, 2010

Understanding Magento Scalability and Performance

Monday, July 6, 2009, 21:42
This news item was posted in Conversion, How To, Magento, News, Optimization, eCommerce category and has 0 Comments so far.

image

Performance and scalability are hot topics for any enterprise application, and this is especially true of Magento. Our clients are usually impressed with the features and extensibility of Magento, but there is a worry in the background if the platform can scale to many thousands of orders per day or huge catalogs. This worry is partly because early versions of Magento had some issues with performance, and competitors used this as an argument in favor of their product. But it is also true that getting Magento to be fast and scalable requires some knowledge of the underlying software stack – such as the web server and PHP configuration – and a little custom development to optimize Magento’s caching for your specific use case. This article focuses on getting the most out of a single server, or virtual machine; as you will see, this can take you very far already.

Visions works mostly on large projects and these invariably involve consultancy on infrastructure, performance and the like. There are two concerns: first, everybody wants to have the shortest loading time possible, which is what we mean by performance. Amazon and Google did some research on this, and found that a hundred milliseconds of delay can already reduce conversion rates. Performance is important for projects large and small, so we will take about in some depth.

The second problem is scalability, namely: will my shop remain fast when there are visitors on the site? Think of this is as the online analog of standing in line at the cashier: if you are the only consumer, you can go to pay directly – so performance is good. But when there are many consumers, everybody has to wait to get his turn; in other words, a single cashier doesn’t scale to a large supermarket.

Clearly, the two are related – if you give the cashier a better till, performance will improve further and queues get a little shorter. But even the best till will only take you so far, and sooner or later you need a second cashier. In the Magento world, this means offloading some parts of the shop to a separate server, or even moving to a fully-fledged cluster system. Setting up a cluster system is difficult and can take a lot of time. We’re not going to cover it here; instead, our focus will be to get the maximum possible scalability and performance out of a single, suitably-sized server.

In essence, I’ll walk you through the steps we at Visions take when we do infrastructure consultancy in such settings. First, I will show you some configuration tweaks that will let you score some easy wins. We then take a look at two tools that help you understand where the loading times of your Magento come from, and estimate how scalable your deployment is.

Now that you have some numbers, you want to improve them. We’ll discuss three of them: switching your web server to use FastCGI instead of mod_php, enabling Block Caching for selected Catalog and CMS blocks, and convincing your designers to make fewer HTTP requests per page load.

Most of the time, this will be more than enough to get a snappy Magento shop that scales to some serious visitor numbers per day. If your project is larger still, we’ll leave you with a few pointers for what you can do next.

Easy Wins

Be sure the Magento caches are enabled

MySQL comes with a query cache, which can save the result of SELECT queries for short periods of time – that is, until some change is made to the database. How much benefit you get from the query cache depends strongly on the kind of application you use – this is why the query cache is not turned on by default. When it comes to Magento, tests have shown again and again just how much extra scalability you get if it is enabled. To enable query caching, go to your my.cnf and set the following options in the mysqld section:


query_cache_type=1

You can leave a response, or trackback from your own site.

Leave a Reply