Contenu | Rechercher | Menus

Annonce

Si vous avez des soucis pour rester connecté, déconnectez-vous puis reconnectez-vous depuis ce lien en cochant la case
Me connecter automatiquement lors de mes prochaines visites.

À propos de l'équipe du forum.

#1 Le 30/11/2012, à 18:51

@null4ever

Quel bon paramétrage d'apache2.conf ?

Bonjour,

Sur une machine un peu musclée (AMD FX 8150 8 cores @ 4.2 Ghz, RAM 32 Gb DDR3, SSD Crucial 250 Gb SATA3) avec Ubuntu 10.04.4 LTS à jour, j'ai installé un serveur Apache2 avec mpm-worker.

La montée en charge de ce serveur est testée avec l'outil weighttp via le wrapper ab.c

Malheureusement, Apache2 s'arrête de fonctionner avec une erreur "segmentation fault" dès que le test dépasse 180 utilisateurs simultanés.

Le fichier de configuration apache2.conf est le suivant :

#
# Based upon the NCSA server configuration files originally by Rob McCool.
#
# This is the main Apache server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See http://httpd.apache.org/docs/2.2/ for detailed information about
# the directives.
#
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.  
#
# The configuration directives are grouped into three basic sections:
#  1. Directives that control the operation of the Apache server process as a
#     whole (the 'global environment').
#  2. Directives that define the parameters of the 'main' or 'default' server,
#     which responds to requests that aren't handled by a virtual host.
#     These directives also provide default values for the settings
#     of all virtual hosts.
#  3. Settings for virtual hosts, which allow Web requests to be sent to
#     different IP addresses or hostnames and have them handled by the
#     same Apache server process.
#
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path.  If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so "/var/log/apache2/foo.log"
# with ServerRoot set to "" will be interpreted by the
# server as "//var/log/apache2/foo.log".
#

### Section 1: Global Environment
#
# The directives in this section affect the overall operation of Apache,
# such as the number of concurrent requests it can handle or where it
# can find its configuration files.
#

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# NOTE!  If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the LockFile documentation (available
# at <URL:http://httpd.apache.org/docs-2.1/mod/mpm_common.html#lockfile>);
# you will save yourself a lot of trouble.
#
# Do NOT add a slash at the end of the directory path.
#
ServerRoot "/etc/apache2"

#
# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
#
#<IfModule !mpm_winnt.c>
#<IfModule !mpm_netware.c>
LockFile /var/lock/apache2/accept.lock
#</IfModule>
#</IfModule>

#
# PidFile: The file in which the server should record its process
# identification number when it starts.
# This needs to be set in /etc/apache2/envvars
#
PidFile ${APACHE_PID_FILE}

#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 300

#
# 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 100
MaxKeepAliveRequests 100

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

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

# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
#<IfModule mpm_prefork_module>
#    StartServers          5
#    MinSpareServers       5
#    MaxSpareServers      10
#    MaxClients          150
#    MaxRequestsPerChild   0
#</IfModule>

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

<IfModule mpm_worker_module>
    StartServers          8
    MinSpareThreads      25
    MaxSpareThreads     128 
    ThreadLimit         128
    ThreadsPerChild      25
    MaxClients         1000
    MaxRequestsPerChild   0
</IfModule>

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

# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

#
# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives.  See also the AllowOverride
# directive.
#

AccessFileName .htaccess

#
# The following lines prevent .htaccess and .htpasswd files from being 
# viewed by Web clients. 
#
<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy all
</Files>

#
# DefaultType is the default MIME type the server will use for a document
# if it cannot otherwise determine one, such as from filename extensions.
# If your server contains mostly text or HTML documents, "text/plain" is
# a good value.  If most of your content is binary, such as applications
# or images, you may want to use "application/octet-stream" instead to
# keep browsers from trying to display binary files as though they are
# text.
#
DefaultType text/plain

#
# HostnameLookups: Log the names of clients or just their IP addresses
# e.g., www.apache.org (on) or 204.62.129.132 (off).
# The default is off because it'd be overall better for the net if people
# had to knowingly turn this feature on, since enabling it means that
# each client request will result in AT LEAST one lookup request to the
# nameserver.
#
HostnameLookups Off

# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
# ErrorLog /var/log/apache2/error.log
ErrorLog Off

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn

# Include module configuration:
Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf

# Include all the user configurations:
Include /etc/apache2/httpd.conf

# Include ports listing
Include /etc/apache2/ports.conf

#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
# If you are behind a reverse proxy, you might want to change %h into %{X-Forwarded-For}i
#
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

#
# Define an access log for VirtualHosts that don't define their own logfile
CustomLog /var/log/apache2/other_vhosts_access.log vhost_combined

# Include of directories ignores editors' and dpkg's backup files,
# see README.Debian for details.

# Include generic snippets of statements
Include /etc/apache2/conf.d/

# Include the virtual host configurations:
Include /etc/apache2/sites-enabled/

Autres caractéristiques du paramétrage du système :

Le fichier /etc/security/limits.conf est le suivant :

* soft nofile = 200000
* hard nofile = 200000

Le fichier /etc/sysclt.conf est le suivant :

#
# /etc/sysctl.conf - Configuration file for setting system variables
# See /etc/sysctl.d/ for additional system variables.
# See sysctl.conf (5) for information.
#

#kernel.domainname = example.com

# Uncomment the following to stop low-level messages on console
#kernel.printk = 4 4 1 7

##############################################################3
# Functions previously found in netbase
#

# Uncomment the next two lines to enable Spoof protection (reverse-path filter)
# Turn on Source Address Verification in all interfaces to
# prevent some spoofing attacks
#net.ipv4.conf.default.rp_filter=1
#net.ipv4.conf.all.rp_filter=1

# Uncomment the next line to enable TCP/IP SYN cookies
#net.ipv4.tcp_syncookies=1

# Uncomment the next line to enable packet forwarding for IPv4
#net.ipv4.ip_forward=1

# Uncomment the next line to enable packet forwarding for IPv6
#net.ipv6.conf.all.forwarding=1


###################################################################
# Additional settings - these settings can improve the network
# security of the host and prevent against some network attacks
# including spoofing attacks and man in the middle attacks through
# redirection. Some network environments, however, require that these
# settings are disabled so review and enable them as needed.
#
# Ignore ICMP broadcasts
#net.ipv4.icmp_echo_ignore_broadcasts = 1
#
# Ignore bogus ICMP errors
#net.ipv4.icmp_ignore_bogus_error_responses = 1
# 
# Do not accept ICMP redirects (prevent MITM attacks)
#net.ipv4.conf.all.accept_redirects = 0
#net.ipv6.conf.all.accept_redirects = 0
# _or_
# Accept ICMP redirects only for gateways listed in our default
# gateway list (enabled by default)
# net.ipv4.conf.all.secure_redirects = 1
#
# Do not send ICMP redirects (we are not a router)
#net.ipv4.conf.all.send_redirects = 0
#
# Do not accept IP source route packets (we are not a router)
#net.ipv4.conf.all.accept_source_route = 0
#net.ipv6.conf.all.accept_source_route = 0
#
# Log Martian Packets
#net.ipv4.conf.all.log_martians = 1

# "Performance Scalability of a Multi-Core Web Server", Nov 2007
# Bryan Veal and Annie Foong, Intel Corporation, Page 4/10
fs.file-max = 5000000
net.core.netdev_max_backlog = 400000
net.core.optmem_max = 10000000
net.core.rmem_default = 10000000
net.core.rmem_max = 10000000
net.core.somaxconn = 100000
net.core.wmem_default = 10000000
net.core.wmem_max = 10000000
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.tcp_congestion_control = bic
net.ipv4.tcp_ecn = 0
net.ipv4.tcp_max syn backlog = 12000
net.ipv4.tcp_max tw buckets = 2000000
net.ipv4.tcp_mem = 30000000 30000000 30000000
net.ipv4.tcp_rmem = 30000000 30000000 30000000
net.ipv4.tcp_sack = 1
net.ipv4.tcp_syncookies = 0
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_wmem = 30000000 30000000 30000000    
                
# optionally, avoid TIME_WAIT states on localhost no-HTTP Keep-Alive tests:
# "error: connect() failed: Cannot assign requested address (99)"
# On Linux, the 2MSL time is hardcoded to 60 seconds in /include/net/tcp.h:
# #define TCP_TIMEWAIT_LEN (60*HZ)
# The option below lets you reduce TIME_WAITs by several orders of magnitude
# but this option is for benchmarks, NOT for production servers (NAT issues)

net.ipv4.tcp_tw_recycle = 1

# other settings above found from various sources
# fs.file-max = 200000						# set to 5000000 in Bryan Veal and Annie Foong settings
# net.ipv4.ip_local_port_range = 1024 65535	# not set in Bryan Veal and Annie Foong settings
# net.ipv4.ip_forward = 0					# not set in Bryan Veal and Annie Foong settings
# net.ipv4.conf.default.rp_filter = 1		# set to 1 in Bryan Veal and Annie Foong settings
# net.core.rmem_max = 262143				# set to 10000000 in Bryan Veal and Annie Foong settings
# net.core.rmem_default = 262143			# set to 10000000 in Bryan Veal and Annie Foong settings
# net.core.netdev_max_backlog = 32768		# not set in Bryan Veal and Annie Foong settings
# net.core.somaxconn = 2048					# set to 10000000 in Bryan Veal and Annie Foong settings
# net.ipv4.tcp_rmem = 4096 131072 262143	# set to 30000000 30000000 30000000 in Bryan Veal and Annie Foong settings
# net.ipv4.tcp_wmem = 4096 131072 262143	# set to 30000000 30000000 30000000 in Bryan Veal and Annie Foong settings
# net.ipv4.tcp_sack = 0						# set to 1 in Bryan Veal and Annie Foong settings
# net.ipv4.tcp_dsack = 0					# not set in Bryan Veal and Annie Foong settings
# net.ipv4.tcp_fack = 0						# not set in Bryan Veal and Annie Foong settings
# net.ipv4.tcp_fin_timeout = 30				# not set in Bryan Veal and Annie Foong settings
# net.ipv4.tcp_orphan_retries = 0			# not set in Bryan Veal and Annie Foong settings
# net.ipv4.tcp_keepalive_time = 120			# not set in Bryan Veal and Annie Foong settings
# net.ipv4.tcp_keepalive_probes = 3			# not set in Bryan Veal and Annie Foong settings
# net.ipv4.tcp_keepalive_intvl = 10			# not set in Bryan Veal and Annie Foong settings
# net.ipv4.tcp_retries2 = 15				# not set in Bryan Veal and Annie Foong settings
# net.ipv4.tcp_retries1 = 3					# not set in Bryan Veal and Annie Foong settings
# net.ipv4.tcp_synack_retries = 5			# not set in Bryan Veal and Annie Foong settings
# net.ipv4.tcp_syn_retries = 5				# not set in Bryan Veal and Annie Foong settings
# net.ipv4.tcp_timestamps = 0				# set to 1 in Bryan Veal and Annie Foong settings
# net.ipv4.tcp_max_tw_buckets = 32768		# not set in Bryan Veal and Annie Foong settings
# net.ipv4.tcp_moderate_rcvbuf = 1			# not set in Bryan Veal and Annie Foong settings
# kernel.sysrq = 0							# not set in Bryan Veal and Annie Foong settings
# kernel.shmmax = 67108864					# not set in Bryan Veal and Annie Foong settings

net.ipv4.ip_local_port_range = 1024 65535
net.ipv4.ip_forward = 0
net.core.netdev_max_backlog = 32768
net.ipv4.tcp_dsack = 0
net.ipv4.tcp_fack = 0
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_orphan_retries = 0
net.ipv4.tcp_keepalive_time = 120
net.ipv4.tcp_keepalive_probes = 3
net.ipv4.tcp_keepalive_intvl = 10
net.ipv4.tcp_retries2 = 15
net.ipv4.tcp_retries1 = 3
net.ipv4.tcp_synack_retries = 5
net.ipv4.tcp_syn_retries = 5
net.ipv4.tcp_max_tw_buckets = 32768
net.ipv4.tcp_moderate_rcvbuf = 1
kernel.sysrq = 0
kernel.shmmax = 67108864

Sur cette machine et avec ces réglages, Cherokee, Lighttpd, Nginx et G-WAN supportent (plus ou moins rapidement et avec plus ou moins d'efficacité selon le serveur web) une montée en charge de 1.000.000 requètes de 1.000 utilisateurs d'un fichier html statique de 100 caractères.

Est-ce qu'un spécialiste d'Apache2, saurait me dire comment configurer Apache2 pour qu'il puisse tenir une telle montée en charge sans obtenir l'erreur "segmentation fault", ou est-ce impossible avec ce serveur web sur ce type de configuration matérielle ?

Merci d'avance de vos conseils avisés.

Très cordialement.

Dernière modification par @null4ever (Le 30/11/2012, à 18:59)


Better to look like an idiot for a short time when asking something obvious for an expert than pretend to be smart all your life. (c) 2012 by Moi!
MB Asus Sabertooth 990SX CPU FX 8150 8 core@4.2 GhZ RAM: DDR3 32 Gb SSD Crucial 250 Gb (system) HD Samsung 3 Tb 7.200 RPM (data) GPU Saphire Radeon Dual Pro
Ubuntu 10.04.4 + 12.04.1 + Windows 7 + Windows 8 (all OSes 64 bit) !

Hors ligne

#2 Le 30/11/2012, à 19:10

Haleth

Re : Quel bon paramétrage d'apache2.conf ?

C'est un bug, pas une erreur de conf.


Ubuntu is an ancien African word which means "I can't configure Debian"

Because accessor & mutator are against encapsulation (one of OOP principles), good OOP-programmers do not use them. Obviously, procedural-devs do not. In fact, only ugly-devs are still using them.

Hors ligne

#3 Le 02/12/2012, à 16:02

@null4ever

Re : Quel bon paramétrage d'apache2.conf ?

Bonjour Haleth,

Haleth a écrit :

C'est un bug, pas une erreur de conf.

Apache est développé depuis 1995, soit près de 17 ans, et ce par une communauté de brillants experts et de contributeurs prestigieux comme par exemple IBM qui entre autre l'utilise dans WebSphere.

Si comme vous le pensez il s'agit d'un bug, comment se fait-il qu'il n'ait pas été rapporté depuis tout ce temps, ni donc corrigé ?

Pour ma part, je ne pense donc pas qu'il s'agisse alors d'un bug, mais bien plutôt d'une mauvaise configuration de ma part due à mon inexpérience dans ce domaine. hmm

Si ce n'est pas le cas, alors comment et à qui rapporter ce problème car d'autres solutions telles Cherokee, Lighttpd, G-WAN, Nginx et même le récent Monkey HTTP Deamon passent le test de montée en charge de weighttp sans problème (cependant avec des différences très notables en résultats et temps d'exécution).

Merci.


Better to look like an idiot for a short time when asking something obvious for an expert than pretend to be smart all your life. (c) 2012 by Moi!
MB Asus Sabertooth 990SX CPU FX 8150 8 core@4.2 GhZ RAM: DDR3 32 Gb SSD Crucial 250 Gb (system) HD Samsung 3 Tb 7.200 RPM (data) GPU Saphire Radeon Dual Pro
Ubuntu 10.04.4 + 12.04.1 + Windows 7 + Windows 8 (all OSes 64 bit) !

Hors ligne

#4 Le 02/12/2012, à 16:07

Haleth

Re : Quel bon paramétrage d'apache2.conf ?

Apache est toujours en dev
Ensuite, ce n'est pas forcement un bug d'apache, mais d'un composant externe.

Une segfault est TOUJOURS un bug

Pour te donner une idée, peut-être, tu devrais changer ceci:

<IfModule mpm_worker_module>
    StartServers          8
    MinSpareThreads      25
    MaxSpareThreads     128 
    ThreadLimit         128
    ThreadsPerChild      25
    MaxClients         1000
    MaxRequestsPerChild   0
</IfModule>

Par ailleurs, les logs ne te disent rien de plus ? Regarde dans /var/log/apache2/error.log

Dernière modification par Haleth (Le 02/12/2012, à 16:07)


Ubuntu is an ancien African word which means "I can't configure Debian"

Because accessor & mutator are against encapsulation (one of OOP principles), good OOP-programmers do not use them. Obviously, procedural-devs do not. In fact, only ugly-devs are still using them.

Hors ligne

#5 Le 11/12/2012, à 02:59

@null4ever

Re : Quel bon paramétrage d'apache2.conf ?

Bonjour Haleth,

Haleth a écrit :

Apache est toujours en dev
Ensuite, ce n'est pas forcement un bug d'apache, mais d'un composant externe.

Une segfault est TOUJOURS un bug.

Le problème est d'une part que je n'utilise aucun composant spécifique sauf php5-fpm qui dans le cas de ce test n'est pas appelé, et d'autre part que de temps en temps, ça marche, et de temps en temps, Apache2 s'arrête de répondre.

Je penche donc définitivement pour une mauvaise configuration de ma part.

Haleth a écrit :

Pour te donner une idée, peut-être, tu devrais changer ceci:

<IfModule mpm_worker_module>
    StartServers          8
    MinSpareThreads      25
    MaxSpareThreads     128 
    ThreadLimit         128
    ThreadsPerChild      25
    MaxClients         1000
    MaxRequestsPerChild   0
</IfModule>

J'ai essayé différentes valeurs de ThreadLimit (500 au lieu de 128) et de ThreadsPerChild (128 au lieu de 25) en les augmentant significativement en me basant sur différentes sources trouvées sur le net mais le problème reste le même.

Haleth a écrit :

Par ailleurs, les logs ne te disent rien de plus ? Regarde dans /var/log/apache2/error.log

Non, ils ne précisent rien de particulier, ce qui me semble assez logique vu qu'Apache2 semble "mourir" et n'a donc à priori pas le temps d'écrire quoi que ce soit dans ses fichiers logs.

Merci quand même.

Je savais déjà qu'Apache2 était le plus lent de tous les serveurs web pour Linux, mais quand même pas à ce point par rapport à Cherokee, Lighttpd, Monkey Deamon Tool, Nginx et surtout G-WAN (de très loin le plus véloce d'entre tous et dans des proportions incroyables).

Ceci est très surprenant vu sa part de marché estimée à environ 60 pour 100 des serveurs web installés dans le monde.

Pourquoi donc est-il encore utilisé par tant d'ISP alors qu'il est très largement surpassé par de nombreuses autres solutions?

Omerta de la presse spécialisée et des aficionados (payés ou non) de l'Apache Fundation sur les réelles capacités comparées de ses concurrents ?

Lobby d'IBM (qui est le principal partenaire financier et technique de la Apache Fundation) ?

Ceci est très étrange !

Cordialement.

PS: A propos d'outil de test de montée en charge de serveurs web, j'aimerai proposer sur ce forum un petit utilitaire sans prétention que j'ai écrit qui utilise weighttp (actuellement le seul outil de test capable d'utiliser correctement les performances des CPU multi coeurs, ce qui n'est pas le cas ni d'AB ni de HTTPerf) et qui permet de tester n'importe quel serveur web (static files) et serveur d'applications web (dynamic contents) en ne changeant que quelques paramètres (nom du serveur testé, adresse IP, port, nombre de clients simultanés, nombre de requêtes demandées par chaque client, nombre d'occurrences de weighttp lancées à chaque étape de la boucle de test, sauts de la boucle) et qui sauvegarde les résultats dans un fichier texte (dont le nom est paramétrable) formaté de manière à pouvoir être utilisé pour réaliser facilement des graphiques.

Bien entendu les sources (qui contiennent aussi toutes les instructions d'installation et de paramétrage optimal de l'OS) sont "ouvertes" et "gratuites" via les termes de la licence Creative Commons By-Sa.

Dois-je rédiger un petit tuto pour cela ou puis-je tout simplement le mettre ici entre les balises Code et /Code ?

Dernière modification par @null4ever (Le 11/12/2012, à 03:05)


Better to look like an idiot for a short time when asking something obvious for an expert than pretend to be smart all your life. (c) 2012 by Moi!
MB Asus Sabertooth 990SX CPU FX 8150 8 core@4.2 GhZ RAM: DDR3 32 Gb SSD Crucial 250 Gb (system) HD Samsung 3 Tb 7.200 RPM (data) GPU Saphire Radeon Dual Pro
Ubuntu 10.04.4 + 12.04.1 + Windows 7 + Windows 8 (all OSes 64 bit) !

Hors ligne