Postgres connections optimization #4342
Hello, On P-CSCF when running we have 200+ permanent connection to postgres db, even if there is no traffic. Is there a way to manage connections dynamically using a pool like using PgBouncer ? Regards, Stéphane
Hello, have a look to the actual source of the connections (kamailio PID etc..). In many cases a lot of connections are created during startup and then should expire after some time, because they are not used. The only connections that should stay are from the processed processing actual traffic on external interfaces etc. This is at least the behaviour on MySQL. Cheers, Henning From: Stephane Savonitto via sr-users <sr-users@lists.kamailio.org> Sent: Dienstag, 29. Juli 2025 17:51 To: sr-users@lists.kamailio.org Cc: Stephane Savonitto <stephane.savonitto@airnity.com> Subject: [SR-Users] Postgres connections optimization #4342 Hello, On P-CSCF when running we have 200+ permanent connection to postgres db, even if there is no traffic. Is there a way to manage connections dynamically using a pool like using PgBouncer ? Regards, Stéphane
Hi, Thanks for your feedback. Could you tell me how many permanent connections are established based on your setup ? I’ve checked and didn’t found any code update related to connection pool, do you think this could be a feature request ? Regards, Stéphane De : Henning Westerholt <hw@gilawa.com> Date : mercredi, 30 juillet 2025 à 09:07 À : Kamailio (SER) - Users Mailing List <sr-users@lists.kamailio.org> Cc : Stephane Savonitto <stephane.savonitto@airnity.com> Objet : RE: Postgres connections optimization #4342 Vous n’obtenez pas souvent d’e-mail à partir de hw@gilawa.com. Pourquoi c’est important<https://aka.ms/LearnAboutSenderIdentification> Hello, have a look to the actual source of the connections (kamailio PID etc..). In many cases a lot of connections are created during startup and then should expire after some time, because they are not used. The only connections that should stay are from the processed processing actual traffic on external interfaces etc. This is at least the behaviour on MySQL. Cheers, Henning From: Stephane Savonitto via sr-users <sr-users@lists.kamailio.org> Sent: Dienstag, 29. Juli 2025 17:51 To: sr-users@lists.kamailio.org Cc: Stephane Savonitto <stephane.savonitto@airnity.com> Subject: [SR-Users] Postgres connections optimization #4342 Hello, On P-CSCF when running we have 200+ permanent connection to postgres db, even if there is no traffic. Is there a way to manage connections dynamically using a pool like using PgBouncer ? Regards, Stéphane
You can put a pgbouncer in front of postgres That pgbouncer will multiplex all incoming db connections into one (connected to pgsql) pgbouncer will listen on standard pgsql port, and you change the config of pgsql so it listen on a modified port or local socket only (pointed by the pgbouncer config) This way you will have a very tiny impact on the overall platform, just add pgbouncer on the pgsql machine, and change the port pgsql listen to (or limit it to listen on local socket) Sincerely, Giovanni Maruzzelli OpenTelecom.IT cell: +39 347 266 56 18 On Wed, Jul 30, 2025, 10:55 Stephane Savonitto via sr-users < sr-users@lists.kamailio.org> wrote:
Hi,
Thanks for your feedback. Could you tell me how many permanent connections are established based on your setup ? I’ve checked and didn’t found any code update related to connection pool, do you think this could be a feature request ?
Regards,
Stéphane
*De : *Henning Westerholt <hw@gilawa.com> *Date : *mercredi, 30 juillet 2025 à 09:07 *À : *Kamailio (SER) - Users Mailing List <sr-users@lists.kamailio.org> *Cc : *Stephane Savonitto <stephane.savonitto@airnity.com> *Objet : *RE: Postgres connections optimization #4342
Vous n’obtenez pas souvent d’e-mail à partir de hw@gilawa.com. Pourquoi c’est important <https://aka.ms/LearnAboutSenderIdentification>
Hello,
have a look to the actual source of the connections (kamailio PID etc..). In many cases a lot of connections are created during startup and then should expire after some time, because they are not used. The only connections that should stay are from the processed processing actual traffic on external interfaces etc. This is at least the behaviour on MySQL.
Cheers,
Henning
*From:* Stephane Savonitto via sr-users <sr-users@lists.kamailio.org> *Sent:* Dienstag, 29. Juli 2025 17:51 *To:* sr-users@lists.kamailio.org *Cc:* Stephane Savonitto <stephane.savonitto@airnity.com> *Subject:* [SR-Users] Postgres connections optimization #4342
Hello,
On P-CSCF when running we have 200+ permanent connection to postgres db, even if there is no traffic. Is there a way to manage connections dynamically using a pool like using PgBouncer ?
Regards,
Stéphane __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions -- sr-users@lists.kamailio.org To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender!
Hello, if you have many udp ipsec tunnels, which use a pair of sockets per end point, then you may want to try with Kamailio 6.0.x and turn on the multi-threaded udp receiving: async_workers_group="name=udp;workers=8" udp_receiver_mode = 1 That should reduce the number of processes created by Kamailio. Cheers, Daniel On 29.07.25 17:51, Stephane Savonitto via sr-users wrote:
Hello,
On P-CSCF when running we have 200+ permanent connection to postgres db, even if there is no traffic. Is there a way to manage connections dynamically using a pool like using PgBouncer ?
Regards,
Stéphane
__________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions -- sr-users@lists.kamailio.org To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender!
-- Daniel-Constantin Mierla (@ asipto.com) twitter.com/miconda -- linkedin.com/in/miconda Kamailio Consultancy, Training and Development Services -- asipto.com
Hi, thanks Daniel, I will give a try. Regards, Stéphane De : Daniel-Constantin Mierla <miconda@gmail.com> Date : mercredi, 30 juillet 2025 à 10:35 À : Kamailio (SER) - Users Mailing List <sr-users@lists.kamailio.org> Cc : Stephane Savonitto <stephane.savonitto@airnity.com> Objet : Re: [SR-Users] Postgres connections optimization #4342 Vous n’obtenez pas souvent d’e-mail à partir de miconda@gmail.com. Pourquoi c’est important<https://aka.ms/LearnAboutSenderIdentification> Hello, if you have many udp ipsec tunnels, which use a pair of sockets per end point, then you may want to try with Kamailio 6.0.x and turn on the multi-threaded udp receiving: async_workers_group="name=udp;workers=8" udp_receiver_mode = 1 That should reduce the number of processes created by Kamailio. Cheers, Daniel On 29.07.25 17:51, Stephane Savonitto via sr-users wrote: Hello, On P-CSCF when running we have 200+ permanent connection to postgres db, even if there is no traffic. Is there a way to manage connections dynamically using a pool like using PgBouncer ? Regards, Stéphane __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions -- sr-users@lists.kamailio.org<mailto:sr-users@lists.kamailio.org> To unsubscribe send an email to sr-users-leave@lists.kamailio.org<mailto:sr-users-leave@lists.kamailio.org> Important: keep the mailing list in the recipients, do not reply only to the sender! -- Daniel-Constantin Mierla (@ asipto.com) twitter.com/miconda -- linkedin.com/in/miconda Kamailio Consultancy, Training and Development Services -- asipto.com
I recently contributed this mode in the sqlops, in cas you are using this module. 2 do not connect until needed (this will limit the amount of idle connections) Default value is 0. On Wed, Jul 30, 2025, 3:02 AM Stephane Savonitto via sr-users < sr-users@lists.kamailio.org> wrote:
Hello,
On P-CSCF when running we have 200+ permanent connection to postgres db, even if there is no traffic. Is there a way to manage connections dynamically using a pool like using PgBouncer ?
Regards,
Stéphane __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions -- sr-users@lists.kamailio.org To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender!
More context https://github.com/kamailio/kamailio/pull/4027 On Wed, Jul 30, 2025 at 8:20 AM Julien Chavanton <jchavanton@gmail.com> wrote:
I recently contributed this mode in the sqlops, in cas you are using this module.
2 do not connect until needed (this will limit the amount of idle connections)
Default value is 0.
On Wed, Jul 30, 2025, 3:02 AM Stephane Savonitto via sr-users < sr-users@lists.kamailio.org> wrote:
Hello,
On P-CSCF when running we have 200+ permanent connection to postgres db, even if there is no traffic. Is there a way to manage connections dynamically using a pool like using PgBouncer ?
Regards,
Stéphane __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions -- sr-users@lists.kamailio.org To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender!
Ok thanks Envoyé de mon iPhone Le 30 juil. 2025 à 15:34, Julien Chavanton <jchavanton@gmail.com> a écrit : Vous n’obtenez pas souvent d’e-mail à partir de jchavanton@gmail.com. Pourquoi c’est important<https://aka.ms/LearnAboutSenderIdentification> More context https://github.com/kamailio/kamailio/pull/4027 On Wed, Jul 30, 2025 at 8:20 AM Julien Chavanton <jchavanton@gmail.com<mailto:jchavanton@gmail.com>> wrote: I recently contributed this mode in the sqlops, in cas you are using this module. 2 do not connect until needed (this will limit the amount of idle connections) Default value is 0. On Wed, Jul 30, 2025, 3:02 AM Stephane Savonitto via sr-users <sr-users@lists.kamailio.org<mailto:sr-users@lists.kamailio.org>> wrote: Hello, On P-CSCF when running we have 200+ permanent connection to postgres db, even if there is no traffic. Is there a way to manage connections dynamically using a pool like using PgBouncer ? Regards, Stéphane __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions -- sr-users@lists.kamailio.org<mailto:sr-users@lists.kamailio.org> To unsubscribe send an email to sr-users-leave@lists.kamailio.org<mailto:sr-users-leave@lists.kamailio.org> Important: keep the mailing list in the recipients, do not reply only to the sender!
Hello, I'm trying to configure kamailio 6.1 to handle "production" traffic but I cannot find setup reference in term of parameters: ipsec, tcp_processes, memory, cpu.. Anyone went through similar questioning has something to share? thanks Stéphane
Hi, I've tried "udp_receiver_mode=1" as explained by Daniel here :https://kamailio.org/mailman3/hyperkitty/list/sr-dev@lists.kamailio.org/thre... Great optimization in term of workers, memory, db connections used. Thanks, Stéphane
participants (6)
-
Daniel-Constantin Mierla -
Giovanni Maruzzelli -
Henning Westerholt -
Julien Chavanton -
Stephane Savonitto -
stephane.savonitto@airnity.com