phpgroupware

Tips to increase phpgw response time

I thought I'd start a page with some general tips to increase your server's speed for serving up phpgw pages.

This will start out kind of general since phpgw can run on so many hardware platforms with so many combinations of web servers and databases but hopefully people will add more specific tips as time goes by.

  1. add more RAM or reduce the amount of other software running on the same machine (X windows on linux machines is exceptionally good at using all your RAM). This will likely give you the biggest bang for the effort/cost. By adding more RAM, you can:
    1. reduce or prevent any memory swaps to the hard drive (a killer for any kind of server)
    2. increase the cache size so more info is stored in RAM
      1. php.ini (usually /etc/php.ini on linux systems) has cache settings
      2. use a php accelerator (this basically holds php code in a cache so the web server doesn't have to load it each time)
      3. increase database cache size and look ahead
        1. mysql
        2. postgresql .. look for the file postgresql.conf
      4. turn off ip address lookups and turn on use cookies and php session management in phpgoupware setup, config
  2. look for network traffic bottlenecks and handle those with hardware. This is usually only a problem on LANs with a larger user base but would be applicable with a small user base on a 10MB LANs. A relatively small number of concurrent users (20 or so) can eat up a 1.5MB DSL internet connection (additional users could be connected from the LAN at the same time without affecting the internet network connection) so you would want to get a faster connection.


---
Some apache config tips:
Here is the miminum list of modules that need to be loaded in http.conf:
define_module
config_log_module
mime_module
status_module
includes_module
cgi_module # I'm running SQL-Ledger
alias_module
access_module
php4_module

in this order.

This didn't seem to make much difference in page load times. Maybe because there is
a gig of RAM in the server.

Bob Crandell

---

This is a wide topic in itself. Where ive found the most impact is in
using apache 1.3.26 with lingerd (google for lingerd homepage). It
requires you to patch a vanilla apache thus recompiling php will also be
a must, as will be putting some new up/down scripts for lingerd. But its
well worth the trouble, ive seen amazing increases in performance with
this thing.

Of all the tunnning options this is the hardest, but with the least cost
(does not require more memmory)

Another thing that can have a lot of impact is php cache. Most are
incorregible leakers, but ive ran into one called turck that seems to be
the smartest in memmory management issues. It will senssibli up your
perfomance. Anyhow, you should have plenty extra ram for this to show.

Finally, db tunning will also affect the performance. Make shure also
that you have enough ram and dig into the query cache and indexing
features of whatever database youre using. Mysql seams the most
configurable, postgres the least, but it does include a configurable
query cache size variable somwhere.

The more you can get on RAM, the fastest it will all go. Phpgroupware is
a hungry app, you do need some good tunning or serious iron to run it
for a larger number of users (300 and up, on less ive seen it can cope
with it on a 'normal' box -dual 400mhz PII-PRo, scsi 2gig ram box).

Alex Borges


---
Some server examples:

How can you tell if more RAM would help in linux? Run the command line program "top" and look at the memory stats in the upper section. Here's some examples of servers I run:
Server1 - production phpgw/web server:
Mem: 515900K av, 355568K used, 160332K free, 0K shrd, 129264K buff
Swap: 248968K av, 3492K used, 245476K free 111896K cached

Not using much swap, plenty of free RAM, good cache and buffer use. This server was started recently and is under a fairly light load.

Server2 - production phpgw/webserver, being phased out and replaced by server1 because it's too slow:
Mem: 261728K av, 252256K used, 9472K free, 0K shrd, 8756K buff
Swap: 128484K av, 13712K used, 114772K free 84836K cached

Not too much swap, buffer usage a bit low, very little free RAM (linux most always leaves 3-4 meg at all times). This one could do with a more RAM but is holding up OK for now.

Server3 - very light usage phpgw server (2-3 users) and squid server, made of spare parts and no one cares it's slow:
Mem: 94944K av, 89076K used, 5868K free, 0K shrd, 152K buff
Swap: 248968K av, 95708K used, 153260K free 18812K cached

massive swap usage, very very little free mem, almost no buffer usage and very low cached. This server is in pain. You can probably hear it screaming and crying from where you are. This server desperatly needs more RAM (and a faster CPU but that's for another book).

Server 4 - runs everything under the sun including a thin client
CPU states: 0.3% user 0.5% system 0.0% nice 0.0% iowait 99.0% idle
Mem: 1548224k av, 1528908k used, 19316k free, 0k shrd, 82684k buff
12k active, 1401180k inactive
Swap: 500464k av, 32468k used, 467996k free 1203664k cached
Athlon 2.4 GHz with 1.5 GB of DDR RAM
15 users with average load of about 5 concurrent
nice and fast with cranked up cache on phpgw subsystems (apache, php, and postgresql)


--

Here are some tips:

1. Install it on a dedicated server. It is rarely a problem to do
that when you use it on a LAN only.
2. Stop unused daemons - like sound, samba, cups, telnet or any other
shit that comes preinstalled in every major Linux distro lately.
3. Reduce the number of Apache instances kept in the server memory.
Default setting in most distros is 10 Apache instances - way too much
if you have a dedicated phpGW server with up to 50 users. It is rare
when more than 2 instances are needed. Also take care about the
number of mgetty instances - who needs more than 1 virtual console,
when one always uses ssh?

So by meeting these guidelines I've managed to set up a Pentium
150MHz with 64MB (yeah - sixty four) with apache 1.3, php4,
postgresql (mandrake 9 distro) and APC. And it was a perfecty usable
phpGW install. The funny thing is that with several users the average
swap file usage was about 0 (zero). You knwo how they say: 640 kb
ought to be enough for everyone ;-) Of course it was an experiement,
but one should know it is doable and fully usable :-)

Best regards
Tomasz Spyrczak

(C) 2000-2003 Free Software Foundation Inc