Apache, my.cnf ... für 16GB RAM Server optimieren

Apache, Lighttpd, nginx, Cherokee
gamehub
Posts: 1
Joined: 2016-01-14 04:54
 

Apache, my.cnf ... für 16GB RAM Server optimieren

Post by gamehub »

Hallo,

OS: Debian 7.9, 64bit
Apache Version: 2.2.22

Auf meinem Server läuft ein kleiner Gameserver und ein Forum mit 10.000 Besuchern täglich, es sind meistens um die 400.500 User gleichzeitig online. Ich möchte meine Config so optimieren, dass sie meinen Server völlig ausnutzt, bzw. das mein Forum die volle Leistung des Servers nutzen kann. Leider bin ich noch ein Anfänger was Linux angeht, deswegen brauche ich Hilfe... :)

Server: Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz, 16GB RAM

my.cnf:

Code: Select all

#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port            = 3306
socket          = /var/run/mysqld/mysqld.sock

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket          = /var/run/mysqld/mysqld.sock
nice            = 0

[mysqld]
#
# * Basic Settings
#
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address            = 127.0.0.1
#
# * Fine Tuning
#
key_buffer_size         = 1400M
max_allowed_packet      = 1M
thread_stack            = 192K
thread_cache_size       = 64
join_buffer_size        = 2M
sort_buffer_size        = 256K
connect_timeout         = 360
wait_timeout            = 2400
interactive_timeout     = 2400

# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover         = BACKUP
max_connections        = 1000
max_user_connections   = 700
table_cache            = 64k
#thread_concurrency     = 10
#
# * Query Cache Configuration
#
query_cache_limit       = 1M
query_cache_size        = 150M
query_cache_type        = 1

#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file        = /var/log/mysql/mysql.log
#general_log             = 1
#
# Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf.
#
# Here you can see queries with especially long duration
#log_slow_queries       = /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
#       other settings you may need to change.
#server-id              = 1
#log_bin                        = /var/log/mysql/mysql-bin.log
expire_logs_days        = 10
max_binlog_size         = 100M
#binlog_do_db           = include_database_name
#binlog_ignore_db       = include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem
innodb_flush_log_at_trx_commit = 2
innodb_buffer_pool_size        = 512M
innodb_file_per_table          = 1


[mysqldump]
quick
quote-names
max_allowed_packet      = 32M

[mysql]
#no-auto-rehash # faster start of mysql but no tab completition

[isamchk]
key_buffer              = 16M

#
# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/
apache2.conf (Ich nutze das Worker Modul)

Code: Select all

<IfModule mpm_worker_module>
    ServerLimit           250
    StartServers          10
    MinSpareThreads       75
    MaxSpareThreads       250
    ThreadLimit           64
    ThreadsPerChild       32
    MaxClients            8000
    MaxRequestsPerChild   10000
</IfModule>
Hat jemand einen Tipp was ich umstellen muss um alles aus dem server rauszuholen?

Gruß
User avatar
rudelgurke
Posts: 409
Joined: 2008-03-12 05:36
 

Re: Apache, my.cnf ... für 16GB RAM Server optimieren

Post by rudelgurke »

"Voll ausnutzen" - wenn die Kiste ständig auf Anschlag läuft fehlt Luft nach oben für den Fall der Fälle ;)

Zu MySQL - hier hat Joe User tuning-primer aktualisiert, dass kann ein wenig helfen bestimmte Stellen an der DB zu optimieren, allerdings hängt das Ganze auch immer sehr vom Einsatz ab. Ob MyISAM, InnoDB, ob die Queries der Software passen usw. usw.
Damit will ich nur sagen dass es wenig bringt an Apache und MySQL zu drehen dass tausende Requests - theoretisch - abgearbeitet werden können wenn ein User ein 17500x17500 JPG Bild hochladen kann und dass automatisch runtergerechnet wird, dann noch die DB blockiert und alles wieder an einer Stelle hängt.

Meine Empfehlung ist deswegen vorerst die Standardwerte zu belassen und bei Bedarf anzupassen. Eventuell hilft noch ein Reverse Proxy mit Cache (Varnish oder Nginx) vor dem Webserver um statische Inhalte schnell ausliefern zu können, PHP als FastCGI oder FPM zu betreiben und generell für PHP und Apache nur wirklich die Module zu laden die benötigt werden.

Weiterhin sollte natürlich ein Monitoring nicht vergessen werden, wenn mittels Cacti / Cricket Graphen vom Verhalten erstellt werden hilft dass auch weiter, wo noch etwas Luft ist.

Kurz - mal eben hier und da ein paar Werte verändern macht die Kiste nicht schneller und bringt eventuell mehr Probleme mit sich.
amiga1200
Posts: 213
Joined: 2007-01-13 19:58
 

Re: Apache, my.cnf ... für 16GB RAM Server optimieren

Post by amiga1200 »

Falls es Deine eigene Hardware ist würde ich
irgendwann mal auf ein Skylake wechseln, und möglichst 32GB stecken,
16er GB Packs kosten gerade mal 80€
Oder gleich 64GB dann über DDR4.
An Apache würde ich nichts ändern, Mysql kann man mehr Speicher zuweisen.
Einige schwören auch Mysql Tabellen auf SSD zu legen.
Ich habe eine I5 2600 35W CPU/32GB und fertige ca.5000€ Besucher ab! und das über 10MB Upload.


Aber immer dran denken:
Lieber Stabiler als Schneller
powie
Posts: 80
Joined: 2002-09-25 16:41
Location: Singen
 

Re: Apache, my.cnf ... für 16GB RAM Server optimieren

Post by powie »

läuft ein kleiner Gameserver und ein Forum mit 10.000 Besuchern täglich,
Beides auf einer Hardware ist meiner Meinung nach von Anfang an ein Design Fehler....
jan10001
Anbieter
Posts: 749
Joined: 2004-01-02 12:17
 

Re: Apache, my.cnf ... für 16GB RAM Server optimieren

Post by jan10001 »

@powie @amiga1200
Viel RAM und Rechenleistung oder Trennung Gameserver und Forum muß nicht heißen das etwas besser läuft. Wie @rudelgurke es beschrieben hat ist Monitoring und sinnvolle Softwarekonfiguration das A und O. Ich habe Systeme gesehen mit weniger Rechenleistung und RAM, die zügig Daten auslieferten.
User avatar
Proteus
Posts: 289
Joined: 2013-04-14 05:08
Location: Holzgerlingen
 

Re: Apache, my.cnf ... für 16GB RAM Server optimieren

Post by Proteus »

powie wrote: 2016-03-17 10:57
läuft ein kleiner Gameserver und ein Forum mit 10.000 Besuchern täglich,
Beides auf einer Hardware ist meiner Meinung nach von Anfang an ein Design Fehler....
Ein Fehler nicht unbedingt, bei Debian weiß ich jetzt nicht wie man es mit Jails handhabt, aber das ist durchaus ein Denkansatz alles auf einer Maschine zu betreiben.
LG
Proti

"Die Kamera wird bei hohen ISO Werten aber rauschen. Nichts ahnend hielt er sich die Kamera ans Ohr!"
User avatar
Proteus
Posts: 289
Joined: 2013-04-14 05:08
Location: Holzgerlingen
 

Re: Apache, my.cnf ... für 16GB RAM Server optimieren

Post by Proteus »

jan10001 wrote: 2016-03-20 13:53 @powie @amiga1200
Viel RAM und Rechenleistung oder Trennung Gameserver und Forum muß nicht heißen das etwas besser läuft. Wie @rudelgurke es beschrieben hat ist Monitoring und sinnvolle Softwarekonfiguration das A und O. Ich habe Systeme gesehen mit weniger Rechenleistung und RAM, die zügig Daten auslieferten.
Stimmt genau, eine falsche Konfiguration kann auch auf einem schnellen Server einen haufen Mist erzeugen... ich habe einmal vergessen die Swap auf einem Server abzustellen oder entsprechend anzupassen!
LG
Proti

"Die Kamera wird bei hohen ISO Werten aber rauschen. Nichts ahnend hielt er sich die Kamera ans Ohr!"