Apache Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationApache Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old September 17th, 2001, 02:09 PM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Pembroke Pines, Florida, USA
Posts: 2,300 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 3 h 2 m 4 sec
Reputation Power: 43
Optimizing Apache/PHP for heavy load -- question for freebsd and experts

I'm trying to optimize Apache for heavy load on a site using PHP 4.0.6 with continuous use of sessions, and many MySQL connections. The server is also using some CGI, and some FrontPage.

Apache was having a lot of trouble handling the sessions, and was frequently failing at writing session files, until I did the following tweaks. It is running OK, now, but still near the limit most of the time.

Here are the tweaks; is there anything else I have missed or done wrong?:

1. recompiled Apache with HARD_SERVER_LIMIT raised to 1024, only the essential modules loaded, and with the following vars set before ./configure:

OPTIM="-O9 -funroll-loops -ffast-math -malign-double -mcpu=i686 -march=i686
-fomit-frame-pointer -fno-exceptions"

2. set the following values for httpd.conf:

MaxKeepAliveRequests 500
KeepAliveTimeout 30

MinSpareServers 20
MaxSpareServers 50
StartServers 35

MaxClients 500

MaxRequestsPerChild 250


3. Linux system changes:

a. Change max filehandles to 16384 or (default was 4096)

b. Change max inodes to 65536 (default was 16384)


4. recompiled PHP with inline optimization and minimal external modules.

---------------

The above is what I have done so far. I am considering two other possibilities:

1. Change /etc/fstab to mount the /usr/ partition with the -noatime option, so that timestamps are not set when files are read-accessed.

2. Mount a RAM partition as the location to save session temp files, (session files need the access timestamp)

The server itself is a Rackspace.com box, with a gigahertz Athlon, 1 GB RAM, 2 18 GB SCSI drives. When I run "top" the CPU is usually at less than 15% usage, but the memory is usually at 85 or 90% used. We can only add another 1/2 GB RAM before we have to upgrade to a larger machine.

Any ideas?
__________________
The real n-tier system:

FreeBSD -> PostgreSQL -> [any_language] -> Apache -> Mozilla/XUL

Amazon wishlist -- rycamor (at) gmail.com

Reply With Quote
  #2  
Old September 17th, 2001, 09:01 PM
IceMan IceMan is offline
Roving Icicle
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Location: Netizen
Posts: 56 IceMan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to IceMan Send a message via AIM to IceMan Send a message via Yahoo to IceMan
I wouldn't exactly call myself an expert, so I'd take this advice with a grain of salt, but I'll proffer my two bits nonetheless.

Have you considered using more than one build of Apache? If your site is high traffic (it sounds like it), you can save some memory by using multiple builds with only the bare essentials. You need almost nothing installed to serve images, for example. You also don't need to load Front Page Extensions for a PHP page, etc. So, you could probably get a modest performance boost by isolating the needs of specific documents to specific servers.

Also, what OS are you runing? I know that, for instance, Red Hat Linux 7.1 has far more overhead than previous versions as it uses the new kernel.
__________________
Is it just me or is it cold in here?

Reply With Quote
  #3  
Old September 17th, 2001, 09:06 PM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Try to avoid FrontPage if at all possible. If you can't, set the following is reasonable:

RLimitCPU 60 60
RLimitMEM 60000000 60000000

Increase them:
MinSpareServers 20 -> 30
MaxSpareServers 50 -> 75
StartServers 35 -> 100

MaxClients depends on how many simultaneous requests, setting 500 might be too high.

MaxRequestsPerChild has a very tricky setting and influences memory the most. If it's set too high, the children will die off slowly, thus sucking up memory. Normally you would want to set it as high as 20000 if you serve alot of static files. So try to lower it and adjust it accordingly. If you also use mod_perl, lower it below 80.

>> hange /etc/fstab to mount the /usr/ partition

Disk partitioning could also be a big factor because it affects disk I/O speed. You might want to relocate your docroot partition to a dedicated partition like /www. It's bad if your docroot lives on the same partition as /usr or /home.

>> but the memory is usually at 85 or 90% used

That's normal and optimistic. If it's too low, that's a waste of ram.

Performance tuning of Apache takes time and may vary as it depends on many factors. If you can remove frontpage alone, that should help significantly.

Reply With Quote
  #4  
Old September 17th, 2001, 09:26 PM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Pembroke Pines, Florida, USA
Posts: 2,300 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 3 h 2 m 4 sec
Reputation Power: 43
freebsd -

I will definitely be changing the doc_root partition, and testing out your other suggestions in httpd.conf.

Where do I set RLimitCPU and RLimitMEM?

And trust me, I would love to remove FrontPage, but my client insists on using for some stuff :-(. What do you think of Iceman's idea?


Iceman-

It seems an interesting idea, but I'm a little hazy on exactly how I would implement it.

How would I manage to keep each process from trying to serve the wrong files? Would I have to physically separate them, as in build1 serves files from this directory container, and build2 serves files from that directory container?

The OS seems to be some special cooked-up version of RedHat that Rackspace installs, but it's serving kernel 2.2.19, not 2.4.

I personally much prefer running FreeBSD (but I'll live with Slackware), but my client is afraid to change anything right now.

I suppose I could recompile Linux, but since I'm stuck with working remotely on the box, I doubt that is an option.

Thanks for the tips, both of you.

Reply With Quote
  #5  
Old September 17th, 2001, 09:51 PM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
>> Where do I set RLimitCPU and RLimitMEM?

You can define them globally. They impact CGI, SSI and frontpage.

>> What do you think of Iceman's idea?

Great one. You can isolate frontpage alone to another box and NFS exporting or rsync them to your main server. This doesn't help I/O speed but it helps your CPU and Rams just because frontpage eats them like crazy.

Another thing to watch for with Frontpage is the log file (it grows without bound). If users are experiencing connection timeout to frontpage, that's the common cause of the problem.

Reply With Quote
  #6  
Old September 17th, 2001, 10:08 PM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Pembroke Pines, Florida, USA
Posts: 2,300 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 3 h 2 m 4 sec
Reputation Power: 43
Thanks so much...

Reply With Quote
  #7  
Old September 18th, 2001, 07:20 PM
IceMan IceMan is offline
Roving Icicle
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Location: Netizen
Posts: 56 IceMan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to IceMan Send a message via AIM to IceMan Send a message via Yahoo to IceMan
rycamor-

You don't necessarily have to use seperate docroots for the different servers, although it wouldn't hurt.

The Apaches should be bound to different ports/ips as the default server so they don't overlap each other, however. If you can do it, the easiest thing would be give each an IP and set a domain/sub to it.

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationApache Development > Optimizing Apache/PHP for heavy load -- question for freebsd and experts


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway