<div dir="ltr">Hi,<div>having the DB "max connections" ~ 1000 is not unreasonable and I have been doing it since long ago.</div><div>This is also related to the number of nodes running the services. For example in Nova, related to the number of nodes running APIs, conductors, schedulers...</div><div><br></div><div>cheers,</div><div>Belmiro</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Oct 21, 2022 at 5:07 PM Arnaud Morin <<a href="mailto:arnaud.morin@gmail.com">arnaud.morin@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Hey all,<br>
<br>
TLDR: How can I fine tune the number of DB connection on OpenStack<br>
      services?<br>
<br>
<br>
Long story, with some inline questions:<br>
<br>
I am trying to figure out the maximum number of db connection we should<br>
allow on our db cluster.<br>
<br>
For this short speech, I will use neutron RPC as example service, but I<br>
think nova is acting similar.<br>
<br>
So, to do so, I identified few parameters that I can tweak:<br>
rpc_workers [1]<br>
max_pool_size [2]<br>
max_overflow [3]<br>
executor_thread_pool_size [4]<br>
<br>
<br>
rpc_worker default is half CPU threads available (result of nproc)<br>
max_pool_size default is 5<br>
max_overflow default is 50<br>
executor_thread_pool_size is 64<br>
<br>
Now imagine I have a server with 40 cores,<br>
So rpc_worker will be 20.<br>
Each worker will have a DB pool with 5+50 connections available.<br>
Each worker will use up to 64 "green" thread.<br>
<br>
The theorical max connection that I should set on my database is then:<br>
rpc_workers*(max_pool_size+max_overflow) = 20*(5+50) = 1100<br>
<br>
Q1: am I right here?<br>
I have the feeling that this is huge.<br>
<br>
Now, let's assume each thread is consuming 1 connection from the DB pool.<br>
Under heavy load, I am affraid that the 64 threads could exceed the<br>
number of max_pool_size+max_overflow.<br>
<br>
Also, I noticed that some green threads were consuming more than 1<br>
connection from the pool, so I can reach the max even sooner!<br>
<br>
Another thing, I notice that I have 21 RPC workers, not 20. Is it<br>
normal?<br>
<br>
<br>
[1] <a href="https://docs.openstack.org/neutron/latest/configuration/neutron.html#DEFAULT.rpc_workers" rel="noreferrer" target="_blank">https://docs.openstack.org/neutron/latest/configuration/neutron.html#DEFAULT.rpc_workers</a><br>
[2] <a href="https://docs.openstack.org/neutron/latest/configuration/neutron.html#database.max_pool_size" rel="noreferrer" target="_blank">https://docs.openstack.org/neutron/latest/configuration/neutron.html#database.max_pool_size</a><br>
[3] <a href="https://docs.openstack.org/neutron/latest/configuration/neutron.html#database.max_overflow" rel="noreferrer" target="_blank">https://docs.openstack.org/neutron/latest/configuration/neutron.html#database.max_overflow</a><br>
[4] <a href="https://docs.openstack.org/neutron/latest/configuration/neutron.html#DEFAULT.executor_thread_pool_size" rel="noreferrer" target="_blank">https://docs.openstack.org/neutron/latest/configuration/neutron.html#DEFAULT.executor_thread_pool_size</a><br>
<br>
Cheers,<br>
<br>
Arnaud.<br>
<br>
</blockquote></div>