Re: Reducing load for LAMP app?



_q_u_a_m_i_s's wrote:
On Jan 4, 10:34 am, Gilles Ganault <nos...@xxxxxxxxxx> 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?

Are you sure keeping data in ram is a good solution? MySQL cache
dosen`t help?


Its all held in ram by disk caching anyway.

Probably :-)

If you are running queries against the same sets of tables time and again, those tables will be cached by the OS.

If the computer runs out of free RAM tho, expect a sudden and huge downturn in performance.

That something for the machine owner to fix tho.

The other thing that sometimes screw up dB apps is searches on un-indexed fields. Adding indexes can often help a lot, as can optimising the way nested select statements are done.

The key is that the earliest you can reduce the amount of data, if possible searching on indexed fields first..

- 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.

For an easy test try to install a PHP accelerator (i`ve testesd
eaccelerator http://eaccelerator.net/ ). It can do a pretty good job.
And another thing , try to make sure that the server is overloaded
procesing stuff and not because of a bad caching mechanism (google for
browser-caching). As a rule of thumb , do not use php-generated
images, or other dinamically generated content if it`s not really
needed.


Its a hard call to know what is slow without access to the machine. It may be I/O bound due to low RAM and too many disk access, process bound - too many processes for the RAM avaialable - or simply CPU bound having to do too much computation. My experience suggests that mostly you don't need huge CPU power in a *server*, but a fast disk or better, several disks, and huge amounts of RAM are the key. As is a fast network..only in some of the nastier SQL queries does CPU power get an issue, and those are generally fixed by rewriting te query or indexing.

Any on the fly graphics computation will of course screw the CPU, but most people don't do that..its more likely the images are just being retrieved, not generated...


There is no easy way to optimize PHP,as with any other language you
have to know exactly what goes wrong with your scripts. You can use
xdebug (as a profiler) to see what functions eat a lot of resources.
You can monitor the server and see why he is slowing down like
that(need more ram, more cpu`s...more hdd?).

That's an interesting point..can PHP easily get at things like CPU utilisation, memory resoure allocation and the like? so one could build a web page to peer into the server?

I wouldn't mind one of those here..


.



Relevant Pages

  • Re: Would a 2nd processor really be a waste of time???? help
    ... > buy another processor and more ram, however this is what one supplier ... > Your server has only 1 processor. ... installation including changing the bios settings and installing the smp ... The second cpu will probably help ...somewhat. ...
    (comp.unix.sco.misc)
  • Re: ASP.Net Performance Problems
    ... The stress testing was conducted over a week long period using the Microsoft ... the webserver and the database server. ... Disk I/O - OK ... CPU - overloaded ...
    (microsoft.public.dotnet.distributed_apps)
  • Re: High memory usage (*HELP*)
    ... Low on virtual memory does not necessarily mean anything with regard to disk ... If your system uses all the available RAM, ... acceptable for a server to put all of its available RAM to use. ...
    (microsoft.public.windows.server.sbs)
  • Re: SCO OSR5.0.6 System Crashed during LoneTAR Verify
    ... RAM; scrambled bits point the CPU toward disaster and it ... available that can really stress memory, but the best ones need to run ... disk corruption can cause otherwise good code to be read ...
    (comp.unix.sco.misc)
  • Re: Terminal Sessions performance
    ... After reviewing everything you have written in this thread thus far, it would appear that you do not have enough RAM for the number of users and applications on your server. ... In this post you state that the PF Usage number reaches over 3GB. ... One of the ways you can tell when you have too little RAM is if you see high Pages/sec in Performance Monitor combined with slow performance and high CPU. ...
    (microsoft.public.windows.terminal_services)