this post was submitted on 13 Jun 2023
21 points (95.7% liked)

PHP

547 readers
1 users here now

Welcome to /c/php! This is a community for PHP developers and enthusiasts to share and discuss anything related to PHP. From the latest updates and tutorials, to your burning questions and amazing personal projects, we welcome all contributions.

Let's foster an environment of respect, learning, and mutual growth. Whether you're an experienced PHP developer, a beginner, or just interested in learning more about PHP, we're glad to have you here!

Let's code, learn, and grow together!

founded 1 year ago
MODERATORS
 

Hey! ๐Ÿ‘‹

Whether you're an experienced PHP developer, a beginner just starting your journey, or an enthusiast interested in understanding more about the world of PHP, this is the place for you. We are a community dedicated to sharing knowledge, discussing new trends, and solving problems related to PHP.

As members of this community, we expect everyone to respect each other and foster a positive environment. Please make sure your posts are relevant to PHP, and remember to be kind and considerate in your discussions. Let's learn from each other and help each other grow.

Whether you're here to ask questions or to share your knowledge, we're excited to have you here. Let's make the most of this community together!

Welcome to /c/php! ๐Ÿ˜

you are viewing a single comment's thread
view the rest of the comments
[โ€“] msage 1 points 1 year ago (1 children)

Single process doesn't save any queries, no idea what you mean.

Persistent connections persist between requests just like in a single process. It's just that pool handling is hidden in PDO.

[โ€“] [email protected] 1 points 1 year ago (1 children)

Also how's the setup? You setup for example 5 max children in fpm and 5 persistent connections? Per server? So your overall connections to the db server will be 5x your server instances?

If you setup 5 fpm children and less connections, one child will eventually reuse from another, but only when the connection is free (does not do a query for another process or pdo does not consume a resultset). If it tries to do a query at that time it will have to wait and it will block. This is my understanding. Also how you do transactions with persistent connections?

This has evolved into such an interesting conversation.

[โ€“] msage 2 points 1 year ago

From my current understanding, there is no pool, just one process keeps and reuses one database handle over and over again.

And it's not PDO, but the driver, which handles that.

Transactions are handled within try/finally blocks. You can reset the DB connection, but it's not free in terms of time. You get more performance making sure code doesn't leak open transactions.