Windows 7 Performance Tuning

September 12th, 2009 Category: General

Found a few tips on support.microsoft.com how to improve the performance of Windows Vista. Checking my Windows 7 installation it seems that these tips seem also apply to Windows 7. Unfortunately I could not found the English version of this support entry (KB954980), only in German language, but I think it should be understandable because of the many pictures:

Basically the article describes 4 things which help to improve the performance:

  1. Part 2: Improve boot time using Windows ReadyBoost
  2. Part 3: Disable Windows Aero
  3. Part 4: Use extended hard disc write cache
  4. Part 5: Disable unused hardware

On my Windows 7 installation I followed item 1. and 3. Think I have to make further checks how much it improves performance.

Especially item 1. ReadyBoost sounds interesting: Windows uses a USB stick or flash memory card to as additional cache. But I don’t want to use a USB stick, I want to use a PCI Express flash card adapter with a very fast memory card. Guess this should bring best performance.

After first checks my Windows 7 installation boots in about 1:45 minutes (completely). Looks not so bad, since I’ve already installed software like Photoshop, Office, iTunes, etc. The real boot time of Windows 7 is slightly lower than BIOS start up also needs time, approx. 7 seconds.

MySQL Performance Tips

January 11th, 2009 Category: PHP/MySQL

Optimizing a MySQL server is probably not very easy. It depends on your database structure, how many users are accessing your server and so on.

Basics

But there are a few things which could help to improve your performance. On my configuration I’ve added skip-name-resolve in my.cnf:

[mysqld]
skip-name-resolve

Now the MySQL server will not do any DNS name resolves. Please note that permissions based on hostnames will no longer work!

For security reasons I would also recommend binding only to the localhost address. Using this the MySQL server is not reachable on the Ethernet interface. In earlier version of MySQL this was usually done with the skip-networking parameter.

[mysqld]
bind-address    = 127.0.0.1

And I’ve added skip-external-locking and skip-locking:

[mysqld]

skip-external-locking
skip-locking

This could also improve your performance.

Search Length

For text search queries with a allowed length of 2 characters add this line:

ft_min_word_len="2"

Otherwise default minimum length is 3 characters, which means that a search query “select * like ‘%AB%’” will never return any data.

Cache Settings

Caching seems to be a very important thing when optimizing your server. My feeling is that the standard configuration of a MySQL server is not really designed for machines with 1 GByte memory or above.

Below is my configuration, with a few cache settings increased.

[mysqld]
query_cache_limit    =  1M
query_cache_size     = 32M
thread_cache_size    =  8
join_buffer          =  1M
table_cache          = 16M
sort_buffer_size     =  2M
read_buffer_size     =  2M
read_rnd_buffer_size =  2M
tmp_table_size       = 48M
max_allowed_packet   = 16M
thread_stack         = 128K
key_buffer_size      = 32M

This configuration works on a machine with 1 GByte RAM and several databases running. Basically I recommend to increase the cache size settings. And memory helps almost always.

Applies to MySQL version: 5.0.32

Apache Tuning Part 3

December 30th, 2008 Category: Apache

Some further settings which worked well for a server (1GB RAM, single CPU) with max. 120 users simultaneously and doing some video streaming. Settings are found in /etc/apache2/apache.conf

Timeout 30

KeepAlive On

MaxKeepAliveRequests 100

KeepAliveTimeout 5

<IfModule mpm_prefork_module>
StartServers         16
ServerLimit         512
MinSpareServers      16
MaxSpareServers      128
MaxClients          256
MaxRequestsPerChild 55555
</IfModule>

HostnameLookups Off

ServerTokens Prodme
ServerSignature Off
UseCanonicalName Off
TraceEnable Off

HostNameLookups Off are recommended in any case.

Apache Tuning Part 2

December 30th, 2008 Category: Apache

Let’s assume your web server has high disc IO. Every access to a .PHP, .HTML, .JPG, .GIF, etc wil cause a log entry which will be stored on hard disc. In such a case it helps to disable all apache loggings.

You can check the opened log file from apache using the command:

lsof |grep apache|grep log

Oh yes, if you serve lot’s of domains on your server this list will be quite long. To disable logging just uncomment the corresponding lines e.g. in your virtual host definition:

#ErrorLog /var/log/apachd2/mydonain.de-error_log

#CustomLog /var/log/apache2/mydomain.de-access_log combined

Afterwards check your apace configuration for errors:

apache2ctl -t

In case of syntax OK just restart your apache server:

apache2ctl -k graceful

This command is qute because it does a “graceful” restart without anoying users accesing your server right now.

Hint

How to check if my disc IO is high?

Use the command “vmstat 1″ and check the section “IO” (what else…). You will see bi and bo which means blocks received and blocks sent. In case the numbers are high, you will have high disc IO.

procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
0  0 659476  41604   8732 347304    3    3    37    41   20   14 19  7 58 16
3  0 659476  41604   8732 347336    0    0     0     0  410  314  7  0 93  0
0  0 659476  41464   8740 347328    0    0     0   424  522  321 11  1 86  2

Apache Tuning Part 1

December 30th, 2008 Category: Apache

This article applies to apache version 2.2.3 also it will work for other versions.

Apache needs a lot of memory, this will decrease performance on a machine with e.g. 1 GByte memory and about 60 users accessing the server simultaneously a lot. There is a simply method to save memory: disable all unused modules. Yes, it really helps!

Why does it help? Because every apache process started – and a lot will be started when several users are accessing the server – will load all enabled modules.

To get an overview how much memory is consumed by the modules use the command

lsof | grep apache | grep modules

Using this command you will also see which modules consumes much memory.

In my case only the following modules are used:

  • actions.load
  • authz_default.load
  • authn_file.load
  • auth_basic.load
  • authz_user.load
  • env.load
  • mime.load
  • rewrite.load
  • userdir.load
  • alias.load
  • authz_host.load
  • deflate.load
  • expires.load
  • negotiation.load
  • setenvif.load
  • headers.load
  • speling.load
  • cgi.load
  • dir.load
  • include.load
  • php5.load

Modules which are not needed are disabled using the command

a2dismod <module_name>