<div dir="ltr">some modules can have child processes that each maintain a database connection. the number of child processes for a module can sometimes be set using a modparam() for that module</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 10, 2017 at 4:23 PM, Alex Balashov <span dir="ltr"><<a href="mailto:abalashov@evaristesys.com" target="_blank">abalashov@evaristesys.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
By way of illustration, I have one server with children=8, a single UDP<br>
listener, and 23 processes total:<br>
<br>
--<br>
21117 attendant<br>
21118 udp receiver child=0 sock=xxx.xxx.xxx.xxx:5060<br>
21119 udp receiver child=1 sock=xxx.xxx.xxx.xxx:5060<br>
21120 udp receiver child=2 sock=xxx.xxx.xxx.xxx:5060<br>
21121 udp receiver child=3 sock=xxx.xxx.xxx.xxx:5060<br>
21122 udp receiver child=4 sock=xxx.xxx.xxx.xxx:5060<br>
21123 udp receiver child=5 sock=xxx.xxx.xxx.xxx:5060<br>
21124 udp receiver child=6 sock=xxx.xxx.xxx.xxx:5060<br>
21125 udp receiver child=7 sock=xxx.xxx.xxx.xxx:5060<br>
21126 slow timer<br>
21127 timer<br>
21128 MI FIFO<br>
21129 ctl handler<br>
21130 RTIMER USEC EXEC<br>
21131 RTIMER USEC EXEC<br>
21132 RTIMER USEC EXEC<br>
21133 RTIMER USEC EXEC<br>
21134 RTIMER USEC EXEC<br>
21135 RTIMER USEC EXEC<br>
21136 RTIMER USEC EXEC<br>
21137 Dialog KA Timer<br>
21138 Dialog Clean Timer<br>
21139 tcp main process<br>
<br>
# kamcmd -s /tmp/kamailio_ctl ps | wc -l<br>
23<br>
--<br>
<br>
This appears to result in 23 total database connections to the Postgres<br>
server:<br>
<br>
--<br>
# lsof -n | grep -i '^kam' | grep IPv4 | grep TCP | grep -i :postgres | wc -l<br>
23<br>
--<br>
<br>
But I have another Kamailio server that has three listeners, two UDP and<br>
one TCP, and children=24, i.e.<br>
<br>
--<br>
children=24<br>
listen=udp:xxx.xxx.xxx.xxx:<wbr>5060<br>
listen=udp:yyy.yyy.yyy.yyy:<wbr>5060<br>
listen=tcp:zzz.zzz.zzz.zzz:<wbr>5060<br>
--<br>
<br>
I am given to understand that the total number of worker processes there<br>
will be (children_setting * listeners), i.e. 72 in this case, plus some<br>
number of rtimer and supervisory processes, as in my case. And true<br>
enough:<br>
<br>
--<br>
# kamcmd -s /tmp/kamailio_ctl ps | wc -l<br>
86<br>
# kamcmd -s /tmp/kamailio_ctl ps | sed 's/<a href="http://65.254.44.195/yyy.yyy.yyy.yyy/g" rel="noreferrer" target="_blank">65.254.44.195/yyy.yyy.yyy.<wbr>yyy/g</a>' | sed 's/<a href="http://65.254.44.194/zzz.zzz.zzz.zzz/g" rel="noreferrer" target="_blank">65.254.44.194/zzz.zzz.zzz.<wbr>zzz/g</a>'<br>
22065 main process - attendant<br>
22069 udp receiver child=0 sock=zzz.zzz.zzz.zzz:5060<br>
22070 udp receiver child=1 sock=zzz.zzz.zzz.zzz:5060<br>
22071 udp receiver child=2 sock=zzz.zzz.zzz.zzz:5060<br>
22073 udp receiver child=3 sock=zzz.zzz.zzz.zzz:5060<br>
22074 udp receiver child=4 sock=zzz.zzz.zzz.zzz:5060<br>
22076 udp receiver child=5 sock=zzz.zzz.zzz.zzz:5060<br>
22079 udp receiver child=6 sock=zzz.zzz.zzz.zzz:5060<br>
22080 udp receiver child=7 sock=zzz.zzz.zzz.zzz:5060<br>
22082 udp receiver child=8 sock=zzz.zzz.zzz.zzz:5060<br>
22085 udp receiver child=9 sock=zzz.zzz.zzz.zzz:5060<br>
22086 udp receiver child=10 sock=zzz.zzz.zzz.zzz:5060<br>
22089 udp receiver child=11 sock=zzz.zzz.zzz.zzz:5060<br>
22091 udp receiver child=12 sock=zzz.zzz.zzz.zzz:5060<br>
22093 udp receiver child=13 sock=zzz.zzz.zzz.zzz:5060<br>
22095 udp receiver child=14 sock=zzz.zzz.zzz.zzz:5060<br>
22097 udp receiver child=15 sock=zzz.zzz.zzz.zzz:5060<br>
22099 udp receiver child=16 sock=zzz.zzz.zzz.zzz:5060<br>
22100 udp receiver child=17 sock=zzz.zzz.zzz.zzz:5060<br>
22103 udp receiver child=18 sock=zzz.zzz.zzz.zzz:5060<br>
22105 udp receiver child=19 sock=zzz.zzz.zzz.zzz:5060<br>
22107 udp receiver child=20 sock=zzz.zzz.zzz.zzz:5060<br>
22109 udp receiver child=21 sock=zzz.zzz.zzz.zzz:5060<br>
22111 udp receiver child=22 sock=zzz.zzz.zzz.zzz:5060<br>
22113 udp receiver child=23 sock=zzz.zzz.zzz.zzz:5060<br>
22115 udp receiver child=0 sock=yyy.yyy.yyy.yyy:5060<br>
22117 udp receiver child=1 sock=yyy.yyy.yyy.yyy:5060<br>
22119 udp receiver child=2 sock=yyy.yyy.yyy.yyy:5060<br>
22121 udp receiver child=3 sock=yyy.yyy.yyy.yyy:5060<br>
22123 udp receiver child=4 sock=yyy.yyy.yyy.yyy:5060<br>
22125 udp receiver child=5 sock=yyy.yyy.yyy.yyy:5060<br>
22127 udp receiver child=6 sock=yyy.yyy.yyy.yyy:5060<br>
22129 udp receiver child=7 sock=yyy.yyy.yyy.yyy:5060<br>
22131 udp receiver child=8 sock=yyy.yyy.yyy.yyy:5060<br>
22132 udp receiver child=9 sock=yyy.yyy.yyy.yyy:5060<br>
22135 udp receiver child=10 sock=yyy.yyy.yyy.yyy:5060<br>
22137 udp receiver child=11 sock=yyy.yyy.yyy.yyy:5060<br>
22139 udp receiver child=12 sock=yyy.yyy.yyy.yyy:5060<br>
22141 udp receiver child=13 sock=yyy.yyy.yyy.yyy:5060<br>
22143 udp receiver child=14 sock=yyy.yyy.yyy.yyy:5060<br>
22145 udp receiver child=15 sock=yyy.yyy.yyy.yyy:5060<br>
22147 udp receiver child=16 sock=yyy.yyy.yyy.yyy:5060<br>
22149 udp receiver child=17 sock=yyy.yyy.yyy.yyy:5060<br>
22151 udp receiver child=18 sock=yyy.yyy.yyy.yyy:5060<br>
22153 udp receiver child=19 sock=yyy.yyy.yyy.yyy:5060<br>
22155 udp receiver child=20 sock=yyy.yyy.yyy.yyy:5060<br>
22156 udp receiver child=21 sock=yyy.yyy.yyy.yyy:5060<br>
22159 udp receiver child=22 sock=yyy.yyy.yyy.yyy:5060<br>
22161 udp receiver child=23 sock=yyy.yyy.yyy.yyy:5060<br>
22163 slow timer<br>
22165 timer<br>
22167 secondary timer<br>
22168 ctl handler<br>
22169 RTIMER USEC EXEC<br>
22170 RTIMER USEC EXEC<br>
22172 RTIMER USEC EXEC<br>
22173 RTIMER USEC EXEC<br>
22175 Dialog Clean Timer<br>
22176 TIMER NH<br>
22177 TIMER NH<br>
22178 TIMER NH<br>
22179 tcp receiver (generic) child=0<br>
22180 tcp receiver (generic) child=1<br>
22182 tcp receiver (generic) child=2<br>
22184 tcp receiver (generic) child=3<br>
22186 tcp receiver (generic) child=4<br>
22188 tcp receiver (generic) child=5<br>
22190 tcp receiver (generic) child=6<br>
22192 tcp receiver (generic) child=7<br>
22194 tcp receiver (generic) child=8<br>
22196 tcp receiver (generic) child=9<br>
22198 tcp receiver (generic) child=10<br>
22200 tcp receiver (generic) child=11<br>
22202 tcp receiver (generic) child=12<br>
22204 tcp receiver (generic) child=13<br>
22206 tcp receiver (generic) child=14<br>
22208 tcp receiver (generic) child=15<br>
22210 tcp receiver (generic) child=16<br>
22212 tcp receiver (generic) child=17<br>
22214 tcp receiver (generic) child=18<br>
22216 tcp receiver (generic) child=19<br>
22218 tcp receiver (generic) child=20<br>
22220 tcp receiver (generic) child=21<br>
22223 tcp receiver (generic) child=22<br>
22225 tcp receiver (generic) child=23<br>
22227 tcp main process<br>
--<br>
<br>
But, for some reason, the number of database connections to Postgres<br>
seems to be considerably higher than the number of total processes:<br>
<br>
--<br>
# lsof -n | grep '^kam' | grep TCP | grep IPv4 | grep ':postgres' | wc -l<br>
114<br>
--<br>
<br>
This is not due to orphaned/unterminated Kamailio processes. There's<br>
only one process lineage:<br>
<br>
--<br>
|-kamailio(22065)-+-kamailio(<wbr>22069)<br>
| |-kamailio(22070)<br>
| |-kamailio(22071)<br>
| |-kamailio(22073)<br>
| |-kamailio(22074)<br>
| |-kamailio(22076)<br>
| |-kamailio(22079)<br>
| |-kamailio(22080)<br>
| |-kamailio(22082)<br>
| |-kamailio(22085)<br>
| |-kamailio(22086)<br>
| |-kamailio(22089)<br>
| |-kamailio(22091)<br>
| |-kamailio(22093)<br>
| |-kamailio(22095)<br>
| |-kamailio(22097)<br>
| |-kamailio(22099)<br>
| |-kamailio(22100)<br>
| |-kamailio(22103)<br>
| |-kamailio(22105)<br>
| |-kamailio(22107)<br>
| |-kamailio(22109)<br>
| |-kamailio(22111)<br>
| |-kamailio(22113)<br>
| |-kamailio(22115)<br>
| |-kamailio(22117)<br>
| |-kamailio(22119)<br>
| |-kamailio(22121)<br>
| |-kamailio(22123)<br>
| |-kamailio(22125)<br>
| |-kamailio(22127)<br>
| |-kamailio(22129)<br>
| |-kamailio(22131)<br>
| |-kamailio(22132)<br>
| |-kamailio(22135)<br>
| |-kamailio(22137)<br>
| |-kamailio(22139)<br>
| |-kamailio(22141)<br>
| |-kamailio(22143)<br>
| |-kamailio(22145)<br>
| |-kamailio(22147)<br>
| |-kamailio(22149)<br>
| |-kamailio(22151)<br>
| |-kamailio(22153)<br>
| |-kamailio(22155)<br>
| |-kamailio(22156)<br>
| |-kamailio(22159)<br>
| |-kamailio(22161)<br>
| |-kamailio(22163)<br>
| |-kamailio(22165)<br>
| |-kamailio(22167)<br>
| |-kamailio(22168)<br>
| |-kamailio(22169)<br>
| |-kamailio(22170)<br>
| |-kamailio(22172)<br>
| |-kamailio(22173)<br>
| |-kamailio(22175)<br>
| |-kamailio(22176)<br>
| |-kamailio(22177)<br>
| |-kamailio(22178)<br>
| |-kamailio(22179)<br>
| |-kamailio(22180)<br>
| |-kamailio(22182)<br>
| |-kamailio(22184)<br>
| |-kamailio(22186)<br>
| |-kamailio(22188)<br>
| |-kamailio(22190)<br>
| |-kamailio(22192)<br>
| |-kamailio(22194)<br>
| |-kamailio(22196)<br>
| |-kamailio(22198)<br>
| |-kamailio(22200)<br>
| |-kamailio(22202)<br>
| |-kamailio(22204)<br>
| |-kamailio(22206)<br>
| |-kamailio(22208)<br>
| |-kamailio(22210)<br>
| |-kamailio(22212)<br>
| |-kamailio(22214)<br>
| |-kamailio(22216)<br>
| |-kamailio(22218)<br>
| |-kamailio(22220)<br>
| |-kamailio(22223)<br>
| |-kamailio(22225)<br>
| `-kamailio(22227)<br>
--<br>
<br>
Yet, for some reason, some of the processes have two established DB<br>
connections from different ports:<br>
<br>
--<br>
kamailio 22220 root 3u IPv4 189895303 0t0 TCP 127.0.0.1:46550->127.0.0.1:pos<wbr>tgres (ESTABLISHED)<br>
kamailio 22220 root 86u IPv4 189895067 0t0 TCP 127.0.0.1:46458->127.0.0.1:pos<wbr>tgres (ESTABLISHED)<br>
kamailio 22223 root 3u IPv4 189895315 0t0 TCP 127.0.0.1:46556->127.0.0.1:pos<wbr>tgres (ESTABLISHED)<br>
kamailio 22223 root 86u IPv4 189895067 0t0 TCP 127.0.0.1:46458->127.0.0.1:pos<wbr>tgres (ESTABLISHED)<br>
kamailio 22225 root 3u IPv4 189895321 0t0 TCP 127.0.0.1:46560->127.0.0.1:pos<wbr>tgres (ESTABLISHED)<br>
kamailio 22225 root 86u IPv4 189895067 0t0 TCP 127.0.0.1:46458->127.0.0.1:pos<wbr>tgres (ESTABLISHED)<br>
kamailio 22227 root 86u IPv4 189895067 0t0 TCP 127.0.0.1:46458->127.0.0.1:pos<wbr>tgres (ESTABLISHED)<br>
--<br>
<br>
... while others don't ...<br>
<br>
--<br>
kamailio 22111 root 3u IPv4 189894820 0t0 TCP 127.0.0.1:46326->127.0.0.1:pos<wbr>tgres (ESTABLISHED)<br>
kamailio 22113 root 3u IPv4 189894828 0t0 TCP 127.0.0.1:46332->127.0.0.1:pos<wbr>tgres (ESTABLISHED)<br>
kamailio 22115 root 3u IPv4 189894834 0t0 TCP 127.0.0.1:46334->127.0.0.1:pos<wbr>tgres (ESTABLISHED)<br>
kamailio 22117 root 3u IPv4 189894842 0t0 TCP 127.0.0.1:46338->127.0.0.1:pos<wbr>tgres (ESTABLISHED)<br>
kamailio 22119 root 3u IPv4 189894848 0t0 TCP 127.0.0.1:46340->127.0.0.1:pos<wbr>tgres (ESTABLISHED)<br>
--<br>
<br>
So, this gives rise to two questions in my mind:<br>
<br>
1. I don't seem to understand the relationship between the number of<br>
database connection handles and the total number of child processes.<br>
<br>
I had always assumed that only SIP workers and other processes<br>
specialised into a role with possible "database involvement" (e.g.<br>
rtimer, async workers, etc.) would hold database connections.<br>
<br>
2. What's going on in the second scenario such that some processes have<br>
two connections?<br>
<br>
Both servers running:<br>
<br>
--<br>
# kamcmd -s /tmp/kamailio_ctl core.version<br>
kamailio 4.4.6 (x86_64/linux) becbde<br>
--<br>
<br>
Insights much appreciated!<br>
<span class="HOEnZb"><font color="#888888"><br>
-- Alex<br>
<br>
--<br>
Alex Balashov | Principal | Evariste Systems LLC<br>
<br>
Tel: <a href="tel:%2B1-706-510-6800" value="+17065106800">+1-706-510-6800</a> / <a href="tel:%2B1-800-250-5920" value="+18002505920">+1-800-250-5920</a> (toll-free)<br>
Web: <a href="http://www.evaristesys.com/" rel="noreferrer" target="_blank">http://www.evaristesys.com/</a>, <a href="http://www.csrpswitch.com/" rel="noreferrer" target="_blank">http://www.csrpswitch.com/</a><br>
<br>
______________________________<wbr>_________________<br>
Kamailio (SER) - Users Mailing List<br>
<a href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a><br>
<a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">https://lists.kamailio.org/<wbr>cgi-bin/mailman/listinfo/sr-<wbr>users</a><br>
</font></span></blockquote></div><br></div>