Speeding up Apache and PHP

6,748

Solution 1

Here are some popular, industry standard techniques to increase your speed. You can try them out depending on your exact configuration:

Memcached

Memcached is a general-purpose distributed memory caching system that is often used to speed up dynamic database-driven websites by caching data and objects in RAM to reduce the number of times an external data source (such as a database or API) must be read.

http://memcached.org/

Varnish Cache

Varnish is an HTTP accelerator designed for content-heavy dynamic web sites. In contrast to other HTTP accelerators, such as Squid, which began life as a client-side cache, or Apache, which is primarily an origin server, Varnish was designed from the ground up as an HTTP accelerator.

http://www.varnish-cache.org/

Mod_pagespeed

Page Speed is a tool and library that identifies improvements that can be made to web-sites to improve their latency. mod_pagespeed automates the application of those rules in an Apache server. HTML, CSS, JavaScript, and images are changed dynamically during the web serving process, so that the best practices recommended by Page Speed can be used without having to change the way the web site is maintained.

http://googlewebmastercentral.blogspot.com/2010/11/make-your-websites-run-faster.html

HBase

HBase is an open source, non-relational, distributed database modeled after Google's BigTable and is written in Java. It is developed as part of Apache Software Foundation's Hadoop project and runs on top of HDFS (Hadoop Distributed Filesystem), providing BigTable-like capabilities for Hadoop. That is, it provides a fault-tolerant way of storing large quantities of sparse data.

http://hbase.apache.org/

Cheat on Slow-Start

Slow-start is part of the congestion control strategy used by TCP, the data transmission protocol used by many Internet applications. Slow-start is used in conjunction with other algorithms to avoid sending more data than the network is capable of transmitting, that is, to avoid causing network congestion.

http://blog.benstrong.com/2010/11/google-and-microsoft-cheat-on-slow.html

Solution 2

cwd's answer is excellent, just add a PHP opcode cacher (APC, eaccelerator, xcache) if the processing is PHP-heavy.

Solution 3

+1 to cwd for the mod_pagespeed suggestion.

If your goal is to reduce the load on Apache, and assuming Apache is the front-line daemon receiving HTTP requests (i.e. there's no cache between the user and Apache) you should be giving a lot of attention to client-side optimization, specifically reducing page weight and reducing the number of requests needed to load a page. mod_pagespeed is going to do a lot of these on the fly, but because it's an Apache module it's going to incur a little Apache load just to do those optimizations.

It's going to maximize client-side caching using expiration headers etc. without you needing to tune the Apache configuration in detail, which is a win. It might be good to do some of the other optimizations (combining or bundling CSS and Javascript files to reduce the number of each needed to build the page, CSS image spriting to reduce the number of images loaded per page) on your own to reduce the load on mod_pagespeed.

You can look at Google's Page Speed tool (linked from the mod_pagespeed page) and/or the Yslow extension for the Firebug Firefox plug-in to find good client-side optimizations for your pages.

Share:
6,748

Related videos on Youtube

tgriesser
Author by

tgriesser

http://github.com/tgriesser

Updated on September 17, 2022

Comments

  • tgriesser
    tgriesser over 1 year

    What are some good modules or systems that for caching that I can use for decreasing my load on Apache on an EC2 server running PHP, and why would you choose them?

  • pjmorse
    pjmorse about 13 years
    This is a good idea, I thought about that but forgot to mention it.