PDA

View Full Version : Server Optimization request - VPS


blueuniverse
Sun 23rd Apr '06, 1:23pm
Edit: Should probably outline what is actually wrong

Basically, we've upgraded and loads have gone up but then so have post counts and suchlike. It isn't running particularly slow but it's still on the default configuration and a lot of it seems not particularly optimized i.e. the MySQL memory limit which was 8mb (now 16) with a site that uses MySQL above most other things and has a db size of 300mb.

1. Is this on dedicated or shared virual server. If shared, how many sites share this server (ask web host if needed)

Virtual Private Server

2. your server specs. For example:

CPU (obviously I don't utilise all of this) - AMD Opteron 2.4ghz x2
Memory Installed - 2GB Burst RAM - 512MB RAM guaranteed
Hard Drive - RAID10 arrays 10K RPM 74GB drives SCSI - I get 20gb
OS - Fedora Core 2
Apache - 1.3.34 (Unix)
PHP - 4.3.11
MySQL -4.1.18-standard

3. if you use mysql 4.x instead of mysql 3.23.x, do you have any innodb type databases/tables on your server ?

Not that I'm aware of.

4. if possible how mysql was compiled/installed

As part of apache. Otherwise, no idea.

5. your top stats

top - 16:26:32 up 8 days, 16:26, 1 user, load average: 0.95, 1.25, 1.25
Tasks: 108 total, 1 running, 107 sleeping, 0 stopped, 0 zombie
Cpu(s): 1.4% user, 1.1% system, 0.0% nice, 97.5% idle
Mem: 8211012k total, 8187824k used, 23188k free, 2149580k buffers
Swap: 8193140k total, 4437224k used, 3755916k free, 1265920k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
25377 root 18 0 976 976 752 R 1.6 0.0 0:01.99 top
26880 nobody 16 0 28296 20m 13m S 1.3 0.3 24:43.23 httpd
31104 nobody 11 0 29564 17m 11m S 1.0 0.2 24:52.78 httpd
1376 root 9 0 22200 3460 2216 S 0.3 0.0 1:08.30 spamd
21026 root 9 0 2136 2084 1804 S 0.3 0.0 0:00.02 sshd
1 root 8 0 552 508 480 S 0.0 0.0 0:08.12 init
27906 root 9 0 560 528 476 S 0.0 0.0 0:05.40 syslogd
27948 nobody 8 0 1640 1120 1016 S 0.0 0.0 0:06.31 proftpd
27960 named 9 0 4476 3804 1640 S 0.0 0.0 0:00.00 named
27961 named 9 0 4476 3804 1640 S 0.0 0.0 0:04.64 named
27966 named 9 0 4476 3804 1640 S 0.0 0.0 0:21.91 named
27970 named 9 0 4476 3804 1640 S 0.0 0.0 0:21.51 named
28003 named 9 0 4476 3804 1640 S 0.0 0.0 0:02.08 named
28065 named 9 0 4476 3804 1640 S 0.0 0.0 0:08.70 named
28226 root 9 0 1244 1064 1008 S 0.0 0.0 0:01.33 sshd
28545 root 8 0 792 728 660 S 0.0 0.0 0:00.71 xinetd
29792 root 8 0 8124 2096 1460 S 0.0 0.0 0:15.40 chkservd
6. your mysql configuration variables located at /etc/my.cnf or c:\my.cnf or my.ini so post the contents inside of my.cnf (minus any passwords of course).

[mysqld]
skip-locking
character-sets-dir=/usr/share/mysql/charsets/
query_cache_limit=1M
query_cache_size=16M
query_cache_type=1
max_user_connections=50
max_connections=300
# MySQL would close any connection that was idle for more than 30 seconds. On a very busy server this must be
# further decreased. Setting this higher may lead to reaching the max connections, as idle connections will
# occupy most of the resources alloted reby max_connections.
wait_timeout=30
thread_cache_size=96
# The value of key_buffer(_size) is the size of the buffer used with indexes.
# The larger the buffer, the faster the SQL command will finish and a result will be returned.
# The rule-of-thumb is to set the key_buffer_size to at least a quarter, but no more than half,
# of the total amount of memory on the server. Ideally, it will be large enough to contain all the
# indexes (the total size of all .MYI files on the server).
key_buffer=8M
join_buffer=1M
max_allowed_packet=8M
table_cache=1024
record_buffer=1M
sort_buffer_size=1024K
read_buffer_size=1024K
# kills a connection after 10 errors, prevents laggy/incorrect mysql connections
max_connect_errors=10
# prevents laggy connections
connect_timeout=10
interactive_timeout=100

read_rnd_buffer_size=1024K
myisam_sort_buffer_size=16M
socket=/var/lib/mysql/mysql.sock
tmp_table_size=8M


[mysql.server]
user=mysql
basedir=/var/lib


[safe_mysqld]
open_files_limit=8192

[mysqldump]
quick
max_allowed_packet=8M
max_allowed_packet=8M

[mysql]
no-auto-rehash

[isamchk]
key_buffer=16M
sort_buffer=16M
read_buffer=8
write_buffer=8M

[myisamchk]
key_buffer=16M
sort_buffer=16M
read_buffer=8M
write_buffer=8M

[mysqlhotcopy]
interactive-timeout
7. MySQL stats from ssh telnet as root user type:

emysql Ver 14.7 Distrib 4.1.18, for pc-linux-gnu (i686) using readline 4.3
Copyright (C) 2002 MySQL AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license
Usage: mysql [OPTIONS] [database]
-?, --help Display this help and exit.
-I, --help Synonym for -?
--auto-rehash Enable automatic rehashing. One doesn't need to use
'rehash' to get table and field completion, but startup
and reconnecting may take a longer time. Disable with
--disable-auto-rehash.
-A, --no-auto-rehash
No automatic rehashing. One has to use 'rehash' to get
table and field completion. This gives a quicker start of
mysql and disables rehashing on reconnect. WARNING:
options deprecated; use --disable-auto-rehash instead.
-B, --batch Don't use history file. Disable interactive behavior.
(Enables --silent)
--character-sets-dir=name
Directory where character sets are.
--default-character-set=name
Set the default character set.
-C, --compress Use compression in server/client protocol.
-#, --debug[=#] This is a non-debug version. Catch this and exit
-D, --database=name Database to use.
--delimiter=name Delimiter to be used.
-e, --execute=name Execute command and quit. (Disables --force and history
file)
-E, --vertical Print the output of a query (rows) vertically.
-f, --force Continue even if we get an sql error.
-g, --no-named-commands
Named commands are disabled. Use \* form only, or use
named commands only in the beginning of a line ending
with a semicolon (;) Since version 10.9 the client now
starts with this option ENABLED by default! Disable with
'-G'. Long format commands still work from the first
line. WARNING: option deprecated; use
--disable-named-commands instead.
-G, --named-commands
Enable named commands. Named commands mean this program's
internal commands; see mysql> help . When enabled, the
named commands can be used from any line of the query,
otherwise only from the first line, before an enter.
Disable with --disable-named-commands. This option is
disabled by default.
-i, --ignore-spaces Ignore space after function names.
--local-infile Enable/disable LOAD DATA LOCAL INFILE.
-b, --no-beep Turn off beep on error.
-h, --host=name Connect to host.
-H, --html Produce HTML output.
-X, --xml Produce XML output
--line-numbers Write line numbers for errors.
-L, --skip-line-numbers
Don't write line number for errors. WARNING: -L is
deprecated, use long version of this option instead.
--no-pager Disable pager and print to stdout. See interactive help
(\h) also. WARNING: option deprecated; use
--disable-pager instead.
--no-tee Disable outfile. See interactive help (\h) also. WARNING:
option deprecated; use --disable-tee instead
-n, --unbuffered Flush buffer after each query.
--column-names Write column names in results.
-N, --skip-column-names
Don't write column names in results. WARNING: -N is
deprecated, use long version of this options instead.
-O, --set-variable=name
Change the value of a variable. Please note that this
option is deprecated; you can set variables directly with
--variable-name=value.
--sigint-ignore Ignore SIGINT (CTRL-C)
-o, --one-database Only update the default database. This is useful for
skipping updates to other database in the update log.
--pager[=name] Pager to use to display results. If you don't supply an
option the default pager is taken from your ENV variable
PAGER. Valid pagers are less, more, cat [> filename],
etc. See interactive help (\h) also. This option does not
work in batch mode.
-p, --password[=name]
Password to use when connecting to server. If password is
not given it's asked from the tty.
-P, --port=# Port number to use for connection.
--prompt=name Set the mysql prompt to this value.
--protocol=name The protocol of connection (tcp,socket,pipe,memory).
-q, --quick Don't cache result, print it row by row. This may slow
down the server if the output is suspended. Doesn't use
history file.
-r, --raw Write fields without conversion. Used with --batch.
--reconnect Reconnect if the connection is lost. Disable with
--disable-reconnect. This option is enabled by default.
-s, --silent Be more silent. Print results with a tab as separator,
each row on new line.
-S, --socket=name Socket file to use for connection.
-t, --table Output in table format.
-T, --debug-info Print some debug info at exit.
--tee=name Append everything into outfile. See interactive help (\h)
also. Does not work in batch mode.
-u, --user=name User for login if not current user.
-U, --safe-updates Only allow UPDATE and DELETE that uses keys.
-U, --i-am-a-dummy Synonym for option --safe-updates, -U.
-v, --verbose Write more. (-v -v -v gives the table output format).
-V, --version Output version information and exit.
-w, --wait Wait and retry if connection is down.
--connect_timeout=# Number of seconds before connection timeout.
--max_allowed_packet=#
Max packet length to send to, or receive from server
--net_buffer_length=#
Buffer for TCP/IP and socket communication
--select_limit=# Automatic limit for SELECT when using --safe-updates
--max_join_size=# Automatic limit for rows in a join when using
--safe-updates
--secure-auth Refuse client connecting to server if it uses old
(pre-4.1.1) protocol

Default options are read from the following files in the given order:
/etc/my.cnf /var/lib/mysql/my.cnf ~/.my.cnf
The following groups are read: mysql client
The following options may be given as the first argument:
--print-defaults Print the program argument list and exit
--no-defaults Don't read default options from any options file
--defaults-file=# Only read default options from the given file #
--defaults-extra-file=# Read this file after the global files are read

Variables (--variable-name=value)
and boolean options {FALSE|TRUE} Value (after reading options)
--------------------------------- -----------------------------
auto-rehash FALSE
character-sets-dir (No default value)
default-character-set latin1
compress FALSE
database (No default value)
delimiter ;
vertical FALSE
force FALSE
named-commands FALSE
local-infile FALSE
no-beep FALSE
host (No default value)
html FALSE
xml FALSE
line-numbers TRUE
unbuffered FALSE
column-names TRUE
sigint-ignore FALSE
port 3306
prompt mysql>
quick FALSE
raw FALSE
reconnect TRUE
socket (No default value)
table FALSE
debug-info FALSE
user root
safe-updates FALSE
i-am-a-dummy FALSE
connect_timeout 0
max_allowed_packet 16777216
net_buffer_length 16384
select_limit 1000
max_join_size 1000000
secure-auth FALSE

8. Is your vb the only thing on the server? or other scripts and sites which utilise php & mysql

The majority of the server is devoted to my site but there are other scripts on the site, notably a few wordpress installations and an image uploading script (celerondude).

9. How many average and max concurrent users are on your vb forum and what your cookie timeout is

Avg. 40 members/80 guests. Max peak in the last week 60 members/140 guests. Max peak ever - 60 members/1400 guests (spider attack)

Cookie timeout - 900

10. Phpinfo file

(Link (http://www.rouseindahouse.com/phpinfo.php))

11. Httpd.conf values

KeepAlive - On
MaxKeepAliveRequests - 10000
KeepAliveTimeout - 5
MinSpareServers - 15
MaxSpareServers - 35
StartServers - 15
MaxClients - 150

AND Maxrequestsperchild value = 0
12. What version of vb are you running?

3.5.4

13. Are any files hitting the 2gb max

Didn't return anything. :)

14. Post output from these 3 commands

uname -a

Linux host.blueuniverse.co.uk 2.4.20-021stab028.18.777-enterprise #1 SMP Wed Sep 14 19:34:46 MSD 2005 i686 athlon i386 GNU/Linux
ulimit -aH

core file size (blocks, -c) 1000000
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 4096
pipe size (512 bytes, -p) 8
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 14335
virtual memory (kbytes, -v) unlimited
cat /proc/cpuinfo

processor : 0
vendor_id : AuthenticAMD
cpu family : 15
model : 5
model name : AMD Opteron(tm) Processor 250
stepping : 10
cpu MHz : 2392.539
cache size : 1024 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 1
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall mmxext lm 3dnowext 3dnow
bogomips : 4771.02

processor : 1
vendor_id : AuthenticAMD
cpu family : 15
model : 5
model name : AMD Opteron(tm) Processor 250
stepping : 10
cpu MHz : 2392.539
cache size : 1024 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 1
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall mmxext lm 3dnowext 3dnow
bogomips : 4784.12



Hope that's cool and thanks in advance,
Ed

eva2000
Mon 24th Apr '06, 8:32am
1. Upgrade PHP to 4.4.2 if you use phpadsnew make sure to update to phpadsnew 2.0.7 or higher to work with PHP 4.4.1/4.4.2
2. Edit /etc/my.cnf and place the following mysql server settings in /etc/my.cnf and restart mysql server afterwards


[mysqld]
socket=/var/lib/mysql/mysql.sock
character-sets-dir=/usr/share/mysql/charsets/
safe-show-database
#old_passwords
back_log = 50
skip-innodb
max_connections = 500
key_buffer = 16M
myisam_sort_buffer_size = 64M
join_buffer_size = 1M
read_buffer_size = 1M
sort_buffer_size = 2M
table_cache = 2000
thread_cache_size = 512
wait_timeout = 180
connect_timeout = 10
tmp_table_size = 64M
max_heap_table_size = 64M
max_allowed_packet = 64M
max_connect_errors = 10
read_rnd_buffer_size = 524288
bulk_insert_buffer_size = 8M
query_cache_limit = 2M
query_cache_size = 48M
query_cache_type = 1
query_prealloc_size = 163840
query_alloc_block_size = 32768
default-storage-engine = MyISAM

[mysql.server]
user=mysql
basedir=/var/lib

[mysqld_safe]
nice = -10
open_files_limit = 8192

[mysqldump]
quick
max_allowed_packet = 16M

[myisamchk]
key_buffer = 64M
sort_buffer = 64M
read_buffer = 16M
write_buffer = 16M

[mysqlhotcopy]
interactive-timeout


3. Install APC Cache lastest version from http://pecl.php.net/package/APC. Read install guide at http://www.vbulletin.com/forum/showthread.php?t=165367 - please remove Zend Optimizer from php.ini before installing APC Cache

4. If you just upgraded to vB 3.5.x try to disable these 4 options:

Admin CP -> vBulletin Options -> Forums Home Page Options -> Display Logged in Users?

Admin CP -> vBulletin Options -> Forum Display Options (forumdisplay) -> Show Users Browsing Forums

Admin CP -> vBulletin Options -> Thread Display Options -> Show Users Browsing Thread

Admin CP -> vBulletin Options -> Message Searching Options -> Automatic Similar Thread search

5. Edit httpd.conf values from

KeepAlive - On
MaxKeepAliveRequests - 10000
KeepAliveTimeout - 5
MinSpareServers - 15
MaxSpareServers - 35
StartServers - 15
MaxClients - 150

AND Maxrequestsperchild value = 0

to

KeepAlive - On
MaxKeepAliveRequests - 120
KeepAliveTimeout - 5
MinSpareServers - 15
MaxSpareServers - 25
StartServers - 15
MaxClients - 200

AND Maxrequestsperchild value = 10000

restart apache