Live modification of smtp_bind_address

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Live modification of smtp_bind_address

Rob Kelledy
Hi,
I've been attempting to achieve this as previously discussed here - http://www.irbs.net/internet/postfix/0512/0081.html
It's all up and running nicely but I have run into a problem with its scalability. I understand that the transport map doesn't accept $1 type rewriting for security reasons so I've explicitly defined each IP that I want to send mail from (2000+ IP's eventually).

transport_maps = regexp:/etc/postfix/transport -

/^(.*)\+120\.88\.0\.0@(.*)$/ smtp-1.2.3.1:
/^(.*)\+120\.88\.0\.1@(.*)$/ smtp-1.2.3.2:
.
.
/^(.*)\+120\.88\.0\.1@(.*)$/ smtp-1.2.10.254:

Likewise I have added transport configs in master.cf -

smtp-1.2.3.1 unix  - - - - - smtp -o smtp_bind_address=1.2.3.1
smtp-1.2.3.2 unix  - - - - - smtp -o smtp_bind_address=1.2.3.2
.
.
smtp-1.2.10.254 unix  - - - - - smtp -o smtp_bind_address=1.2.10.254

This works great until there are about 300 smtp entries in master.cf when I get this error:

localhost postfix/master[30713]: fatal: pipe: Too many open files

I'm wondering if there's a better way to achieve this? Is rewriting available in master.cf? Or am I just approaching this the wrong way?

Thanks,
Rob.
Reply | Threaded
Open this post in threaded view
|

Re: Live modification of smtp_bind_address

Wietse Venema
Rob Kelledy:
> This works great until there are about 300 smtp entries in master.cf when I get this error:
>
> localhost postfix/master[30713]: fatal: pipe: Too many open files

This requires Postfix >= 2.3 with a kernel that supports kqueue,
epoll or /dev/poll; tweaking of the per-process resource limits
(man limits); plus kernel tuning to increase the number of open
files as described in http://www.postfix.org/TUNING_README.html

As for what you are trying to implement, Postfix does not support
multiple MTA personalities, and probably never will, because a
correct implementation introduces a huge amount of complexity for
something that almost no-one needs.

        Wietse
Reply | Threaded
Open this post in threaded view
|

RE: Live modification of smtp_bind_address

Rob Kelledy
> > This works great until there are about 300 smtp entries in master.cf
> when I get this error:
> >
> > localhost postfix/master[30713]: fatal: pipe: Too many open files
>
> This requires Postfix >= 2.3 with a kernel that supports kqueue,
> epoll or /dev/poll; tweaking of the per-process resource limits
> (man limits); plus kernel tuning to increase the number of open
> files as described in http://www.postfix.org/TUNING_README.html
>
> As for what you are trying to implement, Postfix does not support
> multiple MTA personalities, and probably never will, because a
> correct implementation introduces a huge amount of complexity for
> something that almost no-one needs.
>
>         Wietse

Thanks for your advice.

This error only occurs when trying to restart postfix. I don't ever expect for more than a couple of processes running at once and am wondering why postfix needs to open so many file descriptors on initialization of the master.cf file. My kernel looks to support epoll and I have made the mentioned adjustments to sysctl.conf and enabled them with sysctl -p. Is there a way to find the FD_SETSIZE value of a pre-compiled postfix?
Reply | Threaded
Open this post in threaded view
|

Re: Live modification of smtp_bind_address

Wietse Venema
Rob Kelledy:

> > > This works great until there are about 300 smtp entries in master.cf
> > when I get this error:
> > >
> > > localhost postfix/master[30713]: fatal: pipe: Too many open files
> >
> > This requires Postfix >= 2.3 with a kernel that supports kqueue,
> > epoll or /dev/poll; tweaking of the per-process resource limits
> > (man limits); plus kernel tuning to increase the number of open
> > files as described in http://www.postfix.org/TUNING_README.html
> >
> > As for what you are trying to implement, Postfix does not support
> > multiple MTA personalities, and probably never will, because a
> > correct implementation introduces a huge amount of complexity for
> > something that almost no-one needs.
> >
> >         Wietse
>
> Thanks for your advice.
>
> This error only occurs when trying to restart postfix.

This error is reported by the master daemon BEFORE it runs any
Postfix daemon processes. The master has to open one socket for
each master.cf service (NOT PER DAEMON), otherwise, there is no
way to find out if the service is requested. The master also creates
one pipe per service (NOT PER DAEMON) before a service is needed,
so that it won't run into shortage during peak demand. Postfix does
not know that YOU will be using only a few services at any point
in time.

> Is there a way to find the FD_SETSIZE value of a pre-compiled
> postfix?

The FD_SETSIZE hard limit is not applicable with Postfix >=2.3
and a kernel that supports using kqueue, epoll and /dev/poll.

Now, it may be possible that some maintainer distributes
Postfix versions that don't use kqueue, epoll or /dev/poll.
In that case you are screwed by backwards compatibility.

        Wietse
Reply | Threaded
Open this post in threaded view
|

RE: Live modification of smtp_bind_address

Rob Kelledy
> > > > This works great until there are about 300 smtp entries in master.cf
> > > when I get this error:
> > > >
> > > > localhost postfix/master[30713]: fatal: pipe: Too many open files
> > >
> > > This requires Postfix >= 2.3 with a kernel that supports kqueue,
> > > epoll or /dev/poll; tweaking of the per-process resource limits
> > > (man limits); plus kernel tuning to increase the number of open
> > > files as described in http://www.postfix.org/TUNING_README.html
> > >
> > > As for what you are trying to implement, Postfix does not support
> > > multiple MTA personalities, and probably never will, because a
> > > correct implementation introduces a huge amount of complexity for
> > > something that almost no-one needs.
> > >
> > >         Wietse
> >
> > Thanks for your advice.
> >
> > This error only occurs when trying to restart postfix.
>
> This error is reported by the master daemon BEFORE it runs any
> Postfix daemon processes. The master has to open one socket for
> each master.cf service (NOT PER DAEMON), otherwise, there is no
> way to find out if the service is requested. The master also creates
> one pipe per service (NOT PER DAEMON) before a service is needed,
> so that it won't run into shortage during peak demand. Postfix does
> not know that YOU will be using only a few services at any point
> in time.
>
> > Is there a way to find the FD_SETSIZE value of a pre-compiled
> > postfix?
>
> The FD_SETSIZE hard limit is not applicable with Postfix >=2.3
> and a kernel that supports using kqueue, epoll and /dev/poll.
>
> Now, it may be possible that some maintainer distributes
> Postfix versions that don't use kqueue, epoll or /dev/poll.
> In that case you are screwed by backwards compatibility.
>
>         Wietse

I'm testing on a 2.6 kernel and have used pipetest.c from here - http://www.xmailserver.org/linux-patches/nio-improve.html to test epoll performance which appears ok and improves with modification of fs.file-max=16384 and kernel.threads-max=2048 so I assume the kernel supports it. Postfix is version 2.3.8 but I still receive the 'pipe: Too many open files' error. The source mentions FD_SETSIZE and possibly increasing it via CCARGS=-DFD_SETSIZE=2048 but if I understand what you've said this does not apply to a kernel supporting epoll so recompiling postfix with this flag will not have any effect. Is there something else I need to do?

Otherwise, how hard would it be to modify the master daemon to open a static amount of pipes on initialization. Any pointers to the code where this is implemented?