Re: Reducing load for LAMP app?



Jeremy wrote:
Gilles Ganault wrote:
Hello,

I'm no LAMP expert, and a friend of mine is running a site which is a
bit overloaded. Before upgrading, he'd like to make sure there's no
easy way to improve efficiency.

A couple of things:
- MySQL : as much as possible, he keeps query results in RAM, but
apparently, each is session-specific, which means that results can't
be shared with other users.
Is there something that can be done in that area, ie. keep the maximum
amount of MySQL data in RAM, to avoid users (both logged-on and
guests) hitting the single MySQL server again and again?

- His hoster says that Apache server is under significant load. At
this point, I don't have more details, but generally speaking, what
are the well-know ways to optimize PHP apps?

Thank you.

memcached: http://memcached.sf.net (for caching dynamic data in memory)
apc: http://us2.php.net/apc (caches script bytecode to reduce compilation overhead)

These two modules will help enormously. I guarantee it. Using apc is pretty much transparent, but memcached will require modifying your database abstraction layer using the memcached functions (http://php.net/manual/en/ref.memcache.php).


Not necessarily. MySQL and the OS both cache data - and generally do a better job at a lower cost than using memcached.

apc *could* help. But it might not, either. It all depends on where the bottleneck it.

Also try connection pooling using PHP's persistent connections. These make life harder for you, but eliminate a lot of connection/tear-down overhead with the database. You need to be able to configure your own apache and mysql for this to really work.
(http://php.net/manual/en/features.persistent-connections.php)


WRONG, WRONG, WRONG! This INCREASES resource usage on the server. With persistent connections, you must have the maximum number of connections *ever* required allocated *all of the time* - even if no one is using your server.

MySQL persistent connections should not be used except in extreme cases - like when you're running 100+ connections per second.

Jeremy


The FIRST thing to do when having performance problems is to identify the cause of the performance problem. You're making suggestions without having any idea where the hold up is. In at least two cases, your suggestions could actually HURT performance. And the third case may or may not help. If, for instance, the majority of the resource usage is spent in long MySQL queries, apc will have little effect.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================

.



Relevant Pages

  • Re: Reducing load for LAMP app?
    ... MySQL: as much as possible, he keeps query results in RAM, but ... His hoster says that Apache server is under significant load. ... Using apc is pretty much transparent, but memcached will require modifying your database abstraction layer using the memcached functions. ... With persistent connections, you must have the maximum number of connections *ever* required allocated *all of the time* - even if no one is using your server. ...
    (comp.lang.php)
  • Re: Experiences with mysql_pconnect?
    ... talk to a MySQL 5.0.45 DB on an Apache 1.3 series server. ... dangling connections to the server at the php.net site. ... especially when the server is remote as it requires multiple calls to MySQL. ... queries that you execute on a regular basis, preparing it and then ...
    (comp.lang.php)
  • Re: Experiences with mysql_pconnect?
    ... talk to a MySQL 5.0.45 DB on an Apache 1.3 series server. ... dangling connections to the server at the php.net site. ... > Using prepared statements will probably speed up your app a lot. ... especially when the server is remote as it requires multiple calls to MySQL. ...
    (comp.lang.php)
  • Re: Reducing load for LAMP app?
    ... MySQL: as much as possible, he keeps query results in RAM, but ... His hoster says that Apache server is under significant load. ... Using memcached on the application layer can save a lot of network traffic to and from the database server, ... With persistent connections, you must have the maximum number of connections *ever* required allocated *all of the time* - even if no one is using your server. ...
    (comp.lang.php)
  • RE: MySQL/PHPMyAdmin on FC3 Connection Problem
    ... // You can disable a server config entry by setting host to ''. ... MySQL server ... MySQL control user settings ... table to describe the display fields ...
    (Fedora)