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