Subject Re: [firebird-support] FB persistent connections on php-fpm
Author Mark Rotteveel
On 2017-05-03 19:07, Rudi Feijó rudi.feijo@...
[firebird-support] wrote:
> As of late, we have been experiencing with persistent connections on
> our
> backend. This is justifiable, we have a very high number of connection
> requests (lots of requests from lots of users).
> We are using PHP-FPM connecting on firebird3 superserver.
> We quickly run into memory usage issues - the pconnections are never
> getting released by firebird.

Are you actually closing your connections? As long as a connection is
not closed by the client, then of course Firebird will not close it for

I do not really know PHP, but as far as I know, in normal use it uses
short-lived processes, so not explicitly closing a connection is not a
real problem: when the PHP process ends, the socket closes and Firebird
will then end the connection; if you use PHP-FPM, the process does not
end, so the connection will continue to live. This should not be a
problem if the connection is (or can be reused), but if you 'lose'
access to the connection, it might continue to live, continuing to
consume resources.

> Everytime a connection is created, it stays forever on the DB (we are
> looking in mon@attachments), even if its never used again.
> First I tought it could be a TCP keep alive issue, but the settings are
> ok
> (5 mins tcp keepalive). Also tried using Dummypackets config and its no
> good.
> The thing is, on the windows network monitor, those connections are
> always –
> php never closes them, and, I assume, firebird always views them as
> healthy
> and in-use.
> My guess is that since fpm is a pool manager of its own, it doesn’t
> have any
> mechanism to release/close those connections anyway.
> Since fpm keeps a minimum number of request servers on all the time, as
> long
> as any request created a persistent connection, it will never be closed
> (unless that server went offline, which it wont).

I see a description of what you do and some guesswork, but I'm missing
an in-depth description of the real problem.

Note that your question might be more on topic on the firebird-php
mailinglist than here though.