Apache2 server-tuning.conf richtig einstelle!

Apache, Lighttpd, nginx, Cherokee
Anonymous

Apache2 server-tuning.conf richtig einstelle!

Post by Anonymous » 2007-07-21 09:29

Hallo,

wir haben einen VPS server wo unsere Page drauf laufen tut.
Da wir imo um die 500-1000 Gäste täglich haben würde ich gerne wissen
wie man die server-tuning.conf in Apache2 richtig einstellen solte das
auch bei mehren Gästen die Page weiter noch schnell sich auf baut.

Code: Select all

##
## Server-Pool Size Regulation (MPM specific)
## 

# the MPM (multiprocessing module) is not a dynamically loadable module in the
# sense of other modules. It is a compile time decision which one is used. We
# provide different apache2 MPM packages, containing different httpd2 binaries
# compiled with the available MPMs. See APACHE_MPM in /etc/sysconfig/apache2.

# prefork MPM
<IfModule prefork.c>
	# number of server processes to start
	StartServers         25
	# minimum number of server processes which are kept spare
	MinSpareServers      25
	# maximum number of server processes which are kept spare
	MaxSpareServers      75
	# highest possible MaxClients setting for the lifetime of the Apache process.
	ServerLimit        200
	# maximum number of server processes allowed to start
	MaxClients         400
	# maximum number of requests a server process serves
	MaxRequestsPerChild  500
</IfModule>

# worker MPM
<IfModule worker.c>
	# initial number of server processes to start
	StartServers        25
	# minimum number of worker threads which are kept spare
	MinSpareThreads     25
	# maximum number of worker threads which are kept spare
	MaxSpareThreads     75 
	# maximum number of simultaneous client connections
	MaxClients         400
	# constant number of worker threads in each server process
	ThreadsPerChild     25
	# maximum number of requests a server process serves
	MaxRequestsPerChild  500
</IfModule>

# leader MPM
<IfModule leader.c>
	# initial number of server processes to start
	StartServers         25
	# minimum number of worker threads which are kept spare
	MinSpareThreads     25
	# maximum number of worker threads which are kept spare
	MaxSpareThreads     75 
	# maximum number of simultaneous client connections
	MaxClients         400
	# constant number of worker threads in each server process
	ThreadsPerChild     25
	# maximum number of requests a server process serves
	MaxRequestsPerChild  500
</IfModule>

# perchild MPM
<IfModule perchild.c>
	# constant number of server processes
	NumServers           5
	# initial number of worker threads in each server process
	StartThreads         5
	# minimum number of worker threads which are kept spare
	MinSpareThreads      5
	# maximum number of worker threads which are kept spare
	MaxSpareThreads     10
	# maximum number of worker threads in each server process
	MaxThreadsPerChild  20
	# maximum number of connections per server process
	MaxRequestsPerChild  0

	AcceptMutex fcntl
</IfModule>

# metux MPM
<IfModule metuxmpm.c>
	# initial number of worker threads in each server process
	StartThreads          5
	# minimum number of worker threads which are kept spare
	MinSpareThreads       5
	# maximum number of worker threads which are kept spare
	MaxSpareThreads      10
	# maximum number of connections per server process
	MaxRequestsPerChild   0

	Multiplexer	"wwwrun"	"www"

</IfModule>


#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On

#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 200

#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 15

#
# EnableMMAP: Control whether memory-mapping is used to deliver
# files (assuming that the underlying OS supports it).
# The default is on; turn this off if you serve from NFS-mounted
# filesystems.  On some systems, turning it off (regardless of
# filesystem) can improve performance; for details, please see
# http://httpd.apache.org/docs-2.0/mod/core.html#enablemmap
#
#EnableMMAP off

#
# EnableSendfile: Control whether the sendfile kernel support is
# used  to deliver files (assuming that the OS supports it).
# The default is on; turn this off if you serve from NFS-mounted
# filesystems.  Please see
# http://httpd.apache.org/docs-2.0/mod/core.html#enablesendfile
#
#EnableSendfile off


#
# The following directives modify normal HTTP response behavior to
# handle known problems with browser implementations.
#
BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4.0b2;" nokeepalive downgrade-1.0 force-response-1.0
BrowserMatch "RealPlayer 4.0" force-response-1.0
BrowserMatch "Java/1.0" force-response-1.0
BrowserMatch "JDK/1.0" force-response-1.0

#
# The following directive disables redirects on non-GET requests for
# a directory that does not include the trailing slash.  This fixes a 
# problem with Microsoft WebFolders which does not appropriately handle 
# redirects for folders with DAV methods.
# Same deal with Apple's DAV filesystem and Gnome VFS support for DAV.
#
BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
BrowserMatch "^WebDrive" redirect-carefully
BrowserMatch "^WebDAVFS/1.[012]" redirect-carefully
BrowserMatch "^gnome-vfs" redirect-carefully
Ich hoffe Ihr könnt mir dabei helfen??

MfG IroN

Roger Wilco
Administrator
Administrator
Posts: 5924
Joined: 2004-05-23 12:53

Re: Apache2 server-tuning.conf richtig einstelle!

Post by Roger Wilco » 2007-07-21 11:37

http://httpd.apache.org/docs/2.0/misc/perf-tuning.html

Davon abgesehen solltest du vielleicht erst ermitteln, wo genau dein Flaschenhals ist. Ich bezweifle irgendwie, dass es (allein) der Webserver ist.

rootsvr
Posts: 538
Joined: 2005-09-02 11:12

Re: Apache2 server-tuning.conf richtig einstelle!

Post by rootsvr » 2007-07-21 21:54

1000 Gäste täglich sollten aber nichtmal mit nem VPS das Problem sein.. 1000 gleichzeitig schon eher *g*

Außerdem ist die Info ein bischen dünn.. wieviel RAM ist frei, benutzt Du ne DB usw..

Anonymous

Re: Apache2 server-tuning.conf richtig einstelle!

Post by Anonymous » 2007-07-23 16:42

Hallo,

bei 500 - 1000 Besucher sollte der kleinste VS reichen, ich habe lange bei meinem Server rumgeschraubt und bin auf nachstehende Werte gekommen:

<IfModule prefork.c>
# number of server processes to start
StartServers 4
# minimum number of server processes which are kept spare
MinSpareServers 2
# maximum number of server processes which are kept spare
MaxSpareServers 3
# highest possible MaxClients setting for the lifetime of the Apache process.
ServerLimit 75
# maximum number of server processes allowed to start
MaxClients 20
# maximum number of requests a server process serves
MaxRequestsPerChild 0
</IfModule>

# worker MPM
<IfModule worker.c>
# initial number of server processes to start
StartServers 2
# minimum number of worker threads which are kept spare
MinSpareThreads 25
# maximum number of worker threads which are kept spare
MaxSpareThreads 75
# maximum number of simultaneous client connections
MaxClients 150
# constant number of worker threads in each server process
ThreadsPerChild 25
# maximum number of requests a server process serves
MaxRequestsPerChild 0
</IfModule>

# leader MPM
<IfModule leader.c>
# initial number of server processes to start
StartServers 2
# minimum number of worker threads which are kept spare
MinSpareThreads 25
# maximum number of worker threads which are kept spare
MaxSpareThreads 75
# maximum number of simultaneous client connections
MaxClients 150
# constant number of worker threads in each server process
ThreadsPerChild 25
# maximum number of requests a server process serves
MaxRequestsPerChild 0
</IfModule>

Du verteilst Deine wenigen Besucher sofort auf 25 Instanzen, das frist natürlich Ram und die Kiste wird Dir dann ständig gekillt. Mit den Werten habe ich auch schon 400 Besucher gleichzeitig bedient (Webcam Bild) ohne das es Alarm gab.
Mit den auslieferungs Werten von 1und1 hat er damals schon nach 200 Besuchern dicht gemacht.

Gruss,
Frank

noto
Posts: 6
Joined: 2007-02-19 04:38

Re: Apache2 server-tuning.conf richtig einstelle!

Post by noto » 2007-07-30 04:27

Code: Select all

<IfModule prefork.c>
   StartServers         1
   MinSpareServers      1
   MaxSpareServers      2
   ServerLimit        150
   MaxClients         20
   MaxRequestsPerChild  10000
</IfModule> 

KeepAlive On
MaxKeepAliveRequests 200
KeepAliveTimeout 2
Buffers und Caches must du in der /etc/my.cnf klein machen, sonst geht dir bei 20 gleichzeitigen Besuchern (max_connections) der RAM aus.

Beispiel:

Code: Select all

key_buffer = 512K
max_allowed_packet = 256K
table_cache = 255
sort_buffer_size = 32K
net_buffer_length = 1K
read_buffer_size = 16K
read_rnd_buffer_size = 512K
join_buffer_size = 512K
myisam_sort_buffer_size = 32K
thread_cache = 8
query_cache_size = 1M
max_connections = 20
low_priority_updates = 1
long_query_time = 2