Book Image

Instant Magento Performance Optimization How-to

By : Nayrolles Mathieu (USD), Mathieu Nayrolles
Book Image

Instant Magento Performance Optimization How-to

By: Nayrolles Mathieu (USD), Mathieu Nayrolles

Overview of this book

The optimization of an attractive commercial website is a non-trivial task that demands time and knowledge. Optimization is a critical point for all growing businesses because a misconfiguration could make you lose money, a lot of money. If your server is overloaded, a browser that wants to turn into a buyer will not be able to, and you will lose customers. "Instant Magento Performance Optimization How-To" is a practical, hands-on guide that provides you with a number of clear, step-by-step exercises to help you reach a high performance level for your Magento stores and keep your customers satisfied.This book looks at tweaks and tips used to boost your Magento Performance, and breaks down the confusion that surrounds the subject.You will learn how to compress your pages, styles, and scripts by almost 80%. We will also take a look at controversial optimization settings such as Magento core compilation or enabling all caching systems. You will discover new applications that improve performance. If you wish your e-businesses to grow and want to keep your customers satisfied, you definitely need this book.
Table of Contents (7 chapters)

Clustering (Become an expert)


If you have successfully applied all the techniques already presented and your Magento is still slow, it means that you are a very prosperous online retailer and it's time to leave the comfortable world where there is a single server. To keep your customers satisfied, you have to invest in hardware; the tweaking time is now over.

Getting ready

Let's begin with a little bit of general knowledge on clustering. If you are used to it, you can definitively skip to the next How to do it... section. In all recipes related to clustering we will use four images to illustrate architectures. They represent a user, web server, CDN, and a database server.

Most Magento owners will fit into two categories. The ones in the first will have a dedicated server that contains all the Magento needs.

In this configuration, a browser will accede to your server through the Internet and the DNS mechanism, which is beyond the scope of this recipe. This single server contains:

  • A web server with Magento

  • A database server

  • Images, CSS, and scripts

The ones in the second category of Magento owners have a separate database server. Typically, people who have a shared hosting environment have their databases hosted on another server (which is also shared). In this configuration, all resources belonging to servers are dedicated to a specific task.

How to do it...

If you own a single server, you can begin by separating your database in a dedicated server. In order to do this, you have to invest in another server and install MySQL on it (get your host to do it for you), and then extract your database from your first server and import it to your new server. Magento stays on your first server; you have to modify the database connection. Go to /app/etc/local.xml and modify the following lines to fit the new server parameters:

<connection>|
    <host>|<![CDATA[NEW_SERVER_ADDRESS]]>|</host>|
    <username>|<![CDATA[NEW_USER_NAME]]>|</username>|
    <password>|<![CDATA[NEW_PASSWORD]]>|</password>|
    <dbname>|<![CDATA[NEW DATABASE_NAME]]>|</dbname>|
    <initStatements>|<![CDATA[SET NAMES utf8]]>|</initStatements>|
    <model>|<![CDATA[mysql4]]>|</model>|
    <type>|<![CDATA[pdo_mysql]]>|</type>|
    <pdoType>|<![CDATA[]]>|</pdoType>|
    <active>|1</active>|
</connection>|

As simple as that. You now use a dedicated database server and improve your store performance.

The second step in clustering our environment could be using a CDN for our images, CSS, and scripts. A CDN is an independent server optimized for delivering static content such as images, CSS, and scripts. In this way, our web server can focus on running Magento and the CDN can focus on displaying static content. The good news is that Magento has native support to do this.

In your Magento backend, navigate to System | General | Web | Unsecure.

If you still have CSS and JavaScript compressed from the previous recipes, you just have to copy your media directory from your main server to your CDN server. If it's not the case anymore, you have to modify the Base Skin URL field and the Base JavaScript URL field. Also, if for some reason you use the secure URL for that kind of content, don't forget to apply the changes to the secure part as well.

How it works...

That's a very good start. Let's summarize it. We were using a single server for all requests, and now, depending on the request, we use three different servers. The first one handles all the Magento work for building pages, the second one handles the data-related operations, and the last one provides static content. With this kind of architecture, each server can focus on only one purpose.