Wednesday, May 20, 2009

Sendmail - "user open" timeouts...

Hello again - two posts in one day - my aren't you the lucky ones!

As you're all aware, as well as cartoons, I'm a I.T. guy, and part of my job involves looking after Sendmail installations. Recently, I came across a problem which although is well known, no real answer has ever been given that I could find. In the hope of helping others who have had the same problem, here are the details...

There are lots of posts on the net, regarding sendmail creating lot's of connections which, when examined using ps, have the phrase "user open". If there are too many of these connections, sendmail can start rejecting connections, effectively giving you a sort of denial of service attack.

These connections stay open, because the smtp conversation has halted, and sendmail is waiting to timeout these connections. Part one of your fix for this condition, is to look at the SMTP conversation timeouts in the sendmail.mc, and set them to be something useful (the defaults are FAR TOO LONG) - 30 seconds is usually long enough. See this post...

Once your timeouts are more reasonable, start looking at your queue processing - specifically, how often do you process your queue? The default in some installations is as low as 5 minutes. This is OK, provided you have a small queue with only a few failing messages in it. Once you get to a large queue of failed messages (say 400), problems start to occur. Imagine your timeouts are set to 2 minutes. If each of your 400 messages takes 2 minutes to time out, it will take you up to 800 minutes to process the entire queue - fine, but if you're processing the queue every 5 minutes (and starting a new process each time) you'll eventually run out of connections...

The secret therefore, is to lower your timeout limits to sensible values, and process your queue less. In my case, I changed the queue processing to run every 20 minutes, which, when combined with sensible timeouts, dropped my queue processing time down, and kept my connections under control.

I hope this helps someone get out of a jam!

No comments: