xref: /freebsd/share/man/man7/tuning.7 (revision eacee0ff7ec955b32e09515246bd97b6edcd2b0f)
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
2654.5
266and later, softupdates can be turned on using the
267.Fl U
268option to
269.Xr newfs 8 ,
270and
271.Xr sysinstall 8
272will typically enable softupdates automatically for non-root filesystems).
273Softupdates drastically improves meta-data performance, mainly file
274creation and deletion.
275We recommend enabling softupdates on most filesystems; however, there
276are two limitations to softupdates that you should be aware of when
277determining whether to use it on a filesystem.
278First, softupdates guarantees filesystem consistency in the
279case of a crash but could very easily be several seconds (even a minute!)
280behind updating the physical disk.
281If you crash you may lose more work
282than otherwise.
283Secondly, softupdates delays the freeing of filesystem
284blocks.
285If you have a filesystem (such as the root filesystem) which is
286close to full, doing a major update of it, e.g.\&
287.Dq Li "make installworld" ,
288can run it out of space and cause the update to fail.
289.Pp
290A number of run-time
291.Xr mount 8
292options exist that can help you tune the system.
293For this reason, softupdates will not be enabled on the root file system
294during a typical install.
295The most obvious and most dangerous one is
296.Cm async .
297Do not ever use it, it is far too dangerous.
298A less dangerous and more
299useful
300.Xr mount 8
301option is called
302.Cm noatime .
303.Ux
304filesystems normally update the last-accessed time of a file or
305directory whenever it is accessed.
306This operation is handled in
307.Fx
308with a delayed write and normally does not create a burden on the system.
309However, if your system is accessing a huge number of files on a continuing
310basis the buffer cache can wind up getting polluted with atime updates,
311creating a burden on the system.
312For example, if you are running a heavily
313loaded web site, or a news server with lots of readers, you might want to
314consider turning off atime updates on your larger partitions with this
315.Xr mount 8
316option.
317However, you should not gratuitously turn off atime
318updates everywhere.
319For example, the
320.Pa /var
321filesystem customarily
322holds mailboxes, and atime (in combination with mtime) is used to
323determine whether a mailbox has new mail.
324You might as well leave
325atime turned on for mostly read-only partitions such as
326.Pa /
327and
328.Pa /usr
329as well.
330This is especially useful for
331.Pa /
332since some system utilities
333use the atime field for reporting.
334.Sh STRIPING DISKS
335In larger systems you can stripe partitions from several drives together
336to create a much larger overall partition.
337Striping can also improve
338the performance of a filesystem by splitting I/O operations across two
339or more disks.
340The
341.Xr vinum 8
342and
343.Xr ccdconfig 8
344utilities may be used to create simple striped filesystems.
345Generally
346speaking, striping smaller partitions such as the root and
347.Pa /var/tmp ,
348or essentially read-only partitions such as
349.Pa /usr
350is a complete waste of time.
351You should only stripe partitions that require serious I/O performance,
352typically
353.Pa /var , /home ,
354or custom partitions used to hold databases and web pages.
355Choosing the proper stripe size is also
356important.
357Filesystems tend to store meta-data on power-of-2 boundaries
358and you usually want to reduce seeking rather than increase seeking.
359This
360means you want to use a large off-center stripe size such as 1152 sectors
361so sequential I/O does not seek both disks and so meta-data is distributed
362across both disks rather than concentrated on a single disk.
363If
364you really need to get sophisticated, we recommend using a real hardware
365RAID controller from the list of
366.Fx
367supported controllers.
368.Sh SYSCTL TUNING
369.Xr sysctl 8
370variables permit system behavior to be monitored and controlled at
371run-time.
372Some sysctls simply report on the behavior of the system; others allow
373the system behavior to be modified;
374some may be set at boot time using
375.Xr rc.conf 5 ,
376but most will be set via
377.Xr sysctl.conf 5 .
378There are several hundred sysctls in the system, including many that appear
379to be candidates for tuning but actually are not.
380In this document we will only cover the ones that have the greatest effect
381on the system.
382.Pp
383The
384.Va kern.ipc.shm_use_phys
385sysctl defaults to 0 (off) and may be set to 0 (off) or 1 (on).
386Setting
387this parameter to 1 will cause all System V shared memory segments to be
388mapped to unpageable physical RAM.
389This feature only has an effect if you
390are either (A) mapping small amounts of shared memory across many (hundreds)
391of processes, or (B) mapping large amounts of shared memory across any
392number of processes.
393This feature allows the kernel to remove a great deal
394of internal memory management page-tracking overhead at the cost of wiring
395the shared memory into core, making it unswappable.
396.Pp
397The
398.Va vfs.vmiodirenable
399sysctl defaults to 1 (on).
400This parameter controls how directories are cached
401by the system.
402Most directories are small and use but a single fragment
403(typically 1K) in the filesystem and even less (typically 512 bytes) in
404the buffer cache.
405However, when operating in the default mode the buffer
406cache will only cache a fixed number of directories even if you have a huge
407amount of memory.
408Turning on this sysctl allows the buffer cache to use
409the VM Page Cache to cache the directories.
410The advantage is that all of
411memory is now available for caching directories.
412The disadvantage is that
413the minimum in-core memory used to cache a directory is the physical page
414size (typically 4K) rather than 512 bytes.
415We recommend turning this option off in memory-constrained environments;
416however, when on, it will substantially improve the performance of services
417that manipulate a large number of files.
418Such services can include web caches, large mail systems, and news systems.
419Turning on this option will generally not reduce performance even with the
420wasted memory but you should experiment to find out.
421.Pp
422There are various buffer-cache and VM page cache related sysctls.
423We do not recommend modifying these values.
424As of
425.Fx 4.3 ,
426the VM system does an extremely good job tuning itself.
427.Pp
428The
429.Va net.inet.tcp.sendspace
430and
431.Va net.inet.tcp.recvspace
432sysctls are of particular interest if you are running network intensive
433applications.
434This controls the amount of send and receive buffer space
435allowed for any given TCP connection.
436The default sending buffer is 32K; the default receiving buffer
437is 64K.
438You can often
439improve bandwidth utilization by increasing the default at the cost of
440eating up more kernel memory for each connection.
441We do not recommend
442increasing the defaults if you are serving hundreds or thousands of
443simultaneous connections because it is possible to quickly run the system
444out of memory due to stalled connections building up.
445But if you need
446high bandwidth over a fewer number of connections, especially if you have
447gigabit Ethernet, increasing these defaults can make a huge difference.
448You can adjust the buffer size for incoming and outgoing data separately.
449For example, if your machine is primarily doing web serving you may want
450to decrease the recvspace in order to be able to increase the
451sendspace without eating too much kernel memory.
452Note that the routing table (see
453.Xr route 8 )
454can be used to introduce route-specific send and receive buffer size
455defaults.
456.Pp
457As an additional management tool you can use pipes in your
458firewall rules (see
459.Xr ipfw 8 )
460to limit the bandwidth going to or from particular IP blocks or ports.
461For example, if you have a T1 you might want to limit your web traffic
462to 70% of the T1's bandwidth in order to leave the remainder available
463for mail and interactive use.
464Normally a heavily loaded web server
465will not introduce significant latencies into other services even if
466the network link is maxed out, but enforcing a limit can smooth things
467out and lead to longer term stability.
468Many people also enforce artificial
469bandwidth limitations in order to ensure that they are not charged for
470using too much bandwidth.
471.Pp
472Setting the send or receive TCP buffer to values larger then 65535 will result
473in a marginal performance improvement unless both hosts support the window
474scaling extension of the TCP protocol, which is controlled by the
475.Va net.inet.tcp.rfc1323
476sysctl.
477These extensions should be enabled and the TCP buffer size should be set
478to a value larger than 65536 in order to obtain good performance out of
479certain types of network links; specifically, gigabit WAN links and
480high-latency satellite links.
481RFC1323 support is enabled by default.
482.Pp
483The
484.Va net.inet.tcp.always_keepalive
485sysctl determines whether or not the TCP implementation should attempt
486to detect dead TCP connections by intermittently delivering
487.Dq keepalives
488on the connection.
489By default, this is enabled for all applications; by setting this
490sysctl to 0, only applications that specifically request keepalives
491will use them.
492In most environments, TCP keepalives will improve the management of
493system state by expiring dead TCP connections, particularly for
494systems serving dialup users who may not always terminate individual
495TCP connections before disconnecting from the network.
496However, in some environments, temporary network outages may be
497incorrectly identified as dead sessions, resulting in unexpectedly
498terminated TCP connections.
499In such environments, setting the sysctl to 0 may reduce the occurrence of
500TCP session disconnections.
501.Pp
502The
503.Va kern.ipc.somaxconn
504sysctl limits the size of the listen queue for accepting new TCP connections.
505The default value of 128 is typically too low for robust handling of new
506connections in a heavily loaded web server environment.
507For such environments,
508we recommend increasing this value to 1024 or higher.
509The service daemon
510may itself limit the listen queue size (e.g.\&
511.Xr sendmail 8 ,
512apache) but will
513often have a directive in its configuration file to adjust the queue size up.
514Larger listen queues also do a better job of fending off denial of service
515attacks.
516.Pp
517The
518.Va kern.maxfiles
519sysctl determines how many open files the system supports.
520The default is
521typically a few thousand but you may need to bump this up to ten or twenty
522thousand if you are running databases or large descriptor-heavy daemons.
523The read-only
524.Va kern.openfiles
525sysctl may be interrogated to determine the current number of open files
526on the system.
527.Pp
528The
529.Va vm.swap_idle_enabled
530sysctl is useful in large multi-user systems where you have lots of users
531entering and leaving the system and lots of idle processes.
532Such systems
533tend to generate a great deal of continuous pressure on free memory reserves.
534Turning this feature on and adjusting the swapout hysteresis (in idle
535seconds) via
536.Va vm.swap_idle_threshold1
537and
538.Va vm.swap_idle_threshold2
539allows you to depress the priority of pages associated with idle processes
540more quickly then the normal pageout algorithm.
541This gives a helping hand
542to the pageout daemon.
543Do not turn this option on unless you need it,
544because the tradeoff you are making is to essentially pre-page memory sooner
545rather then later, eating more swap and disk bandwidth.
546In a small system
547this option will have a detrimental effect but in a large system that is
548already doing moderate paging this option allows the VM system to stage
549whole processes into and out of memory more easily.
550.Sh LOADER TUNABLES
551Some aspects of the system behavior may not be tunable at runtime because
552memory allocations they perform must occur early in the boot process.
553To change loader tunables, you must set their values in
554.Xr loader.conf 5
555and reboot the system.
556.Pp
557.Va kern.maxusers
558controls the scaling of a number of static system tables, including defaults
559for the maximum number of open files, sizing of network memory resources, etc.
560As of
561.Fx 4.5 ,
562.Va kern.maxusers
563is automatically sized at boot based on the amount of memory available in
564the system, and may be determined at run-time by inspecting the value of the
565read-only
566.Va kern.maxusers
567sysctl.
568Some sites will require larger or smaller values of
569.Va kern.maxusers
570and may set it as a loader tunable; values of 64, 128, and 256 are not
571uncommon.
572We do not recommend going above 256 unless you need a huge number
573of file descriptors; many of the tunable values set to their defaults by
574.Va kern.maxusers
575may be individually overridden at boot-time or run-time as described
576elsewhere in this document.
577Systems older than
578.Fx 4.4
579must set this value via the kernel
580.Xr config 8
581option
582.Cd maxusers
583instead.
584.Pp
585.Va kern.ipc.nmbclusters
586may be adjusted to increase the number of network mbufs the system is
587willing to allocate.
588Each cluster represents approximately 2K of memory,
589so a value of 1024 represents 2M of kernel memory reserved for network
590buffers.
591You can do a simple calculation to figure out how many you need.
592If you have a web server which maxes out at 1000 simultaneous connections,
593and each connection eats a 16K receive and 16K send buffer, you need
594approximate 32MB worth of network buffers to deal with it.
595A good rule of
596thumb is to multiply by 2, so 32MBx2 = 64MB/2K = 32768.
597So for this case
598you would want to set
599.Va kern.ipc.nmbclusters
600to 32768.
601We recommend values between
6021024 and 4096 for machines with moderates amount of memory, and between 4096
603and 32768 for machines with greater amounts of memory.
604Under no circumstances
605should you specify an arbitrarily high value for this parameter, it could
606lead to a boot-time crash.
607The
608.Fl m
609option to
610.Xr netstat 1
611may be used to observe network cluster use.
612Older versions of
613.Fx
614do not have this tunable and require that the
615kernel
616.Xr config 8
617option
618.Dv NMBCLUSTERS
619be set instead.
620.Pp
621More and more programs are using the
622.Xr sendfile 2
623system call to transmit files over the network.
624The
625.Va kern.ipc.nsfbufs
626sysctl controls the number of filesystem buffers
627.Xr sendfile 2
628is allowed to use to perform its work.
629This parameter nominally scales
630with
631.Va kern.maxusers
632so you should not need to modify this parameter except under extreme
633circumstances.
634.Sh KERNEL CONFIG TUNING
635There are a number of kernel options that you may have to fiddle with in
636a large scale system.
637In order to change these options you need to be
638able to compile a new kernel from source.
639The
640.Xr config 8
641manual page and the handbook are good starting points for learning how to
642do this.
643Generally the first thing you do when creating your own custom
644kernel is to strip out all the drivers and services you do not use.
645Removing things like
646.Dv INET6
647and drivers you do not have will reduce the size of your kernel, sometimes
648by a megabyte or more, leaving more memory available for applications.
649.Pp
650.Dv SCSI_DELAY
651and
652.Dv IDE_DELAY
653may be used to reduce system boot times.
654The defaults are fairly high and
655can be responsible for 15+ seconds of delay in the boot process.
656Reducing
657.Dv SCSI_DELAY
658to 5 seconds usually works (especially with modern drives).
659Reducing
660.Dv IDE_DELAY
661also works but you have to be a little more careful.
662.Pp
663There are a number of
664.Dv *_CPU
665options that can be commented out.
666If you only want the kernel to run
667on a Pentium class CPU, you can easily remove
668.Dv I386_CPU
669and
670.Dv I486_CPU ,
671but only remove
672.Dv I586_CPU
673if you are sure your CPU is being recognized as a Pentium II or better.
674Some clones may be recognized as a Pentium or even a 486 and not be able
675to boot without those options.
676If it works, great!
677The operating system
678will be able to better-use higher-end CPU features for MMU, task switching,
679timebase, and even device operations.
680Additionally, higher-end CPUs support
6814MB MMU pages which the kernel uses to map the kernel itself into memory,
682which increases its efficiency under heavy syscall loads.
683.Sh IDE WRITE CACHING
684.Fx 4.3
685flirted with turning off IDE write caching.
686This reduced write bandwidth
687to IDE disks but was considered necessary due to serious data consistency
688issues introduced by hard drive vendors.
689Basically the problem is that
690IDE drives lie about when a write completes.
691With IDE write caching turned
692on, IDE hard drives will not only write data to disk out of order, they
693will sometimes delay some of the blocks indefinitely when under heavy disk
694loads.
695A crash or power failure can result in serious filesystem
696corruption.
697So our default was changed to be safe.
698Unfortunately, the
699result was such a huge loss in performance that we caved in and changed the
700default back to on after the release.
701You should check the default on
702your system by observing the
703.Va hw.ata.wc
704sysctl variable.
705If IDE write caching is turned off, you can turn it back
706on by setting the
707.Va hw.ata.wc
708loader tunable to 1.
709More information on tuning the ATA driver system may be found in
710.Xr ata 4 .
711.Pp
712There is a new experimental feature for IDE hard drives called
713.Va hw.ata.tags
714(you also set this in the boot loader) which allows write caching to be safely
715turned on.
716This brings SCSI tagging features to IDE drives.
717As of this
718writing only IBM DPTA and DTLA drives support the feature.
719Warning!
720These
721drives apparently have quality control problems and I do not recommend
722purchasing them at this time.
723If you need performance, go with SCSI.
724.Sh CPU, MEMORY, DISK, NETWORK
725The type of tuning you do depends heavily on where your system begins to
726bottleneck as load increases.
727If your system runs out of CPU (idle times
728are perpetually 0%) then you need to consider upgrading the CPU or moving to
729an SMP motherboard (multiple CPU's), or perhaps you need to revisit the
730programs that are causing the load and try to optimize them.
731If your system
732is paging to swap a lot you need to consider adding more memory.
733If your
734system is saturating the disk you typically see high CPU idle times and
735total disk saturation.
736.Xr systat 1
737can be used to monitor this.
738There are many solutions to saturated disks:
739increasing memory for caching, mirroring disks, distributing operations across
740several machines, and so forth.
741If disk performance is an issue and you
742are using IDE drives, switching to SCSI can help a great deal.
743While modern
744IDE drives compare with SCSI in raw sequential bandwidth, the moment you
745start seeking around the disk SCSI drives usually win.
746.Pp
747Finally, you might run out of network suds.
748The first line of defense for
749improving network performance is to make sure you are using switches instead
750of hubs, especially these days where switches are almost as cheap.
751Hubs
752have severe problems under heavy loads due to collision backoff and one bad
753host can severely degrade the entire LAN.
754Second, optimize the network path
755as much as possible.
756For example, in
757.Xr firewall 7
758we describe a firewall protecting internal hosts with a topology where
759the externally visible hosts are not routed through it.
760Use 100BaseT rather
761than 10BaseT, or use 1000BaseT rather then 100BaseT, depending on your needs.
762Most bottlenecks occur at the WAN link (e.g.\&
763modem, T1, DSL, whatever).
764If expanding the link is not an option it may be possible to use
765.Xr dummynet 4
766feature to implement peak shaving or other forms of traffic shaping to
767prevent the overloaded service (such as web services) from affecting other
768services (such as email), or vice versa.
769In home installations this could
770be used to give interactive traffic (your browser,
771.Xr ssh 1
772logins) priority
773over services you export from your box (web services, email).
774.Sh SEE ALSO
775.Xr netstat 1 ,
776.Xr systat 1 ,
777.Xr ata 4 ,
778.Xr dummynet 4 ,
779.Xr login.conf 5 ,
780.Xr rc.conf 5 ,
781.Xr sysctl.conf 5 ,
782.Xr firewall 7 ,
783.Xr hier 7 ,
784.Xr ports 7 ,
785.Xr boot 8 ,
786.Xr ccdconfig 8 ,
787.Xr config 8 ,
788.Xr disklabel 8 ,
789.Xr fsck 8 ,
790.Xr ifconfig 8 ,
791.Xr ipfw 8 ,
792.Xr loader 8 ,
793.Xr mount 8 ,
794.Xr newfs 8 ,
795.Xr route 8 ,
796.Xr sysctl 8 ,
797.Xr sysinstall 8 ,
798.Xr tunefs 8 ,
799.Xr vinum 8
800.Sh HISTORY
801The
802.Nm
803manual page was originally written by
804.An Matthew Dillon
805and first appeared
806in
807.Fx 4.3 ,
808May 2001.
809