I have a pertinent question regarding the connections in my database.
I was told that with each new connection to MySQL a portion of the RAM is reserved for this connection. I have several applications developed in PHP that connect in the same database. My question is: how do bank connections work in PHP and if there is a way to optimize them.
As far as I know, every time the PHP script runs, it opens a connection to the database, and that connection usually lasts until the script is finished. Following this reasoning, if the same script is executed 10 times by different clients or not at the same time, even for milliseconds, we will have 10 different connections with the bank. Am I right!? Is this really what happens in practice?
If the above reasoning is correct and new connections to the database are opened whenever my PHP script is executed, then a portion of the RAM is allocated dynamically for each execution of the script, correct? Is there any way to optimize database connections to reuse open connections? If possible, open a single connection where the script will communicate with the bank as many times as necessary. Is this possible?
Thanks in advance for any help. ;)