LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 05-04-2004, 04:28 PM   #1
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
apache tuning question: prefork.c vs worker.c


in my httpd.conf, I have the following sections:

Code:
<IfModule prefork.c>
StartServers           20
MinSpareServers        50
MaxSpareServers       100
MaxClients            200
MaxRequestsPerChild 20000
</IfModule>

<IfModule worker.c>
StartServers         35
MaxClients          256
MinSpareThreads      30
MaxSpareThreads     305
ThreadsPerChild     255
MaxRequestsPerChild  0
</IfModule>
What is the difference between the prefork.c and worker.c? Is it bad to have the values the same? Is it bad to have them different? Do the values of the above prefork.c pass your sanity test (I changed those values, but wanted to get confirmation before changing the others).

This server is getting hit really hard - I have mysql max_connections at 200, and don't want to allow the number of web users to go beyond that, but I want to get as high as safely possible. It was higher than that earlier today, but was causing obvious problems as there weren't enough mysql connections to handle all the web requests. It's locked down now, but really slow (that's what I'm trying to fix).

Thanks!

Last edited by BrianK; 05-04-2004 at 04:29 PM.
 
Old 05-04-2004, 04:31 PM   #2
stickman
Senior Member
 
Registered: Sep 2002
Location: Nashville, TN
Posts: 1,552

Rep: Reputation: 53
Prefork and worker are mutually exclusive modules. How did you compile Apache? Check the output of "httpd -l".
 
Old 05-04-2004, 04:35 PM   #3
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Original Poster
Rep: Reputation: 51
Quote:
Originally posted by stickman
Prefork and worker are mutually exclusive modules. How did you compile Apache? Check the output of "httpd -l".
# httpd -l
Compiled in modules:
core.c
prefork.c
http_core.c
mod_so.c

# httpd -V
Server version: Apache/2.0.40
Server built: Nov 27 2003 11:04:06
Server's Module Magic Number: 20020628:0
Architecture: 32-bit
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D HTTPD_ROOT="/etc/httpd"
-D SUEXEC_BIN="/usr/sbin/suexec"
-D DEFAULT_PIDLOG="logs/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="logs/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"
 
Old 11-11-2004, 06:39 AM   #4
Konfuzius
LQ Newbie
 
Registered: Jul 2004
Location: Hamburg, Germany
Posts: 2

Rep: Reputation: 0
Hello,

returning to the original question, what is the difference between those two?

I found out that my apache was compiled with prefork.c , seems to be default by
RedHat.

But when there is more than one possibilitie, then there is a reason for them
to exist.

I haven't found anything about this yet.

Something like prefork is faster, worker uses less memory..

I think I should/could trust RedHat compiling the server with a somewhat
ideal solution, but Im not sure and additionally I'd like to understand the
differences between prefork.c and worker.c


Marcus
 
Old 11-11-2004, 07:59 AM   #5
Demonbane
LQ Guru
 
Registered: Aug 2003
Location: Sydney, Australia
Distribution: Gentoo
Posts: 1,796

Rep: Reputation: 47
Have you checked the Apache documentation? there is a dedicated section on this
http://httpd.apache.org/docs-2.0/mpm.html
 
Old 11-11-2004, 08:40 AM   #6
Konfuzius
LQ Newbie
 
Registered: Jul 2004
Location: Hamburg, Germany
Posts: 2

Rep: Reputation: 0
yes,

shortly after posting the message to the board

I searched google about the topic but it did not show any
pages on the apache site. One of the first topics on google
was this thread.


Marcus
 
Old 03-10-2010, 05:20 AM   #7
fatbobsufc
LQ Newbie
 
Registered: Mar 2010
Posts: 1

Rep: Reputation: 0
Better late than never

I know this reply is a little late (six years!!??), but I thought it might be useful to add this information for anyone else who may stumble onto this thread via google like I did.

I have done a little digging and it looks like the basic difference between worker.c and prefork.c is that the worker.c module allows multiple threads from mulitple processes whereas the prefork.c is a non threaded module similar to the earlier apache 1.3.

Hope this helps any other Googlers
 
Old 05-05-2010, 12:47 AM   #8
jtjurick
LQ Newbie
 
Registered: May 2010
Posts: 1

Rep: Reputation: 0
Google is how I found this thread!

Thanks for providing me with the answer to question:

"difference between worker.c and prefork.c?"
 
Old 11-17-2010, 04:32 PM   #9
gattler
LQ Newbie
 
Registered: Nov 2010
Posts: 5

Rep: Reputation: 0
Out of some Google-specific reason this thread still comes up at the top of the search results on Google. In order help others I want to shed a bit more light on this topic. The difference between both MPMs has been made clear in this thread, but I still don't know which one is considered to be faster. I found this blog entry (http://www.camelrichard.org/apache-prefork-vs-worker) and it says that even with single core CPUs the Worker Thread is faster.

Apache Bench results for prefork:
Requests per second: 20.91 [#/sec] (mean)

Apache Bench results for prefork:
Requests per second: 40.94 [#/sec] (mean)

It has also been noted that PHP must be compiled after apache's compilation in order to work. Alternatively you could use CGI or fast CGI instead of the PHP apache module. There is also another alternative called mod_fcgid.

Last edited by gattler; 11-17-2010 at 05:59 PM.
 
Old 09-27-2011, 09:43 AM   #10
deesto
Member
 
Registered: May 2002
Location: NY, USA
Distribution: FreeBSD, Fedora, RHEL, Ubuntu; OS X, Win; have used Slackware, Mandrake, SuSE, Xandros
Posts: 448

Rep: Reputation: 31
Yup: this thread still comes up highly ranked in searches.

So, if the worker MPM is that much faster than the prefork (by almost a factor of two), why is prefork still shipped as the default MPM in modern distributions (RHEL6)? For compatability reasons, or something else?
 
Old 02-09-2012, 01:42 PM   #11
gizmola
Member
 
Registered: Jun 2001
Location: Los Angeles, CA USA
Distribution: RedHat
Posts: 53

Rep: Reputation: 15
Quote:
Originally Posted by deesto View Post
Yup: this thread still comes up highly ranked in searches.

So, if the worker MPM is that much faster than the prefork (by almost a factor of two), why is prefork still shipped as the default MPM in modern distributions (RHEL6)? For compatability reasons, or something else?
The concern is that php has so many external libraries that are commonly used via the extension system, which are not guaranteed to be reentrant. With the Worker MPM, apache is threaded, and if an individual library isn't reentrant, this can cause the dreaded apache internal error. Many people feel it's better to trade off performance for stability, and knowing that visitors are not going to regularly receive blank pages.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache & MySQL keep becoming unresponsive, tuning? chotgor1 Linux - Software 2 11-03-2004 12:37 PM
Apache2 worker works, prefork doesn't AlexH SUSE / openSUSE 1 10-18-2004 11:15 AM
what if I use worker and prefork on apache? gottin Linux - Software 1 10-15-2004 03:19 PM
Apache2 & prefork MPM, PHP4 XTJ7 Linux - Software 6 04-29-2004 02:43 PM
apache2 prefork + php4 + mysql rymonree Linux - Software 1 09-06-2003 02:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 01:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration