xref: /freebsd/share/man/man7/tuning.7 (revision c17d43407fe04133a94055b0dbc7ea8965654a9f)
1.\" Copyright (c) 2001, Matthew Dillon.  Terms and conditions are those of
2.\" the BSD Copyright as specified in the file "/usr/src/COPYRIGHT" in
3.\" the source tree.
4.\"
5.\" $FreeBSD$
6.\"
7.Dd May 25, 2001
8.Dt TUNING 7
9.Os
10.Sh NAME
11.Nm tuning
12.Nd performance tuning under FreeBSD
13.Sh SYSTEM SETUP - DISKLABEL, NEWFS, TUNEFS, SWAP
14When using
15.Xr disklabel 8
16or
17.Xr sysinstall 8
18to lay out your filesystems on a hard disk it is important to remember
19that hard drives can transfer data much more quickly from outer tracks
20than they can from inner tracks.
21To take advantage of this you should
22try to pack your smaller filesystems and swap closer to the outer tracks,
23follow with the larger filesystems, and end with the largest filesystems.
24It is also important to size system standard filesystems such that you
25will not be forced to resize them later as you scale the machine up.
26I usually create, in order, a 128M root, 1G swap, 128M
27.Pa /var ,
28128M
29.Pa /var/tmp ,
303G
31.Pa /usr ,
32and use any remaining space for
33.Pa /home .
34.Pp
35You should typically size your swap space to approximately 2x main memory.
36If you do not have a lot of RAM, though, you will generally want a lot
37more swap.
38It is not recommended that you configure any less than
39256M of swap on a system and you should keep in mind future memory
40expansion when sizing the swap partition.
41The kernel's VM paging algorithms are tuned to perform best when there is
42at least 2x swap versus main memory.
43Configuring too little swap can lead
44to inefficiencies in the VM page scanning code as well as create issues
45later on if you add more memory to your machine.
46Finally, on larger systems
47with multiple SCSI disks (or multiple IDE disks operating on different
48controllers), we strongly recommend that you configure swap on each drive
49(up to four drives).
50The swap partitions on the drives should be approximately the same size.
51The kernel can handle arbitrary sizes but
52internal data structures scale to 4 times the largest swap partition.
53Keeping
54the swap partitions near the same size will allow the kernel to optimally
55stripe swap space across the N disks.
56Do not worry about overdoing it a
57little, swap space is the saving grace of
58.Ux
59and even if you do not normally use much swap, it can give you more time to
60recover from a runaway program before being forced to reboot.
61.Pp
62How you size your
63.Pa /var
64partition depends heavily on what you intend to use the machine for.
65This
66partition is primarily used to hold mailboxes, the print spool, and log
67files.
68Some people even make
69.Pa /var/log
70its own partition (but except for extreme cases it is not worth the waste
71of a partition ID).
72If your machine is intended to act as a mail
73or print server,
74or you are running a heavily visited web server, you should consider
75creating a much larger partition \(en perhaps a gig or more.
76It is very easy
77to underestimate log file storage requirements.
78.Pp
79Sizing
80.Pa /var/tmp
81depends on the kind of temporary file usage you think you will need.
82128M is
83the minimum we recommend.
84Also note that sysinstall will create a
85.Pa /tmp
86directory, but it is usually a good idea to make
87.Pa /tmp
88a softlink to
89.Pa /var/tmp
90after the fact.
91Dedicating a partition for temporary file storage is important for
92two reasons: first, it reduces the possibility of filesystem corruption
93in a crash, and second it reduces the chance of a runaway process that
94fills up
95.Oo Pa /var Oc Ns Pa /tmp
96from blowing up more critical subsystems (mail,
97logging, etc).
98Filling up
99.Oo Pa /var Oc Ns Pa /tmp
100is a very common problem to have.
101.Pp
102In the old days there were differences between
103.Pa /tmp
104and
105.Pa /var/tmp ,
106but the introduction of
107.Pa /var
108(and
109.Pa /var/tmp )
110led to massive confusion
111by program writers so today programs haphazardly use one or the
112other and thus no real distinction can be made between the two.
113So it makes sense to have just one temporary directory.
114However you handle
115.Pa /tmp ,
116the one thing you do not want to do is leave it sitting
117on the root partition where it might cause root to fill up or possibly
118corrupt root in a crash/reboot situation.
119.Pp
120The
121.Pa /usr
122partition holds the bulk of the files required to support the system and
123a subdirectory within it called
124.Pa /usr/local
125holds the bulk of the files installed from the
126.Xr ports 7
127hierarchy.
128If you do not use ports all that much and do not intend to keep
129system source
130.Pq Pa /usr/src
131on the machine, you can get away with
132a 1 gigabyte
133.Pa /usr
134partition.
135However, if you install a lot of ports
136(especially window managers and Linux-emulated binaries), we recommend
137at least a 2 gigabyte
138.Pa /usr
139and if you also intend to keep system source
140on the machine, we recommend a 3 gigabyte
141.Pa /usr .
142Do not underestimate the
143amount of space you will need in this partition, it can creep up and
144surprise you!
145.Pp
146The
147.Pa /home
148partition is typically used to hold user-specific data.
149I usually size it to the remainder of the disk.
150.Pp
151Why partition at all?
152Why not create one big
153.Pa /
154partition and be done with it?
155Then I do not have to worry about undersizing things!
156Well, there are several reasons this is not a good idea.
157First,
158each partition has different operational characteristics and separating them
159allows the filesystem to tune itself to those characteristics.
160For example,
161the root and
162.Pa /usr
163partitions are read-mostly, with very little writing, while
164a lot of reading and writing could occur in
165.Pa /var
166and
167.Pa /var/tmp .
168By properly
169partitioning your system fragmentation introduced in the smaller more
170heavily write-loaded partitions will not bleed over into the mostly-read
171partitions.
172Additionally, keeping the write-loaded partitions closer to
173the edge of the disk (i.e. before the really big partitions instead of after
174in the partition table) will increase I/O performance in the partitions
175where you need it the most.
176Now it is true that you might also need I/O
177performance in the larger partitions, but they are so large that shifting
178them more towards the edge of the disk will not lead to a significant
179performance improvement whereas moving
180.Pa /var
181to the edge can have a huge impact.
182Finally, there are safety concerns.
183Having a small neat root partition that
184is essentially read-only gives it a greater chance of surviving a bad crash
185intact.
186.Pp
187Properly partitioning your system also allows you to tune
188.Xr newfs 8 ,
189and
190.Xr tunefs 8
191parameters.
192Tuning
193.Xr newfs 8
194requires more experience but can lead to significant improvements in
195performance.
196There are three parameters that are relatively safe to tune:
197.Em blocksize , bytes/i-node ,
198and
199.Em cylinders/group .
200.Pp
201.Fx
202performs best when using 8K or 16K filesystem block sizes.
203The default filesystem block size is 16K,
204which provides best performance for most applications,
205with the exception of those that perform random access on large files
206(such as database server software).
207Such applications tend to perform better with a smaller block size,
208although modern disk characteristics are such that the performance
209gain from using a smaller block size may not be worth consideration.
210Using a block size larger than 16K
211can cause fragmentation of the buffer cache and
212lead to lower performance.
213.Pp
214The defaults may be unsuitable
215for a filesystem that requires a very large number of i-nodes
216or is intended to hold a large number of very small files.
217Such a filesystem should be created with an 8K or 4K block size.
218This also requires you to specify a smaller
219fragment size.
220We recommend always using a fragment size that is 1/8
221the block size (less testing has been done on other fragment size factors).
222The
223.Xr newfs 8
224options for this would be
225.Dq Li "newfs -f 1024 -b 8192 ..." .
226.Pp
227If a large partition is intended to be used to hold fewer, larger files, such
228as a database files, you can increase the
229.Em bytes/i-node
230ratio which reduces the number of i-nodes (maximum number of files and
231directories that can be created) for that partition.
232Decreasing the number
233of i-nodes in a filesystem can greatly reduce
234.Xr fsck 8
235recovery times after a crash.
236Do not use this option
237unless you are actually storing large files on the partition, because if you
238overcompensate you can wind up with a filesystem that has lots of free
239space remaining but cannot accommodate any more files.
240Using 32768, 65536, or 262144 bytes/i-node is recommended.
241You can go higher but
242it will have only incremental effects on
243.Xr fsck 8
244recovery times.
245For example,
246.Dq Li "newfs -i 32768 ..." .
247.Pp
248.Xr tunefs 8
249may be used to further tune a filesystem.
250This command can be run in
251single-user mode without having to reformat the filesystem.
252However, this is possibly the most abused program in the system.
253Many people attempt to
254increase available filesystem space by setting the min-free percentage to 0.
255This can lead to severe filesystem fragmentation and we do not recommend
256that you do this.
257Really the only
258.Xr tunefs 8
259option worthwhile here is turning on
260.Em softupdates
261with
262.Dq Li "tunefs -n enable /filesystem" .
263(Note: in
264.Fx 4.5
265and later, softupdates can be turned on using the
266.Fl U
267option to
268.Xr newfs 8 ,
269and
270.Xr sysinstall 8
271will typically enable softupdates automatically for non-root filesystems).
272Softupdates drastically improves meta-data performance, mainly file
273creation and deletion.
274We recommend enabling softupdates on most filesystems; however, there
275are two limitations to softupdates that you should be aware of when
276determining whether to use it on a filesystem.
277First, softupdates guarantees filesystem consistency in the
278case of a crash but could very easily be several seconds (even a minute!)
279behind updating the physical disk.
280If you crash you may lose more work
281than otherwise.
282Secondly, softupdates delays the freeing of filesystem
283blocks.
284If you have a filesystem (such as the root filesystem) which is
285close to full, doing a major update of it, e.g.\&
286.Dq Li "make installworld" ,
287can run it out of space and cause the update to fail.
288.Pp
289A number of run-time
290.Xr mount 8
291options exist that can help you tune the system.
292For this reason, softupdates will not be enabled on the root file system
293during a typical install.
294The most obvious and most dangerous one is
295.Cm async .
296Do not ever use it, it is far too dangerous.
297A less dangerous and more
298useful
299.Xr mount 8
300option is called
301.Cm noatime .
302.Ux
303filesystems normally update the last-accessed time of a file or
304directory whenever it is accessed.
305This operation is handled in
306.Fx
307with a delayed write and normally does not create a burden on the system.
308However, if your system is accessing a huge number of files on a continuing
309basis the buffer cache can wind up getting polluted with atime updates,
310creating a burden on the system.
311For example, if you are running a heavily
312loaded web site, or a news server with lots of readers, you might want to
313consider turning off atime updates on your larger partitions with this
314.Xr mount 8
315option.
316However, you should not gratuitously turn off atime
317updates everywhere.
318For example, the
319.Pa /var
320filesystem customarily
321holds mailboxes, and atime (in combination with mtime) is used to
322determine whether a mailbox has new mail.
323You might as well leave
324atime turned on for mostly read-only partitions such as
325.Pa /
326and
327.Pa /usr
328as well.
329This is especially useful for
330.Pa /
331since some system utilities
332use the atime field for reporting.
333.Sh STRIPING DISKS
334In larger systems you can stripe partitions from several drives together
335to create a much larger overall partition.
336Striping can also improve
337the performance of a filesystem by splitting I/O operations across two
338or more disks.
339The
340.Xr vinum 8
341and
342.Xr ccdconfig 8
343utilities may be used to create simple striped filesystems.
344Generally
345speaking, striping smaller partitions such as the root and
346.Pa /var/tmp ,
347or essentially read-only partitions such as
348.Pa /usr
349is a complete waste of time.
350You should only stripe partitions that require serious I/O performance,
351typically
352.Pa /var , /home ,
353or custom partitions used to hold databases and web pages.
354Choosing the proper stripe size is also
355important.
356Filesystems tend to store meta-data on power-of-2 boundaries
357and you usually want to reduce seeking rather than increase seeking.
358This
359means you want to use a large off-center stripe size such as 1152 sectors
360so sequential I/O does not seek both disks and so meta-data is distributed
361across both disks rather than concentrated on a single disk.
362If
363you really need to get sophisticated, we recommend using a real hardware
364RAID controller from the list of
365.Fx
366supported controllers.
367.Sh SYSCTL TUNING
368.Xr sysctl 8
369variables permit system behavior to be monitored and controlled at
370run-time.
371Some sysctls simply report on the behavior of the system; others allow
372the system behavior to be modified;
373some may be set at boot time using
374.Xr rc.conf 5 ,
375but most will be set via
376.Xr sysctl.conf 5 .
377There are several hundred sysctls in the system, including many that appear
378to be candidates for tuning but actually are not.
379In this document we will only cover the ones that have the greatest effect
380on the system.
381.Pp
382The
383.Va kern.ipc.shm_use_phys
384sysctl defaults to 0 (off) and may be set to 0 (off) or 1 (on).
385Setting
386this parameter to 1 will cause all System V shared memory segments to be
387mapped to unpageable physical RAM.
388This feature only has an effect if you
389are either (A) mapping small amounts of shared memory across many (hundreds)
390of processes, or (B) mapping large amounts of shared memory across any
391number of processes.
392This feature allows the kernel to remove a great deal
393of internal memory management page-tracking overhead at the cost of wiring
394the shared memory into core, making it unswappable.
395.Pp
396The
397.Va vfs.vmiodirenable
398sysctl defaults to 1 (on).
399This parameter controls how directories are cached
400by the system.
401Most directories are small and use but a single fragment
402(typically 1K) in the filesystem and even less (typically 512 bytes) in
403the buffer cache.
404However, when operating in the default mode the buffer
405cache will only cache a fixed number of directories even if you have a huge
406amount of memory.
407Turning on this sysctl allows the buffer cache to use
408the VM Page Cache to cache the directories.
409The advantage is that all of
410memory is now available for caching directories.
411The disadvantage is that
412the minimum in-core memory used to cache a directory is the physical page
413size (typically 4K) rather than 512 bytes.
414We recommend turning this option off in memory-constrained environments;
415however, when on, it will substantially improve the performance of services
416that manipulate a large number of files.
417Such services can include web caches, large mail systems, and news systems.
418Turning on this option will generally not reduce performance even with the
419wasted memory but you should experiment to find out.
420.Pp
421There are various buffer-cache and VM page cache related sysctls.
422We do not recommend modifying these values.
423As of
424.Fx 4.3 ,
425the VM system does an extremely good job tuning itself.
426.Pp
427The
428.Va net.inet.tcp.sendspace
429and
430.Va net.inet.tcp.recvspace
431sysctls are of particular interest if you are running network intensive
432applications.
433This controls the amount of send and receive buffer space
434allowed for any given TCP connection.
435The default sending buffer is 32K; the default receiving buffer
436is 64K.
437You can often
438improve bandwidth utilization by increasing the default at the cost of
439eating up more kernel memory for each connection.
440We do not recommend
441increasing the defaults if you are serving hundreds or thousands of
442simultaneous connections because it is possible to quickly run the system
443out of memory due to stalled connections building up.
444But if you need
445high bandwidth over a fewer number of connections, especially if you have
446gigabit Ethernet, increasing these defaults can make a huge difference.
447You can adjust the buffer size for incoming and outgoing data separately.
448For example, if your machine is primarily doing web serving you may want
449to decrease the recvspace in order to be able to increase the
450sendspace without eating too much kernel memory.
451Note that the routing table (see
452.Xr route 8 )
453can be used to introduce route-specific send and receive buffer size
454defaults.
455.Pp
456As an additional management tool you can use pipes in your
457firewall rules (see
458.Xr ipfw 8 )
459to limit the bandwidth going to or from particular IP blocks or ports.
460For example, if you have a T1 you might want to limit your web traffic
461to 70% of the T1's bandwidth in order to leave the remainder available
462for mail and interactive use.
463Normally a heavily loaded web server
464will not introduce significant latencies into other services even if
465the network link is maxed out, but enforcing a limit can smooth things
466out and lead to longer term stability.
467Many people also enforce artificial
468bandwidth limitations in order to ensure that they are not charged for
469using too much bandwidth.
470.Pp
471Setting the send or receive TCP buffer to values larger then 65535 will result
472in a marginal performance improvement unless both hosts support the window
473scaling extension of the TCP protocol, which is controlled by the
474.Va net.inet.tcp.rfc1323
475sysctl.
476These extensions should be enabled and the TCP buffer size should be set
477to a value larger than 65536 in order to obtain good performance out of
478certain types of network links; specifically, gigabit WAN links and
479high-latency satellite links.
480RFC1323 support is enabled by default.
481.Pp
482The
483.Va net.inet.tcp.always_keepalive
484sysctl determines whether or not the TCP implementation should attempt
485to detect dead TCP connections by intermittently delivering
486.Dq keepalives
487on the connection.
488By default, this is enabled for all applications; by setting this
489sysctl to 0, only applications that specifically request keepalives
490will use them.
491In most environments, TCP keepalives will improve the management of
492system state by expiring dead TCP connections, particularly for
493systems serving dialup users who may not always terminate individual
494TCP connections before disconnecting from the network.
495However, in some environments, temporary network outages may be
496incorrectly identified as dead sessions, resulting in unexpectedly
497terminated TCP connections.
498In such environments, setting the sysctl to 0 may reduce the occurrence of
499TCP session disconnections.
500.Pp
501The
502.Va kern.ipc.somaxconn
503sysctl limits the size of the listen queue for accepting new TCP connections.
504The default value of 128 is typically too low for robust handling of new
505connections in a heavily loaded web server environment.
506For such environments,
507we recommend increasing this value to 1024 or higher.
508The service daemon
509may itself limit the listen queue size (e.g.\&
510.Xr sendmail 8 ,
511apache) but will
512often have a directive in its configuration file to adjust the queue size up.
513Larger listen queues also do a better job of fending off denial of service
514attacks.
515.Pp
516The
517.Va kern.maxfiles
518sysctl determines how many open files the system supports.
519The default is
520typically a few thousand but you may need to bump this up to ten or twenty
521thousand if you are running databases or large descriptor-heavy daemons.
522The read-only
523.Va kern.openfiles
524sysctl may be interrogated to determine the current number of open files
525on the system.
526.Pp
527The
528.Va vm.swap_idle_enabled
529sysctl is useful in large multi-user systems where you have lots of users
530entering and leaving the system and lots of idle processes.
531Such systems
532tend to generate a great deal of continuous pressure on free memory reserves.
533Turning this feature on and adjusting the swapout hysteresis (in idle
534seconds) via
535.Va vm.swap_idle_threshold1
536and
537.Va vm.swap_idle_threshold2
538allows you to depress the priority of pages associated with idle processes
539more quickly then the normal pageout algorithm.
540This gives a helping hand
541to the pageout daemon.
542Do not turn this option on unless you need it,
543because the tradeoff you are making is to essentially pre-page memory sooner
544rather then later, eating more swap and disk bandwidth.
545In a small system
546this option will have a detrimental effect but in a large system that is
547already doing moderate paging this option allows the VM system to stage
548whole processes into and out of memory more easily.
549.Sh LOADER TUNABLES
550Some aspects of the system behavior may not be tunable at runtime because
551memory allocations they perform must occur early in the boot process.
552To change loader tunables, you must set their values in
553.Xr loader.conf 5
554and reboot the system.
555.Pp
556.Va kern.maxusers
557controls the scaling of a number of static system tables, including defaults
558for the maximum number of open files, sizing of network memory resources, etc.
559As of
560.Fx 4.5 ,
561.Va kern.maxusers
562is automatically sized at boot based on the amount of memory available in
563the system, and may be determined at run-time by inspecting the value of the
564read-only
565.Va kern.maxusers
566sysctl.
567Some sites will require larger or smaller values of
568.Va kern.maxusers
569and may set it as a loader tunable; values of 64, 128, and 256 are not
570uncommon.
571We do not recommend going above 256 unless you need a huge number
572of file descriptors; many of the tunable values set to their defaults by
573.Va kern.maxusers
574may be individually overridden at boot-time or run-time as described
575elsewhere in this document.
576Systems older than
577.Fx 4.4
578must set this value via the kernel
579.Xr config 8
580option
581.Cd maxusers
582instead.
583.Pp
584.Va kern.ipc.nmbclusters
585may be adjusted to increase the number of network mbufs the system is
586willing to allocate.
587Each cluster represents approximately 2K of memory,
588so a value of 1024 represents 2M of kernel memory reserved for network
589buffers.
590You can do a simple calculation to figure out how many you need.
591If you have a web server which maxes out at 1000 simultaneous connections,
592and each connection eats a 16K receive and 16K send buffer, you need
593approximate 32MB worth of network buffers to deal with it.
594A good rule of
595thumb is to multiply by 2, so 32MBx2 = 64MB/2K = 32768.
596So for this case
597you would want to set
598.Va kern.ipc.nmbclusters
599to 32768.
600We recommend values between
6011024 and 4096 for machines with moderates amount of memory, and between 4096
602and 32768 for machines with greater amounts of memory.
603Under no circumstances
604should you specify an arbitrarily high value for this parameter, it could
605lead to a boot-time crash.
606The
607.Fl m
608option to
609.Xr netstat 1
610may be used to observe network cluster use.
611Older versions of
612.Fx
613do not have this tunable and require that the
614kernel
615.Xr config 8
616option
617.Dv NMBCLUSTERS
618be set instead.
619.Pp
620More and more programs are using the
621.Xr sendfile 2
622system call to transmit files over the network.
623The
624.Va kern.ipc.nsfbufs
625sysctl controls the number of filesystem buffers
626.Xr sendfile 2
627is allowed to use to perform its work.
628This parameter nominally scales
629with
630.Va kern.maxusers
631so you should not need to modify this parameter except under extreme
632circumstances.
633.Sh KERNEL CONFIG TUNING
634There are a number of kernel options that you may have to fiddle with in
635a large scale system.
636In order to change these options you need to be
637able to compile a new kernel from source.
638The
639.Xr config 8
640manual page and the handbook are good starting points for learning how to
641do this.
642Generally the first thing you do when creating your own custom
643kernel is to strip out all the drivers and services you do not use.
644Removing things like
645.Dv INET6
646and drivers you do not have will reduce the size of your kernel, sometimes
647by a megabyte or more, leaving more memory available for applications.
648.Pp
649.Dv SCSI_DELAY
650and
651.Dv IDE_DELAY
652may be used to reduce system boot times.
653The defaults are fairly high and
654can be responsible for 15+ seconds of delay in the boot process.
655Reducing
656.Dv SCSI_DELAY
657to 5 seconds usually works (especially with modern drives).
658Reducing
659.Dv IDE_DELAY
660also works but you have to be a little more careful.
661.Pp
662There are a number of
663.Dv *_CPU
664options that can be commented out.
665If you only want the kernel to run
666on a Pentium class CPU, you can easily remove
667.Dv I386_CPU
668and
669.Dv I486_CPU ,
670but only remove
671.Dv I586_CPU
672if you are sure your CPU is being recognized as a Pentium II or better.
673Some clones may be recognized as a Pentium or even a 486 and not be able
674to boot without those options.
675If it works, great!
676The operating system
677will be able to better-use higher-end CPU features for MMU, task switching,
678timebase, and even device operations.
679Additionally, higher-end CPUs support
6804MB MMU pages which the kernel uses to map the kernel itself into memory,
681which increases its efficiency under heavy syscall loads.
682.Sh IDE WRITE CACHING
683.Fx 4.3
684flirted with turning off IDE write caching.
685This reduced write bandwidth
686to IDE disks but was considered necessary due to serious data consistency
687issues introduced by hard drive vendors.
688Basically the problem is that
689IDE drives lie about when a write completes.
690With IDE write caching turned
691on, IDE hard drives will not only write data to disk out of order, they
692will sometimes delay some of the blocks indefinitely when under heavy disk
693loads.
694A crash or power failure can result in serious filesystem
695corruption.
696So our default was changed to be safe.
697Unfortunately, the
698result was such a huge loss in performance that we caved in and changed the
699default back to on after the release.
700You should check the default on
701your system by observing the
702.Va hw.ata.wc
703sysctl variable.
704If IDE write caching is turned off, you can turn it back
705on by setting the
706.Va hw.ata.wc
707loader tunable to 1.
708More information on tuning the ATA driver system may be found in
709.Xr ata 4 .
710.Pp
711There is a new experimental feature for IDE hard drives called
712.Va hw.ata.tags
713(you also set this in the boot loader) which allows write caching to be safely
714turned on.
715This brings SCSI tagging features to IDE drives.
716As of this
717writing only IBM DPTA and DTLA drives support the feature.
718Warning!
719These
720drives apparently have quality control problems and I do not recommend
721purchasing them at this time.
722If you need performance, go with SCSI.
723.Sh CPU, MEMORY, DISK, NETWORK
724The type of tuning you do depends heavily on where your system begins to
725bottleneck as load increases.
726If your system runs out of CPU (idle times
727are perpetually 0%) then you need to consider upgrading the CPU or moving to
728an SMP motherboard (multiple CPU's), or perhaps you need to revisit the
729programs that are causing the load and try to optimize them.
730If your system
731is paging to swap a lot you need to consider adding more memory.
732If your
733system is saturating the disk you typically see high CPU idle times and
734total disk saturation.
735.Xr systat 1
736can be used to monitor this.
737There are many solutions to saturated disks:
738increasing memory for caching, mirroring disks, distributing operations across
739several machines, and so forth.
740If disk performance is an issue and you
741are using IDE drives, switching to SCSI can help a great deal.
742While modern
743IDE drives compare with SCSI in raw sequential bandwidth, the moment you
744start seeking around the disk SCSI drives usually win.
745.Pp
746Finally, you might run out of network suds.
747The first line of defense for
748improving network performance is to make sure you are using switches instead
749of hubs, especially these days where switches are almost as cheap.
750Hubs
751have severe problems under heavy loads due to collision backoff and one bad
752host can severely degrade the entire LAN.
753Second, optimize the network path
754as much as possible.
755For example, in
756.Xr firewall 7
757we describe a firewall protecting internal hosts with a topology where
758the externally visible hosts are not routed through it.
759Use 100BaseT rather
760than 10BaseT, or use 1000BaseT rather then 100BaseT, depending on your needs.
761Most bottlenecks occur at the WAN link (e.g.\&
762modem, T1, DSL, whatever).
763If expanding the link is not an option it may be possible to use
764.Xr dummynet 4
765feature to implement peak shaving or other forms of traffic shaping to
766prevent the overloaded service (such as web services) from affecting other
767services (such as email), or vice versa.
768In home installations this could
769be used to give interactive traffic (your browser,
770.Xr ssh 1
771logins) priority
772over services you export from your box (web services, email).
773.Sh SEE ALSO
774.Xr netstat 1 ,
775.Xr systat 1 ,
776.Xr ata 4 ,
777.Xr dummynet 4 ,
778.Xr login.conf 5 ,
779.Xr rc.conf 5 ,
780.Xr sysctl.conf 5 ,
781.Xr firewall 7 ,
782.Xr hier 7 ,
783.Xr ports 7 ,
784.Xr boot 8 ,
785.Xr ccdconfig 8 ,
786.Xr config 8 ,
787.Xr disklabel 8 ,
788.Xr fsck 8 ,
789.Xr ifconfig 8 ,
790.Xr ipfw 8 ,
791.Xr loader 8 ,
792.Xr mount 8 ,
793.Xr newfs 8 ,
794.Xr route 8 ,
795.Xr sysctl 8 ,
796.Xr sysinstall 8 ,
797.Xr tunefs 8 ,
798.Xr vinum 8
799.Sh HISTORY
800The
801.Nm
802manual page was originally written by
803.An Matthew Dillon
804and first appeared
805in
806.Fx 4.3 ,
807May 2001.
808