473,568 Members | 2,929 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reducing load for LAMP app?

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.
Jan 4 '08 #1
39 2543
On Jan 4, 10:34 am, Gilles Ganault <nos...@nospam. comwrote:
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?
>
- 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.
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?).
Jan 4 '08 #2
On Fri, 4 Jan 2008 02:23:20 -0800 (PST), "_q_u_a_m_i_s's "
<qu****@gmail.c omwrote:
>Are you sure keeping data in ram is a good solution? MySQL cache
dosen`t help?
By RAM, I meant keeping stuff in memory vs. reading them from the HD,
even though it's not necessary since data didn't change.
>For an easy test try to install a PHP accelerator
I'll check it out.
>There is no easy way to optimize PHP,as with any other language you
have to know exactly what goes wrong with your scripts.
That's the problem he has: If I had to investigate where things can be
optimized in Linux + Apache + PHP + MySQL, what tool should I use?

Thanks
Jan 4 '08 #3
_q_u_a_m_i_s's wrote:
On Jan 4, 10:34 am, Gilles Ganault <nos...@nospam. comwrote:
>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..
Jan 4 '08 #4
On Fri, 04 Jan 2008 09:34:20 +0100, Gilles Ganault <no****@nospam. com>
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?
AFAIK, more RAM is not always a good thing for MySQL. I've known setups
where actually reducing RAM usage/cache sizes sped it up tremendously.
It's somewhat out of my expertise though. Consult the MySQL manual, and
possibly ask for advise in comp.databases. mysql.
--
Rik Wasmus
Jan 4 '08 #5
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?
Try comp.databases. mysql - where the MySQL experts hang out. They can
give you more details, but generally the caches are more efficient at
this than user apps.
- 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?
Before you can optimize, you need to find where the bottlenecks are.
Otherwise you're going to waste a lot of time "fixing" things which
aren't broken.
Thank you.


--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===

Jan 4 '08 #6
On Jan 4, 3:34 am, Gilles Ganault <nos...@nospam. comwrote:
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.
I will agree with the statement made in the post that 'before you can
optimize, you need to know where you are optimizing'.

1. Eaccel (or any pre-compiler) will certainly help if the bottleneck
is PHP (to a point.)
2. Use the XDebug package & Kcachegrind (or wincachegrind) to look at
what the code is doing and if it can be optimized.
3. Depending on site needs, considering caching options such as
memcached.

Read the IBM series of articles on tuning/performance for LAMP

http://www.ibm.com/developerworks/li...p-1/#resources

faulkes

Jan 4 '08 #7
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).

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.pe...onnections.php)

Jeremy
Jan 5 '08 #8

"Gilles Ganault" <no****@nospam. comwrote in message
news:iq******** *************** *********@4ax.c om...
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.
Why (or how) are the queries "session-specific"?
No way to get rid of that?

Richard.
Jan 5 '08 #9

"Richard" <root@localhost wrote in message
news:47******** *************** @news.euronet.n l...
>
"Gilles Ganault" <no****@nospam. comwrote in message
news:iq******** *************** *********@4ax.c om...
>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.

Why (or how) are the queries "session-specific"?
No way to get rid of that?

Richard.
Oh and BTW:
>- MySQL : as much as possible, he keeps query results in RAM
It seems like a waste of memory to keep the results in RAM when you
know they will not be of any use to you afterwards. Immediately free
the mem for the next results sounds better to me.

Richard.
Jan 5 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
2195
by: Ranger West | last post by:
Hello there, Are there any out-of-the box handhelds that run Linux/Apache/MYSQL and PHP? Does Redhat, Suse, or Gentoo support any handhelds? I know the Zaurus comes close, but I've heard people have problems running LAMP applications on it. It would be cool to be able to run any LAMP application on sourceforge on a handheld computer.
12
2784
by: Google Mike | last post by:
You know, while working on my moonlight corporation's LAMP project at home this weekend, I couldn't help but wonder if people writing similar projects are solving similar problems with having to complete the project by building an installer and building the user/group administration piece of it. The thought came to me that it would be great...
1
1811
by: Geoff Blake | last post by:
I'm new to linux and I'm trying to set up a LAMP server using Fedora 4 I installed all the relevant packages and have Apache serving static pages ok, however I am unable to access MySql. PHPinfo() tells me that PHP was built using "--without mysql" in the configure command. Is there a logical reason why they would do this? Will all PHP...
10
23590
by: Zabby | last post by:
hi, i want to turn on/turn off a usb lamp via a vb.net button... i think i would have to turn on/turn off the power for this usb port.... how could i do this? kind regards
2
6894
by: Yogee | last post by:
Hello all, I dont know the exact group where I should post my questions. So, I m doing it on most of the groups which support components of LAMP stack. My client wants to use WAMP ( Windows + apache + MySQL + PHP ). But the site performance is very slow on windows. I dont know the exact reasons. I have seen some benchmark details on...
4
6116
by: Patrick | last post by:
I have a tablespace that contains the LOB data for 3 tables which exist in other tablespaces. Even after reorging the LOB tablespace with the LONG option, the high water mark is still too high. I want to be able to shrink the tablespace below the current high water mark and return the excess space back to the filesystem. Is there another...
4
4658
by: Gaurav Agarwal | last post by:
Hi, Am using WAMP5 and python 2.4.3. I tried to install mod_python 3.2.5 for python2.4. When i tried starting wamp, Firstly there was no error message in the apache error log. I saw error message in windows event viewer : "The Apache service named Apache.exe reported the following error: before the error.log file could be opened.
1
1373
by: athindrans | last post by:
Hi I am new to web devp,I have the following query What are the steps and precautions to take when developing your site on a WAMP server and deploying on a LAMP. Since most of the hosting companies are on LAMP, what are the things which will change for a php/mysql site developed and tested on Apache windows. kindly enlighten
0
7597
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7654
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7961
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6273
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5492
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5216
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3630
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2093
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1206
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.