|
Softpanorama
(slightly skeptical)
Open Source Software Educational Society |
May the
source be with you,
but remember the KISS principle ;-)
|
Linux Networking
NFS
See also
But the basic tuning steps include:
Try using NFSv3 if you are currently using NFSv2. There can be very significant
performance increases with this change.
Increasing the read write block size. This is done with the rsize
and wsize mount options. They need to the mount options used by the NFS
clients. Values of 4096 and 8192 reportedly increase performance alot. But see
the notes in the HOWTO about experimenting and measuring the performance implications.
The limits on these are 8192 for NFSv2 and 32768 for NFSv3
Another approach is to increase the number of nfsd threads running. This
is normally controlled by the nfsd init script. On Red Hat Linux machines, the
value "RPCNFSDCOUNT" in the nfs init script controls this value. The best way
to determine if you need this is to experiment. The HOWTO mentions a way to
determin thread usage, but that doesnt seem supported in all kernels.
Another good tool for getting some handle on NFS server performance is `nfsstat`.
This util reads the info in /proc/net/rpc/nfs[d] and displays it in a somewhat
readable format. Some info intended for tuning Solaris, but useful for it's
description of the
nfsstat
format
See also the
tcp tuning
info
Apache config
#######
MinSpareServers 20
MaxSpareServers 80
StartServers 32
# this can be higher if apache is recompiled
MaxClients 256
MaxRequestsPerChild 10000
Note: Starting a massive amount of httpd processes is really a benchmark
hack. In most real world cases, setting a high number for max servers, and a
sane spare server setting will be more than adequate. It's just the instant
on load that benchmarks typically generate that the StartServers helps with.
The MaxRequestPerChild should be bumped up if you are sure that your httpd
processes do not leak memory. Setting this value to 0 will cause the processes
to never reach a limit.
One of the best resources on tuning these values, especially for app servers,
is the
mod_perl
performance tuning documentation.
Bumping the number of available httpd processes
Apache sets a maximum number of possible processes at compile time. It
is set to 256 by default, but in this kind of scenario, can often be exceeded.
To change this, you will need to chage the hardcoded limit in the apache
source code, and recompile it. An example of the change is below:
--- apache_1.3.6/src/include/httpd.h.prezab Fri Aug 6 20:11:14 1999
+++ apache_1.3.6/src/include/httpd.h Fri Aug 6 20:12:50 1999
@@ -306,7 +306,7 @@
* the overhead.
*/
#ifndef HARD_SERVER_LIMIT
-#define HARD_SERVER_LIMIT 256
+#define HARD_SERVER_LIMIT 4000
#endif
/*
To make useage of this many apache's however, you will also need to boost
the number of processes support, at least for 2.2 kernels. See the
section
on kernel process limits for info on increasing this.
The biggest scalability problem with apache, 1.3.x versions at least, is it's
model of using one process per connection. In cases where there large amounts
of concurent connections, this can require a large amount resources. These resources
can include RAM, schedular slots, ability to grab locks, database connections,
file descriptors, and others.
In cases where each connection takes a long time to complete, this is only
compunded. Connections can be slow to complete because of large amounts of cpu
or i/o usage in dynamic apps, large files being transfered, or just talking
to clients on slow links.
There are several strategies to mitigate this. The basic idea being to free
up heavyweight apache processes from having to handle slow to complete connections.
Static Content Servers
If the servers are serving lots of static files (images, videos, pdf's,
etc), a common approach is to serve these files off a dedicated server.
This could be a very light apache setup, or any many cases, something like
thttpd, boa, khttpd, or TUX. In some cases it is possible to run the static
server on the same server, addressed via a different hostname.
For purely static content, some of the other smaller more lightweight
web servers can offer very good performance. They arent nearly as powerful
or as flexible as apache, but for very specific performance crucial tasks,
they can be a big win.
If you need even more ExtremeWebServerPerformance, you probabaly want
to take a look at TUX, written by
Ingo Molnar. This is the current
world record holder for
SpecWeb99. It probabaly owns the right to be called the worlds fastest
web server.
Proxy Usage
For servers that are serving dynamic content, or ssl content, a better approach
is to employ a reverse-proxy. Typically, this would done with either apache's
mod_proxy, or Squid. There can be several advantages from this type of configuration,
including content caching, load balancing, and the prospect of moving slow
connections to lighter weight servers.
The easiest approache is probabaly to use mod_proxy and the "ProxyPass"
directive to pass content to another server. mod_proxy supports a degree
of caching that can offer a significant performance boost. But another advantage
is that since the proxy server and the web server are likely to have a very
fast interconnect, the web server can quickly serve up large content, freeing
up a apache process, why the proxy slowly feeds out the content to clients.
This can be further enhanced by increasing the amount of socket buffer memory
thats for the kernel. See the
section
on tcp tuning for info on this.
proxy links
ListenBacklog
One of the most frustrating thing for a user of a website, is to get "connection
refused" error messages. With apache, the common cause of this is for the
number of concurent connections to exceed the number of available httpd
processes that are available to handle connections.
The apache ListenBacklog paramater lets you specify what backlog paramater
is set to listen(). By default on linux, this can be as high as 128.
Increasing this allows a limited number of httpd's to handle a burst
of attempted connections.
There are some experimental patches from SGI that accelerate apache. More
info at:
I havent really had a chance to test the SGI patches yet, but I've been told
they are pretty effective.
Samba Tuning
Depending on the type of tests, there are a number of tweaks you can do to samba
to improve its performace over the default. The default is best for general
purpose file sharing, but for extreme uses, there are a couple of tweaks.
The first one is to rebuild it with mmap support. In cases where you are
serving up a large amount of small files, this seems to be particularly useful.
You just need to add a "--with-mmap" to the configure line.
You also want to make sure the following options are enabled in the /etc/smb.conf
file:
read raw = no
read prediction = true
level2 oplocks = true
One of the better resources for tuning samba is the "Using Samba" book from
O'reily. The
chapter on
performance tuning is available online.
Openldap tuning
The most important tuning aspect for OpenLDAP is deciding what attributes you
want to build indexes on.
I use the values:
cachesize 10000
dbcachesize 100000
sizelimit 10000
loglevel 0
dbcacheNoWsync
index cn,uid
index uidnumber
index gid
index gidnumber
index mail
If you add the following parameters to /etc/openldap/slapd.conf before entering
the info into the database, they will all get indexed and performance will increase.
netstat
netstat -pa
The `-p` options tells it to try to determine what program has the
socket open, which is often very useful info. For example, someone nmap's
their system and wants to know what is using port 666 for example. Running
netstat -pa will show you its satand running on that tcp port.
One of the most twisted, but useful invocations is:
netstat -a -n|grep -E "^(tcp)"| cut -c 68-|sort|uniq -c|sort -n
This will show you a sorted list of how many sockets are in each
connection state. For example:
9 LISTEN
21 ESTABLISHED
Abstract
Over the past few years, Linux has made its way
into the data centers of many corporations all
over the globe. The Linux operating system has
become accepted by both the scientific and
enterprise user population. Today, Linux is by
far the most versatile operating system. You can
find Linux on embedded devices such as firewalls
and cell phones and mainframes. Naturally,
performance of the Linux operating system has
become a hot topic for both scientific and
enterprise users. However, calculating a global
weather forecast and hosting a database impose
different requirements on the operating system.
Linux has to accommodate all possible usage
scenarios with the most optimal performance. The
consequence of this challenge is that most Linux
distributions contain general tuning parameters
to accommodate all users.
IBMฎ has embraced
Linux, and it is recognized as an operating
system suitable for enterprise-level
applications running on IBM systems. Most
enterprise applications are now available on
Linux, including file and print servers,
database servers, Web servers, and collaboration
and mail servers.
With use of Linux in an enterprise-class
server comes the need to monitor performance
and, when necessary, tune the server to remove
bottlenecks that affect users. This IBM Redpaper
describes the methods you can use to tune Linux,
tools that you can use to monitor and analyze
server performance, and key tuning parameters
for specific server applications. The purpose of
this redpaper is to understand, analyze, and
tune the Linux operating system to yield
superior performance for any type of application
you plan to run on these systems.
The tuning parameters, benchmark results, and
monitoring tools used in our test environment
were executed on Red Hat and Novell SUSE Linux
kernel 2.6 systems running on IBM System x
servers and IBM System z servers. However, the
information in this redpaper should be helpful
for all Linux hardware platforms.
Update 4/2008: Typos corrected
09.30.2008You've just had your first cup of coffee and have received that dreaded
phone call. The system is slow. What are you going to do? This article will discuss
performance bottlenecks and optimization in Red Hat Enterprise Linux (RHEL5).
Before getting into any monitoring or tuning specifics, you should always use
some kind of tuning methodology. This is one which I've used successfully through
the years:
1. Baseline The first thing you must do is establish a baseline, which is a
snapshot of how the system appears when it's performing well. This baseline should
not only compile data, but also document your system's configuration (RAM, CPU and
I/O). This is necessary because you need to know what a well-performing system looks
like prior to fixing it.
2. Stress testing and monitoring This is the part where you monitor and stress
your systems at peak workloads. It's the monitoring which is key here as you cannot
effectively tune anything without some historic trending data.
3. Bottleneck identification
This is where you come up with the diagnosis
for what is ailing your system. The primary objective of section 2 is to determine
the bottleneck. I like to use several monitoring tools here. This allows me to cross-reference
my data for accuracy.
4. Tune Only after you've identified the bottleneck can you tune it.
5. Repeat Once you've tuned it, you can start the cycle again but this time
start from step 2 (monitoring) as you already have your baseline.
It's important to note that you should only make one change at a time. Otherwise,
you'll never know exactly what impacted any changes which might have occurred. It
is only by repeating your tests and consistently monitoring your systems that you
can determine if your tuning is making an impact.
RHEL monitoring tools
Before we can begin to improve the performance of our system, we need to use the
monitoring tools available to us to baseline. Here are some monitoring tools you
should consider using:
OprofileThis tool (made available in RHEL5) utilizes the processor to retrieve kernel system
information about system executables. It allows one to collect samples of performance
data every time a counter detects an interrupt. I like the tool also because it
carries little overhead which is very important because you don't want monitoring
tools to be causing system bottlenecks. One important limitation is that the tool
is very much geared towards finding problems with CPU limited processes. It does
not identify processes which are sleeping or waiting on I/O.
The steps used to start up Oprofile include setting up the profiler, starting
it and then dumping the data.
First we'll set up the profile. This option assumes that one wants to monitor
the kernel.
# opcontrol --setup vmlinux=/usr/lib/debug/lib/modules/'uname -r'/vmlinux
Then we can start it up.
# opcontrol --start
Finally, we'll dump the data.
# opcontrol --stop/--shutdown/--dump
SystemTap
This tool (introduced in RHEL5) collects data by analyzing the running kernel. It
really helps one come up with a correct diagnosis of a performance problem and is
tailor-made for developers. SystemTap eliminates the need for the developer to go
through the recompile and reinstallation process to collect data.
FryskThis is another tool which was introduced by Red Hat in RHEL5. What does it do for
you? It allows both developers and system administrators to monitor running processes
and threads. Frysk differs from Oprofile in that it uses 100% reliable information
(similar to SystemTap) - not just a sampling of data. It also runs in user mode
and does not require kernel modules or elevated privileges. Allowing one to stop
or start running threads or processes is also a very useful feature.
Some more general Linux tools include
top and
vmstat.
While these are considered more basic, often I find them much more useful than more
complex tools. Certainly they are easier to use and can help provide information
in a much quicker fashion.
Top provides a quick snapshot of what is going on in your system in
a friendly character-based display.
It also provides information on CPU, Memory and Swap Space.
Let's look at
vmstat one of the oldest but more important Unix/Linux tools
ever created. Vmstat allows one to get a valuable snapshot of process, memory, sway
I/O and overall CPU utilization. Now let's define some of the fields:
Memory
swpd The amount of virtual memory
free The amount of free memory
buff Amount of memory used for buffers
cache Amount of memory used as page cache
Process
r number of run-able processes
b number or processes sleeping.
Make sure this number does not exceed the
amount of run-able processes, because when this condition occurs it usually signifies
that there are performance problems.
Swap
si the amount of memory swapped in from disk
so the amount of memory swapped out.
This is another important field you should be monitoring if you are swapping out
data, you will likely be having performance problems with virtual memory.
CPU
us The % of time spent in user-level code.
It is preferable for you to have processes which spend more time in user code rather
than system code. Time spent in system level code usually means that the process
is tied up in the kernel rather than processing real data.
sy the time spent in system level code
id the amount of time the CPU is idle wa The amount of time the system is spending
waiting for I/O.
If your system is waiting on I/O everything tends to come to a halt. I start to
get worried when this is > 10.
There is also:
Free This tool provides memory information, giving you data around the total
amount of free and used physical and swap memory.
Now that we've analyzed our systems lets look at what we can do to optimize
and tune our systems.
CPU Overhead Shutting Running Processes
Linux starts up all sorts of processes which are usually not required. This includes
processes such as autofs, cups, xfs, nfslock and sendmail. As a general rule, shut
down anything that isn't explicitly required. How do you do this? The best method
is to use the chkconfig command.
Here's how we can shut these processes down.
[root ((Content component not found.)) _29_140_234 ~]# chkconfig --del xfs
You can also use the GUI - /usr/bin/system-config-services to shut down daemon
process.
Tuning the kernel
To tune your kernel for optimal performance, start with:
sysctl This is the command we use for changing kernel parameters. The
parameters themselves are found in /proc/sys/kernel
Let's change some of the parameters. We'll start with the msgmax parameter.
This parameter specifies the maximum allowable size of a single message in an IPC
message queue. Let's view how it currently looks.
[root ((Content component not found.)) _29_139_52 ~]# sysctl kernel.msgmax
kernel.msgmax = 65536
[root ((Content component not found.)) _29_139_52 ~]#
There are three ways to make these kinds of kernel changes. One way is to change
this using the echo command.
[root ((Content component not found.)) _29_139_52 ~]# echo 131072 >/proc/sys/kernel/msgmax
[root ((Content component not found.)) _29_139_52 ~]# sysctl kernel.msgmax
kernel.msgmax = 131072
[root ((Content component not found.)) _29_139_52 ~]#
Another parameter that is changed quite frequently is SHMMAX, which is
used to define the maximum size (in bytes) for a shared memory segment. In Oracle
this should be set large enough for the largest SGA size. Let's look at the default
parameter:
# sysctl kernel.shmmax
kernel.shmmax = 268435456
This is in bytes which translates to 256 MG. Let's change this to 512 MG, using
the -w flag.
[root ((Content component not found.)) _29_139_52 ~]# sysctl -w kernel.shmmax=5368709132
kernel.shmmax = 5368709132
[root ((Content component not found.)) _29_139_52 ~]#
The final method for making changes is to use a text editor such as vi
directly editing the /etc/sysctl.conf file to manually make our changes.
To allow the parameter to take affect dynamically without a reboot, issue the
sysctl command with the -p parameter.
Obviously, there is more to performance tuning and optimization than we can discuss
in the context of this small article entire books have been written on Linux performance
tuning. For those of you first getting your hands dirty with tuning, I suggest you
tread lightly and spend time working on development, test and/or sandbox environments
prior to deploying any changes into production. Ensure that you monitor the effects
of any changes that you make immediately; it's imperative to know the effect of
your change. Be prepared for the possibility that fixing your bottleneck has created
another one. This is actually not a bad thing in itself, as long as your overall
performance has improved and you understand fully what is happening.
Performance monitoring and tuning is a dynamic process which does not stop after
you have fixed a problem. All you've done is established a new baseline. Don't rest
on your laurels, and understand that performance monitoring must be a routine part
of your role as a systems administrator.
About the author: Ken Milberg is a systems consultant with two decades
of experience working with Unix and Linux systems. He is a SearchEnterpriseLinux.com
Ask the Experts advisor and columnist.
[Feb 23, 2009]
Deployment_Guide/Gathering System Information
Before you learn how to configure your system, you should learn how to gather
essential system>
information. For example, you should know how to find the amount of free
memory, the amount
of available hard drive space, how your hard drive is partitioned, and what
processes are
running. This chapter discusses how to retrieve this type of information
from your Red Hat
Enterprise Linux system using simple commands and a few simple programs.
1. System Processes
The
ps ax
command displays a list of current system processes,
including processes owned by other users. To display the owner alongside each process, use the
ps aux command.
This list is a static list; in other words, it is a snapshot of what was running when
you invoked the command. If you want a constantly updated list of running processes, use
top
as described below. The ps
output can be long. To prevent it from scrolling
off the screen, you can pipe it through less:
ps aux | less
You can use the
ps
command in combination with the
grep command
to see if a process is running. For example, to determine if
Emacs is running, use the following command:
ps ax | grep emacs
The
top
command displays currently running processes and
important information about them including their memory and CPU usage. The list is both real-time and interactive.
An example of output from the top
command is provided as follows:
To exit top
press the q key. Useful
interactive commands that you can use:
Immediately refresh the display
h
Display a help screen
k
Kill a process. You are prompted for the
process ID and the signal to send to it.
n
Change the number of processes displayed.
You are prompted to enter the number.
u
Sort by user.
M
Sort by memory usage.
P
Sort by CPU usage.
For more information, refer to the top(1)
manual page.
Over the past few years, Linux has made its way into the data centers of many
corporations all over the globe. The Linux operating system has become accepted
by both the scientific and enterprise user population. Today, Linux is by far
the most versatile operating system. You can find Linux on embedded devices
such as firewalls and cell phones and mainframes. Naturally, performance of
the Linux operating system has become a hot topic for both scientific and enterprise
users. However, calculating a global weather forecast and hosting a database
impose different requirements on the operating system. Linux has to accommodate
all possible usage scenarios with the most optimal performance. The consequence
of this challenge is that most Linux distributions contain general tuning parameters
to accommodate all users.IBMฎ has embraced Linux, and it is recognized as
an operating system suitable for enterprise-level applications running on IBM
systems. Most enterprise applications are now available on Linux, including
file and print servers, database servers, Web servers, and collaboration and
mail servers.
With use of Linux in an enterprise-class server comes the need to monitor
performance and, when necessary, tune the server to remove bottlenecks that
affect users. This IBM Redpaper describes the methods you can use to tune Linux,
tools that you can use to monitor and analyze server performance, and key tuning
parameters for specific server applications. The purpose of this redpaper is
to understand, analyze, and tune the Linux operating system to yield superior
performance for any type of application you plan to run on these systems.
The tuning parameters, benchmark results, and monitoring tools used in our
test environment were executed on Red Hat and Novell SUSE Linux kernel 2.6 systems
running on IBM System x servers and IBM System z servers. However, the information
in this redpaper should be helpful for all Linux hardware platforms. >
dkftpbench
http://www.kegel.com/
Check out the "c10k problem" page in particular, but the entire site has _lots_
of useful tuning info.
http://linuxperf.nl.linux.org/
Site organized by Rik Van Riel and a few other folks. Probabaly the best linux
specific system tuning page.
http://www.citi.umich.edu/projects/citi-netscape/
Linux Scalibity Project at Umich.
NFS Performance
Tunging
Info on tuning linux kernel NFS in particular, and linux network and disk io
in general
http://home.att.net/~jageorge/performance.html
Linux Performance Tuning Checklist. Some useful content.
http://www.linux.com/tuneup/
Miscelaneous performace tuning tips at linux.com
http://www.psc.edu/networking/perf_tune.html#Linux
Summary of tcp tuning info
Utilities
Some simple utilities that come in handy when doing performance tuning.
dkftpbench
Need to stress out an ftp server, or measure how many users it can support?
dkftpbench can do it.
Want to write your own highly efficient networking software, but
annoyed by having to support very different code for Linux, FreeBSD,
and Solaris? libPoller can help.
dklimits
fd-limit
a tiny util for determining the number of file descriptors available.
fd-limit.c
thread-limit
A util for determining the number of pthreads a system can use. This
and fd-count are both from the system tuning page for
Volano chat, a multithread
java based chat server.
thread-limit.c
Copyright ฉ 1996-2009 by Dr. Nikolai Bezroukov.
www.softpanorama.org was
created as a service to the UN Sustainable Development Networking Programme (SDNP)
in the author free time.
Submit
comments This document is an industrial compilation designed and created
exclusively for educational use and is placed under the copyright of the
Open Content License(OPL).
Site uses AdSense so you need to be aware of Google privacy policy. Original materials copyright belong to respective owners. Quotes are made
for educational purposes only in compliance with the fair use doctrine.
Disclaimer:
- The statements, views and opinions presented on
this web page are those of the author and are not endorsed by, nor do they necessarily
reflect, the opinions of the author present and former employers, SDNP or any other
organization the author may be associated with.
- We do not warrant the correctness of the information provided or its
fitness for any purpose
- In no way this site is associated with or endorse cybersquatters
using
the term "softpanorama" with other main or country domains (e.g. softpanorama.com) with
bad faith intent to profit from the goodwill belonging to
someone else.
Last modified:
August 10, 2009