MINI SHELL

Server : Apache/2.2.2 (Fedora)
System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686
User : apache ( 48)
PHP Version : 5.2.9
Disable Function : NONE
Directory :  /proc/self/root/usr/share/doc/squid-2.5.STABLE14/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/self/root/usr/share/doc/squid-2.5.STABLE14/FAQ-22.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
 <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.21">
 <TITLE>SQUID Frequently Asked Questions: DISKD</TITLE>
 <LINK HREF="FAQ-23.html" REL=next>
 <LINK HREF="FAQ-21.html" REL=previous>
 <LINK HREF="FAQ.html#toc22" REL=contents>
</HEAD>
<BODY>
<A HREF="FAQ-23.html">Next</A>
<A HREF="FAQ-21.html">Previous</A>
<A HREF="FAQ.html#toc22">Contents</A>
<HR>
<H2><A NAME="s22">22.</A> <A HREF="FAQ.html#toc22">DISKD</A></H2>

<H2><A NAME="ss22.1">22.1</A> <A HREF="FAQ.html#toc22.1">What is DISKD?</A>
</H2>

<P>DISKD refers to some features in Squid-2.4 to improve Disk I/O
performance.  The basic idea is that each <EM>cache_dir</EM> has its
own <EM>diskd</EM> child process.  The diskd process performs all disk
I/O operations (open, close, read, write, unlink) for the cache_dir.
Message queues are used to send requests and responses between the
Squid and diskd processes.  Shared memory is used for chunks of
data to be read and written.</P>

<H2><A NAME="ss22.2">22.2</A> <A HREF="FAQ.html#toc22.2">Does it perform better?</A>
</H2>

<P>Yes.  We benchmarked Squid-2.4 with DISKD at the 
<A HREF="http://polygraph.ircache.net/Results/bakeoff-2/">Second IRCache Bake-Off</A>.  The results are also described 
<A HREF="/Benchmarking/bakeoff-02/">here</A>.  At the bakeoff, we
got 160 req/sec with diskd.  Without diskd, we'd have gotten about
40 req/sec.</P>

<H2><A NAME="ss22.3">22.3</A> <A HREF="FAQ.html#toc22.3">How do I use it?</A>
</H2>

<P>You need to run Squid version 
<A HREF="/Versions/v2/2.4">2.4</A> or later.
Your operating system must support message queues, and shared memory.</P>
<P>To configure Squid for DISKD, use the <EM>--enable-storeio</EM> option:
<PRE>
% ./configure --enable-storeio=diskd,ufs
</PRE>
</P>

<H2><A NAME="ss22.4">22.4</A> <A HREF="FAQ.html#toc22.4">FATAL: Unknown cache_dir type 'diskd'</A>
</H2>

<P>You didn't put <EM>diskd</EM> in the list of storeio modules as described
above.  You need to run <EM>configure</EM> and and recompile Squid.</P>

<H2><A NAME="ss22.5">22.5</A> <A HREF="FAQ.html#toc22.5">If I use DISKD, do I have to wipe out my current cache?</A>
</H2>

<P>No.  Diskd uses the same storage scheme as the standard "UFS"
type.  It only changes how I/O is performed.</P>

<H2><A NAME="ss22.6">22.6</A> <A HREF="FAQ.html#toc22.6">How do I configure message queues?</A>
</H2>

<P>Most Unix operating systems have message queue support
by default.  One way to check is to see if you have
an <EM>ipcs</EM> command.</P>

<P>However, you will likely need to increase the message
queue parameters for Squid.  Message queue implementations
normally have the following parameters:
<DL>
<DT><B>MSGMNB</B><DD><P>Maximum number of bytes per message queue.</P>
<DT><B>MSGMNI</B><DD><P>Maximum number of message queue identifiers (system wide).</P>
<DT><B>MSGSEG</B><DD><P>Maximum number of message segments per queue.</P>
<DT><B>MSGSSZ</B><DD><P>Size of a message segment.</P>
<DT><B>MSGTQL</B><DD><P>Maximum number of messages (system wide).</P>
<DT><B>MSGMAX</B><DD><P>Maximum size of a whole message.  On some systems you may need to
increase this limit.  On other systems, you may not be able
to change it.</P>
</DL>
</P>

<P>The messages between Squid and diskd are 32 bytes for 32-bit CPUs
and 40 bytes for 64-bit CPUs.  Thus, MSGSSZ should be 32 or greater.
You may want to set it to a larger value, just to be safe.</P>

<P>We'll have two queues for each <EM>cache_dir</EM> -- one in each direction.
So, MSGMNI needs to be at least two times the number of <EM>cache_dir</EM>'s.</P>

<P>I've found that 75 messages per queue is about the limit of decent performance.
If each diskd message consists of just one segment (depending on your
value of MSGSSZ), then MSGSEG should be greater than 75.</P>

<P>MSGMNB and MSGTQL affect how many messages can be in the queues
at one time.  Diskd messages shouldn't be
more than 40 bytes, but let's use 64 bytes to be safe.  MSGMNB
should be at least 64*75.  I recommend rounding up to the nearest
power of two, or 8192.</P>

<P>MSGTQL should be at least 75 times the number of <EM>cache_dir</EM>'s
that you'll have.</P>

<H3>FreeBSD</H3>

<P>Your kernel must have
<PRE>
options         SYSVMSG
</PRE>
</P>

<P>You can set the parameters in the kernel as follows.  This is just
an example.  Make sure the values are appropriate for your system:
<PRE>
options         MSGMNB=8192     # max # of bytes in a queue
options         MSGMNI=40       # number of message queue identifiers
options         MSGSEG=512      # number of message segments per queue
options         MSGSSZ=64       # size of a message segment
options         MSGTQL=2048     # max messages in system
</PRE>
</P>

<H3>Digital Unix</H3>

<P>Message queue support seems to be in the kernel
by default.  Setting the options is as follows:
<PRE>
options         MSGMNB="8192"     # max # bytes on queue
options         MSGMNI="40"       # # of message queue identifiers
options         MSGMAX="2048"     # max message size
options         MSGTQL="2048"     # # of system message headers
</PRE>
</P>

<P>by 
<A HREF="mailto:B.C.Phillips at massey dot ac dot nz">Brenden Phillips</A></P>
<P>If you have a newer version (DU64), then you can probably use
<EM>sysconfig</EM> instead.  To see what the current IPC settings are run 
<PRE>
# sysconfig -q ipc
</PRE>

To change them make a file like this called ipc.stanza:
<PRE>
ipc:
        msg-max = 2048
        msg-mni = 40
        msg-tql = 2048
        msg-mnb = 8192
</PRE>

then run
<PRE>
# sysconfigdb -a -f ipc.stanza 
</PRE>

You have to reboot for the change to take effect.</P>



<H3>Linux</H3>

<P>In my limited browsing on Linux, I didn't see any way to change
message queue parameters except to modify the include files
and build a new kernel.  On my system, the file
is <EM>/usr/src/linux/include/linux/msg.h</EM>.</P>

<P>Stefan K&ouml;psell reports that if you compile sysctl support
into your kernel, then you can change the following values:
<UL>
<LI>kernel.msgmnb</LI>
<LI>kernel.msgmni</LI>
<LI>kernel.msgmax</LI>
</UL>
</P>

<H3>Solaris</H3>

<P>Refer to 
<A HREF="http://www.sunworld.com/sunworldonline/swol-11-1997/swol-11-insidesolaris.html">Demangling Message Queues</A> in Sunworld Magazine.</P>

<P>I don't think the above article really tells you how to set the parameters.
You do it in <EM>/etc/system</EM> with lines like this:
<PRE>
set msgsys:msginfo_msgmax=2048
set msgsys:msginfo_msgmnb=8192
set msgsys:msginfo_msgmni=40
set msgsys:msginfo_msgssz=64
set msgsys:msginfo_msgtql=2048
</PRE>
</P>
<P>Of course, you must reboot whenever you modify <EM>/etc/system</EM>
before changes take effect.</P>

<H2><A NAME="ss22.7">22.7</A> <A HREF="FAQ.html#toc22.7">How do I configure shared memory?</A>
</H2>

<P>Shared memory uses a set of parameters similar to the ones for message
queues.  The Squid DISKD implementation uses one shared memory area
for each cache_dir.  Each shared memory area is about
800 kilobytes in size.  You may need to modify your system's
shared memory parameters:</P>

<P>
<DL>
<DT><B>SHMSEG</B><DD><P>Maximum number of shared memory segments per process.</P>
<DT><B>SHMMNI</B><DD><P>Maximum number of shared memory segments for the whole system.</P>
<DT><B>SHMMAX</B><DD><P>Largest shared memory segment size allowed.</P>
<DT><B>SHMALL</B><DD><P>Total amount of shared memory that can be used.</P>
</DL>
</P>

<P>For Squid and DISKD, <EM>SHMMNI</EM> and <EM>SHMMNI</EM> must be greater than
or equal to the number of <EM>cache_dir</EM>'s that you have.   <EM>SHMMAX</EM>
must be at least 800 kilobytes.  <EM>SHMALL</EM> must be at least 
<EM>SHMMAX</EM> 800 kilobytes multiplied by the number of <EM>cache_dir</EM>'s.</P>

<H3>FreeBSD</H3>

<P>Your kernel must have
<PRE>
options         SYSVSHM
</PRE>
</P>

<P>You can set the parameters in the kernel as follows.  This is just
an example.  Make sure the values are appropriate for your system:
<PRE>
options         SHMSEG=16       # max shared mem id's per process
options         SHMMNI=32       # max shared mem id's per system
options         SHMMAX=2097152  # max shared memory segment size (bytes)
options         SHMALL=4096     # max amount of shared memory (pages)
</PRE>
</P>

<H3>Digital Unix</H3>

<P>Message queue support seems to be in the kernel
by default.  Setting the options is as follows:
<PRE>
options         SHMSEG="16"       # max shared mem id's per process
options         SHMMNI="32"       # max shared mem id's per system
options         SHMMAX="2097152"  # max shared memory segment size (bytes)
options         SHMALL=4096       # max amount of shared memory (pages)
</PRE>
</P>

<P>by 
<A HREF="mailto:B.C.Phillips at massey dot ac dot nz">Brenden Phillips</A></P>
<P>If you have a newer version (DU64), then you can probably use
<EM>sysconfig</EM> instead.  To see what the current IPC settings are run 
<PRE>
# sysconfig -q ipc
</PRE>

To change them make a file like this called ipc.stanza:
<PRE>
ipc:
        shm-seg = 16
        shm-mni = 32
        shm-max = 2097152
        shm-all = 4096
</PRE>

then run
<PRE>
# sysconfigdb -a -f ipc.stanza 
</PRE>

You have to reboot for the change to take effect.</P>


<H3>Linux</H3>

<P>In my limited browsing on Linux, I didn't see any way to change
shared memory parameters except to modify the include files
and build a new kernel.  On my system, the file
is <EM>/usr/src/linux/include/asm-i386/shmparam.h</EM></P>

<P>Oh, it looks like you can change <EM>SHMMAX</EM> by writing
the file <EM>/proc/sys/kernel/shmmax</EM>.</P>

<P>Stefan K&ouml;psell reports that if you compile sysctl support
into your kernel, then you can change the following values:
<UL>
<LI>kernel.shmall</LI>
<LI>kernel.shmmni</LI>
<LI>kernel.shmmax</LI>
</UL>
</P>

<H3>Solaris</H3>

<P>Refer to
<A HREF="http://www.sunworld.com/swol-09-1997/swol-09-insidesolaris.html">Shared memory uncovered</A>
in Sunworld Magazine.</P>

<P>To set the values, you can put these lines in <EM>/etc/system</EM>:
<PRE>
set shmsys:shminfo_shmmax=2097152
set shmsys:shminfo_shmmni=32
set shmsys:shminfo_shmseg=16
</PRE>
</P>

<H2><A NAME="ss22.8">22.8</A> <A HREF="FAQ.html#toc22.8">Sometimes shared memory and message queues aren't released when Squid exits.</A>
</H2>

<P>Yes, this is a little problem sometimes.  Seems like the operating system
gets confused and doesn't always release shared memory and message
queue resources when processes exit, especially if they exit abnormally.
To fix it you can ``manually'' clear the resources with the <EM>ipcs</EM> command.
Add this command into your <EM>RunCache</EM> or <EM>squid_start</EM>
script:
<PRE>
ipcs | grep '^[mq]' | awk '{printf "ipcrm -%s %s\n", $1, $2}' | /bin/sh
</PRE>
</P>

<H2><A NAME="ss22.9">22.9</A> <A HREF="FAQ.html#toc22.9">What are the Q1 and Q2 parameters?</A>
</H2>

<P>In the source code, these are called <EM>magic1</EM> and <EM>magic2</EM>.
These numbers refer to the number of oustanding requests on a message
queue.  They are specified on the <EM>cache_dir</EM> option line, after
the L1 and L2 directories:
<PRE>
cache_dir diskd /cache1 1024 16 256 Q1=72 Q2=64
</PRE>
</P>
<P>If there are more than Q1 messages outstanding, then Squid will
intentionally fail to open disk files for reading and writing.
This is a load-shedding mechanism.  If your cache gets really really
busy and the disks can not keep up, Squid bypasses the disks until
the load goes down again.</P>
<P>If there are more than Q2 messages outstanding, then the main Squid
process ``blocks'' for a little bit until the diskd process services
some of the messages and sends back some replies. </P>
<P>Q1 should be larger than Q2.  You want Squid to get to the 
``blocking'' condition before it gets to the ``refuse to open files''
condition.</P>
<P>Reasonable values for Q1 and Q2 are 72 and 64, respectively.</P>


<HR>
<A HREF="FAQ-23.html">Next</A>
<A HREF="FAQ-21.html">Previous</A>
<A HREF="FAQ.html#toc22">Contents</A>
</BODY>
</HTML>

Anon7 - 2021