# [CLOSED] Multiple courier-imapd instances for one user

## trossachs

I am finding it increasingly difficult to log into my webmail. When I check my running processes, I find two or more "courier-imapd" processes running for the same user name:

```

top - 21:27:36 up 3 days,  8:09,  6 users,  load average: 5.05, 4.00, 2.64

Tasks: 113 total,   5 running, 108 sleeping,   0 stopped,   0 zombie

Cpu(s):  86.5% user,  13.2% system,   0.0% nice,   0.3% idle

Mem:    515276k total,   429436k used,    85840k free,    89840k buffers

Swap:   506036k total,    54140k used,   451896k free,    63024k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND

  421 root      18   0 94776  92m 4664 R 47.2 18.4   0:12.43 cc1plus

  439 root      18   0  3236 3232 2040 R  3.0  0.6   0:00.09 cc1plus

29908 foo        9   0  1056 1052  948 D  2.0  0.2   0:03.48 courier-imapd

23414 foo        9   0  1060 1056  952 R  1.0  0.2   0:06.60 courier-imapd

28802 root      11   0  1040 1040  812 R  1.0  0.2   0:03.07 top

  363 foo        9   0  1056 1052  948 D  0.7  0.2   0:00.75 courier-imapd

  422 root       9   0  1612 1608  796 S  0.7  0.3   0:00.08 as

  436 root      10   0  1052 1048  868 S  0.7  0.2   0:00.02 sh

30132 root       9   0  2108 2072 1768 S  0.3  0.4   0:04.22 sshd

    1 root       9   0   388  352  332 S  0.0  0.1   0:16.25 init

    2 root       9   0     0    0    0 S  0.0  0.0   0:00.63 keventd

    3 root      19  19     0    0    0 S  0.0  0.0   0:40.98 ksoftirqd_CPU0

    4 root       9   0     0    0    0 S  0.0  0.0   5:42.68 kswapd

    5 root       9   0     0    0    0 S  0.0  0.0   0:00.00 bdflush

    6 root       9   0     0    0    0 S  0.0  0.0   8:32.74 kupdated

    9 root       9   0     0    0    0 S  0.0  0.0   0:00.00 khubd

   10 root       9   0     0    0    0 S  0.0  0.0   2:25.34 kreiserfsd

 1018 root       9   0   668  616  584 S  0.0  0.1   0:52.34 syslog-ng

 1242 root       9   0  1328 1108 1108 S  0.0  0.2   0:00.08 mount.smbfs

 1246 root       9   0  1276 1024 1024 S  0.0  0.2   0:00.07 mount.smbfs

```

I thought it was supposed to be one-per-user? Can someone clarify this for me. Whenever I stop or restart courier, the problem goes away for a 10 minutes or so but then returns. I had some problems recently with a possible break-in so have had to reboot the box and am still picking up the pieces. Apache was being hammered to the point where all the available memory was being used up.

I also have this error in the messages log:

```

Nov 27 21:05:12 s_sys@MWF_02SX130 imapd: Failed to create cache file: maildirwatch (foo)

Nov 27 21:05:12 s_sys@MWF_02SX130 imapd: Error: Input/output error

Nov 27 21:05:12 s_sys@MWF_02SX130 imapd: Check for proper operation and configuration

Nov 27 21:05:12 s_sys@MWF_02SX130 imapd: of the File Access Monitor daemon (famd).

Nov 27 21:05:12 s_sys@MWF_02SX130 imapd: Failed to create cache file: maildirwatch (foo)

Nov 27 21:05:12 s_sys@MWF_02SX130 imapd: Error: Input/output error

Nov 27 21:05:12 s_sys@MWF_02SX130 imapd: Check for proper operation and configuration

Nov 27 21:05:12 s_sys@MWF_02SX130 imapd: of the File Access Monitor daemon (famd).

Nov 27 21:05:12 s_sys@MWF_02SX130 imapd: Failed to create cache file: maildirwatch (foo)

Nov 27 21:05:12 s_sys@MWF_02SX130 imapd: Error: Input/output error

Nov 27 21:05:12 s_sys@MWF_02SX130 imapd: Check for proper operation and configuration

Nov 27 21:05:12 s_sys@MWF_02SX130 imapd: of the File Access Monitor daemon (famd).

Nov 27 21:05:13 s_sys@MWF_02SX130 imapd: Failed to create cache file: maildirwatch (foo)

```

Last edited by trossachs on Sun Dec 05, 2004 3:51 pm; edited 1 time in total

----------

## kashani

my understanding of FAM comes from here.

http://oss.sgi.com/projects/fam/faq.html#why_use_fam

Imap can query fam to find out if new mail has appeared vs having to do a scan of the maildirs. 

http://www.courier-mta.org/?imapd.html

As to the connections I see the same thing on mine, but you should never have more than 4 connectiosn per IP. That's the default setting. You might need to increase this if you have a lot of people using webmail since all connections will be coming from localhost.

http://www.pipeline.com.au/staff/mbowe/isp/webmail-server.htm#COURIER_IMAP

kashani

----------

## trossachs

Is it possible that I can speed up the login time for imap connections or is this dependant on the amount of mail listed in the maildirs? Seems to take forever to log in some users. Or should I increase the MAXDAEMONS config?

----------

## Dr_Stein

This is pretty normal. Also note that if you have Mozilla (or any mail client, really..) set to check all IMAP folders, the maxdaemons limit might need to be raised. 

There's also stuff like "maxperip" or something.. raise 'em, otherwise users might complain about not being able to access IMAP folders.

Outlook Express is funky about opening multiple IMAP connections too.

----------

## trossachs

I have increased the max-ip config to 6. But I was thinking, would courier be busy emptying my Trash before it actually lets me in? There is a 14 day storage period which I believe may have come to an end. This could be why other users log in relaly quickly and I am still waiting!

I have some 159,000 items in the Trash can. Could this also be the "other" processes in the background running under the same user name? Have just logged in another user and they logged in after 6 seconds.

----------

## kashani

160k emails? That's defintely going to cause some problems. I'd look at the last link I posted. You can have the imap daemon auto expire stuff in Trash and Junk. 

kashani

----------

## trossachs

Yeh have re-read you sensible quote. MAXRESIP =  4 should be enough me thinks! However, if I have 10 users, does this setting mean that only 4 can be logged on at one time Kashani? I don't quite understand this setting.

----------

## kashani

Here's the deal on the MAXPERIP. 

Say you're hosting mail for an office with 10 people. They are probably on DSL behind a firewall of some sort. When they connect to your imap server it's going to appear that each person is connecting from the same public IP.

Same thing will webmail. To imap it's going to appear that each connection is originating from 127.0.0.1

Lastly I've found 4 to be pretty low in general. 10 seemed to work much better for me on my personal box. Not sure why, but there it is. 

kashani

----------

