Debian 6.0 vServer Speed Optimierung

ritti1989

New Member
Hallo zusammen,

ich benötige bitte ein bisschen Hilfe bei der Optimierung in Sachen Geschwindigkeit für meinen vServer.

Er hat folgende Daten:
Code:
CPU (garantiert)	2.000 MHz (2 Kern)
RAM (garantiert)	1.024 MB
RAM (maximal)	2.048 MB

Die Apache2.conf sieht aktuell so aus (Standard):
Code:
#
# 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 "foo.log"
# with ServerRoot set to "/etc/apache2" will be interpreted by the
# server as "/etc/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.2/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.
#
LockFile ${APACHE_LOCK_DIR}/accept.lock

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

#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
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       1
MinSpareServers    5
MaxSpareServers   10
MaxClients        10
	MaxRequestsPerChild   0 
</IfModule>

##StartServers       1
##MinSpareServers    5
##MaxSpareServers   10
##MaxClients        10
##	MaxRequestsPerChild   0

# 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
# ThreadLimit: ThreadsPerChild can be changed to this maximum value during a
#              graceful restart. ThreadLimit can only be changed by stopping
#              and starting Apache.
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_worker_module>
StartServers       1
MinSpareThreads    1
MaxSpareThreads    4
    ThreadLimit          64
    ThreadsPerChild      25
MaxClients        10
    MaxRequestsPerChild   0
</IfModule>

##StartServers       1
##MinSpareThreads    1
##MaxSpareThreads    4
##    ThreadLimit          64
##    ThreadsPerChild      25
##MaxClients        10
##    MaxRequestsPerChild   0

# 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       1
MaxClients        10
MinSpareThreads    1
MaxSpareThreads    4
    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 ${APACHE_LOG_DIR}/error.log

#
# 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 mods-enabled/*.load
Include mods-enabled/*.conf

# Include all the user configurations:
Include httpd.conf

# Include ports listing
Include 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

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

# Include generic snippets of statements
Include conf.d/

# Include the virtual host configurations:
Include sites-enabled/
GracefulShutDownTimeout 3
AddOutputFilter INCLUDES .shtml
AddType text/html .shtml
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

Für einen Speedtest habe ich folgendes verwendet:

ab -c 20 -n 200 http://rassekatze.eu/

Ergebnis:
Code:
Benchmarking rassekatze.eu (be patient)
Completed 100 requests
Completed 200 requests
Finished 200 requests


Server Software:        Apache
Server Hostname:        rassekatze.eu
Server Port:            80

Document Path:          /
Document Length:        40016 bytes

Concurrency Level:      20
Time taken for tests:   56.110 seconds
Complete requests:      200
Failed requests:        0
Write errors:           0
Total transferred:      8088600 bytes
HTML transferred:       8003200 bytes
Requests per second:    3.56 [#/sec] (mean)
Time per request:       5610.977 [ms] (mean)
Time per request:       280.549 [ms] (mean, across all concurrent requests)
Transfer rate:          140.78 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.2      0       1
Processing:   749 5398 1343.7   5151    8222
Waiting:      689 5326 1339.2   5063    8187
Total:        750 5398 1343.6   5151    8222

Percentage of the requests served within a certain time (ms)
  50%   5151
  66%   5519
  75%   6106
  80%   6651
  90%   7426
  95%   7692
  98%   8073
  99%   8147
 100%   8222 (longest request)

Habe den Test ein zweites mal ausgeführt, um bessere Werte zu haben:

Code:
Benchmarking rassekatze.eu (be patient)
Completed 100 requests
Completed 200 requests
Finished 200 requests


Server Software:        Apache
Server Hostname:        rassekatze.eu
Server Port:            80

Document Path:          /
Document Length:        40016 bytes

Concurrency Level:      20
Time taken for tests:   51.007 seconds
Complete requests:      200
Failed requests:        0
Write errors:           0
Total transferred:      8088600 bytes
HTML transferred:       8003200 bytes
Requests per second:    3.92 [#/sec] (mean)
Time per request:       5100.677 [ms] (mean)
Time per request:       255.034 [ms] (mean, across all concurrent requests)
Transfer rate:          154.86 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.7      0       3
Processing:  1742 4903 722.1   4987    6591
Waiting:     1641 4806 725.7   4885    6496
Total:       1743 4903 721.8   4987    6594

Percentage of the requests served within a certain time (ms)
  50%   4987
  66%   5148
  75%   5234
  80%   5304
  90%   5516
  95%   5855
  98%   6167
  99%   6378
 100%   6594 (longest request)


Ich danke euch für die Hilfe und freue mich, wenn mein vServer schneller wird :-P


LG und Danke
Toni
 
1.5 bis 2 Sekunden Auslieferung für 8kB bei Unterseite des Menüs ist arg lahm.

Welches CMS steckt dahinter? Wenn Webseiten über die Datenbank generiert werden, kann das Zeit kosten.
 
Kleiner Tip am Rande:
Official security support for Debian GNU/Linux 6.0 (code name "Squeeze") has ended on 31 May 2014
Entweder auf Squeeze LTS umstellen oder besser noch Distribution upgraden.
 
Welches CMS steckt dahinter?
Manchmal ist ausprobieren einfach schneller. ;)
-> http://rassekatze.eu/admin/ - CMS Made Simple

CMS sind immer recht ressourcenintensiv. Da wäre es nun interessant wie die restliche Config ausschaut:
  • mod_php oder fcgid/cgi/php-fpm?
  • MySQL Speicherwerte auf Anwendungsfall optimiert? (tuning-primer kann eine Richtung angeben. Optimale Settings muss man aber selbst ausprobieren)
  • Welcher Apache MPM? Prefork? Worker? Event?
  • Welche MySQL Queries laufen im Hintergrund wenn du die Seite aufrufst? Wie lange benötigen diese?
  • OpCode Cache-Module für PHP aktiv? Falls ja, welche?
 
Ich würde auch sagen dist Upgrade. Gut wäre es aber auch zu wissen wie deine /etc/mysql/my.cnf Datei aussieht und ob ein Caching aktiv ist. Memcache, Disk cache, ...
 
Was die reine HTTP-Performance angeht, kann ich nur dringend anraten, einen NGINX-Reverseproxy mit Request- und Responsebuffering vorzuschalten. Die Konfiguration ist natürlich je nach genauem Setup etwas komplizierter als einen reinen Apache zu betreiben, aber bei Ausliefern von statischem Content ist NGINX unglaublich schnell. Dazu kommt, dass du architekturbedingt auch extrem hohe KeepAlive-Werte (> 5 Minuten) setzen kannst, da NGINX stressfrei tausende offene Verbindungen handeln kann.

Die NGINX-eigene Doku ist meiner Meinung nach sehr gut und verständlich, hier ein Einstieg: http://nginx.com/resources/admin-guide/reverse-proxy/

Zur Optimierung von MySQL ist der Tuning-Primer auch heute noch eine gute Wahl: https://www.thomas-krenn.com/de/wiki/MySQL_Performance_Tuning#mysql-primer.sh
Allerdings zeigt phpMyAdmin in den aktuelleren Versionen auch schon viel Optimierungspotenzial im Bereich der Serverstatistiken auf. Zu beachten ist, dass MySQL zum Zeitpunkt der Messung schon zwei Tage laufen sollte.

Bei PHP selbst kannst du schon durch Verwendung von Version 5.6 einen Schub erreichen, wir haben hier teilweise 10% gegenüber PHP 5.5 messen können. Opcode-Caching können die neuen PHP-Versionen auch von Haus aus.
 
PHP-Friends said:
einen NGINX-Reverseproxy mit Request- und Responsebuffering vorzuschalten. [...] aber bei Ausliefern von statischem Content ist NGINX unglaublich schnell.
Entweder Nginx als Reverse-Proxy oder nur Nginx. Ihn als reverse proxy (ohne zusätzliches Caching, das wurde hier nicht erwähnt!) zu verwenden und zu erwarten dass die Antwortzeiten besser werden ist irgendwie... lustig :D

Wie man an den bisherigen Antworten bereits gut ablesen kann; solange nicht bekannt ist WAS deine größten Engpässe im System sind, kann niemand dir konkrete Hilfestellungen geben. Es wäre hier bspw sinnvoll
a) die PHP XDebug-Erweiterung zu verwenden um zu sehen wo hier Leistung flöten geht
b) einen Auszug aus iotop + top (oder kombiniert: atop) zu liefern
c) eine statische "Hallo Welt" Html-Datei zu benchmarken.
d) eine PHP-Uhrzeit Datei zu benchmarken
 
Klar, gemeint war natürlich ein "cachender" Reverse-Proxy. Allerdings ist auch das Request-/Response-Buffering schon eine Entlastung für einen stark frequentierten Apache.
 
zuerst sollte man aber mal das System an sich optimieren - ich vermute mal, daß hier wie meist üblich so rein gar nichts an der DB gemacht wurde - wenn man die "auf Spur" bringt dürfte sich da schon viel verbessert haben.

Die Frage ist dann immer nur noch, wie viel Platz für Caches (welcher Art auch immer) bei einem Serverchen mit 1GB Ram denn überhaupt vorhanden ist... - bevor ich da noch einen zusätzlichen Cache im eh schon knappen Hauptspeicher unterbringen will (und auch einen zusätzlichen Serverdienst) sollte ich am bestehenden System mal das optimale raus holen.
 
Hi zusammen,

anbei einige weitere Infos...


1. my.cnf der MySQL DB
Code:
#
# 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

innodb_buffer_pool_size=2M
innodb_additional_mem_pool_size=500K
innodb_log_buffer_size=500K
innodb_thread_concurrency=2
[mysqld]
local-infile=0
#
# * 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
language	= /usr/share/mysql/english
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		= 16M
max_allowed_packet	= 16M
thread_stack		= 192K
thread_cache_size       = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover         = BACKUP
#max_connections        = 100
#table_cache            = 64
#thread_concurrency     = 10
#
# * Query Cache Configuration
#
query_cache_limit	= 1M
query_cache_size        = 16M
#
# * 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_buffer_pool_size=2M
innodb_additional_mem_pool_size=500K
innodb_log_buffer_size=500K
innodb_thread_concurrency=2
[mysqldump]
quick
quote-names
max_allowed_packet	= 16M

[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/

2. mod_php oder fcgid/cgi/php-fpm?
Wie bekomme ich das raus?

3. MySQL Speicherwerte auf Anwendungsfall optimiert?
Nein - weiß nich wie?

4. Welcher Apache MPM? Prefork? Worker? Event?
Wo soll ich das einstellen?

5. Welche MySQL Queries laufen im Hintergrund wenn du die Seite aufrufst? Wie lange benötigen diese?
Weiß ich nicht :D

6. OpCode Cache-Module für PHP aktiv? Falls ja, welche?
nein

7. NGinx hatte ich mal aktiv (Standard) da waren die Webseiten im halbe Stunden Takt down.. ich habe das ganze "Schrott Modul" deaktiviert.

8. Die PHP XDebug-Erweiterung zu verwenden um zu sehen wo hier Leistung flöten geht?
Wie geht das?

9. einen Auszug aus iotop + top (oder kombiniert: atop) zu liefern
Bitte was? 0.o


Danke für eure Hilfe.
 
Habe gleich noch ne Frage
Wie mache ich denn ein Dist Update, ohne die ganzen Daten (Webseiten, Datenbanken etc.) neu zu installieren? Also wirklich nur ein Update machen?!
 
Ich habe gelesen das ein Dist-Upgrade von Debian bei der Nutzung von Plesk nicht empfohlen ist. Vielleicht wäre es besser einen neuen VServer zu holen, dort Debian 7 mit Plesk 12 zu installieren und mittels dem MigrationsManager umzuziehen.
 
Last edited by a moderator:
Wie mache ich denn ein Dist Update, ohne die ganzen Daten (Webseiten, Datenbanken etc.) neu zu installieren? Also wirklich nur ein Update machen?!

Aufgrund der komplexen Abhängigkeiten (Plesk) und der scheinbar vorhandenen Wissenslücken würde ich auf jeden Fall dazu raten, eine Kopie des Serverinhalts in einer lokalen Testumgebung (z.B. virtualbox) anzulegen und den Upgrade-Prozeß in dieser Testumgebung vorher zu üben.
So kannst du dich mit dem Ablauf vertraut machen und eventuell auftretende Fehler eingrenzen, bevor du das tatsächliche Upgrade auf dem Server durchführst.
Alternativ machst du ein paar Euro locker und beauftragst einen Profi damit ;)
 
Back
Top