Optimizing X-Cart performance
|
Revision date: 31 Jan 2006
|
After
some time of operating you might notice some decrease in performance of
your store, especially if you have a large product catalog or a huge
number of customer orders. The possible reasons of slowing down are
various and in most complicated cases additional investigation will be
needed. But still, there are several tips that may help you to speed up
your site. They're rather simple to follow, but do not hesitate to get
in touch with us if you have any questions or need our assistance with
them. Move images from database to file system.For
each image you want to display, a separate connection has to be opened
to your database. Even if it's only one image per page, doubling the
connections to the database isn't fun to think about. Each time you do <img src="image.php?imageid=345">
or something similar, that's a separate request to the server, with PHP
going to receive that image from the database. Even if you do use
scripting to grab images from a non-public branch of your file tree,
just using file reading creates very, very little overhead, while
hitting the database creates a lot. Just connecting to the database
alone, without any queries, is something which already takes a
significant amount of server time (more in the sense of processing
cycles than actual time). Storing your images in database tables
is not recommended from the performance point of view. Our advice is to
place images into the file system. It can easily be done by modifying a
single setting in the control panel. At the administration zone, follow to the
'Images location' section, and choose 'File system' at the 'Store
images in' drop-down list value. After that modify original .htaccess file (in /files directory) and change the code to: <FilesMatch "\.(gif|jpe?g|png|GIF|JPE?G|PNG|)$">
Allow from all
</FilesMatch>
Deny from all
Toggle off tracking statisticsTracking
your visitors' movements is a very useful marketing feature, but it
takes significant resources and may slow down the performance of your
site. If there's not much need in such service, it can easily be
disabled. For v3.4.x: in the customer/auth.php file, make the line include "../include/atracking.php";
as follows: #include "../include/atracking.php";
For v3.5.x and higher: statistics are disabled via admin zone, 'General settings': uncheck 'Enable tracking statistics gathering' field. Then clean statistic tables in the admin back-end of X-Cart: 'Summary page' -> 'Statistics clearing'. Optimize database tablesAn
optimized table structure differs from a well-designed table. Table
structure optimization has to do with reclaiming unused space after
deletions and basically cleaning up the table after structural
modifications have been made. The OPTIMIZE SQL command takes care of this, using the following syntax: OPTIMIZE TABLE <table_name>; where
you should replace <table_name> with the name of the necessary
table. Execute the above SQL query for each X-Cart table. You will find
the list of X-Cart tables using the next SQL query: SHOW TABLES; Optimization
should be used if you have deleted a large part of a table or if you
have made many changes to a table with variable-length rows (tables
that have VARCHAR, BLOB, or TEXT columns). Deleted records are
maintained in a linked list and subsequent INSERT operations reuse old
record positions. You can use optimization to reclaim the unused space
and to defragment the data file. Be aware that the table is
locked while it is optimized, so if your table is large, you'd rather
optimize it during a scheduled downtime or when little traffic is
flowing to your system. Install Zend Optimizer (optional)The
Zend Optimizer is a free application that runs the files encoded by the
Zend Encoder and Zend SafeGuard Suite, while enhancing the running
speed of PHP applications. Many scripts require that you have Zend
Optimizer installed so you are able to run them on your server while
decrypting and running them on-the-fly while increasing runtime
performance. Install additional Apache modules (optional) The
idea behind GZIP-encoding documents is very straightforward. Take a
file that is to be transmitted to a Web client, and send a compressed
version of the data, rather than the raw file. Depending on the size of
the file, the compressed version can run anywhere from 50% to 20% of
the original file size. In Apache, this can be achieved using
Content Negotiation, which requires that two separate sets of HTML
files be generated: one for clients who can handle GZIP-encoding, and
one for those who can't. This solution sends gzip-encoded files to
clients who understand them, but does not allow for the compression of
dynamically-generated pages. A more graceful solution is the use
of mod_gzip, one of the many additional modules available for Apache.
We consider it one of the overlooked gems for designing a
high-performance Web server. Using this module, configured file types
will be compressed using GZIP-encoding after they've been processed by
all of Apache's other modules, and before they're sent to the client.
The compressed data that's generated reduces the number of bytes
transferred to the client, without any loss in the structure or content
of the original, uncompressed document. You may ask your hosting administrators to install the necessary compression module: mod_deflate (Apache 2.0.x) or mod_gzip (Apache 1.3.x). Custom optimization serviceIf
this doesn't work, there's one more variant: to order our optimization
service. It requires special investigation to find out the exact
reason. Developers will inspect the store carefully, determine the
reason of the site's slow performance and provide you with possible
solutions. If you are interested, post the request to the message board.
|