Reducing Database Connections


I have a big flow with 17 "functional flow lines" that do the same but with different payloads.
One part of that is working on a Database. Reading here, writing there and so on.
The Flow is updated everty 1.2 seconds and my Connection Count on the database sums up.

Is there a way to acess one "node-red-node-mysql" from multiple flow positions with different payloads and orders?
atm i use 2 SQL nodes per line, thats 34 Connections only from that part. It is a Company DB and that is to much. I have to leave Connections to other colleagues.

Friday i reached the max Connection Count for that db. :frowning:


As usual - it all depends...
You should be able to use as many nodes as you like as long as they share the same connection - IE there is only one server configured. As that should give you just one connection to the database that all the nodes then share.

I think i have to disagree…
I have set up a Connection Counter and if i bring in another DB-Node the Connection Count goes up by 1.
I will do one more test but i think it doesnt work that way ...

That's correct.

Even if you have only one config node, the underlying implementation uses a connection pool with a hard-coded size of 25. Those connections are shared between all mysql nodes. Though it shouldn't exceed those 25 connections, if you have exactly one config node.

I have done some more research and got some new informations:

I have over 90 processes on the DB wich are in "sleep" state. Strange Thing they stay for up to 6 Hours.
So in the night, when nobody works on my flow, starts a bunch of new connections and stayed as process.

I update every 1.2 seconds on the DB. If i would start a new connection with every intervall i would flood the DB. but that dont happened.

As i understand the last replay every SQL-node makes up to 25 connections(processes) possible?
May i cut that down to 1 myself? Its easier for me to use more SQL-nodes. if i could reduce the connection Limit per node , that would be a solution.

And i have to find a way to get those sleeping SQL process id's and to kill them.

Every mysql config node holds 25 connections, not every mysql node in your flows. There should be only one config node (see screenshot in Dave's post) that is shared among the mysql nodes in your flows.

Are you using multiple config nodes at the moment? You can see them in the "configuration nodes" sidebar.

i use the "node-red-node-mysql" node . In "configuration nodes" i see the node , and the info "8 nodes use that configuration"
But i only have 3 of that nodes in my flow ?

But i would like to use more of them. The only other way i see, is bringing the data as global and connect central do the SQL-node. but thats a liitle bit complicated, because i need the requested values in different places in my flow :frowning:

My Solution was working with global variables and cutting down the SQL-Node amount . More Work but works..

Thank You!

1 Like

So i am back again.

I am down to 4 SQL Nodes but my flow creates still around 120 Connections.

Is there a way to reduce the Connection Limit?
I dont know why, but it seems that opened Connections are not been closed…


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.