3 ms·
> No problem running it completely stateless It's a problem for some use cases, and even in the web use case, reusing connections to databases and services can
by dehrmann 7y ago
> No problem running it completely stateless
It's a problem for some use cases, and even in the web use case, reusing connections to databases and services can be a pain with PHP because it's completely stateless.
- wolco 7y agoPersistent connections are available and if your connection dies the db request will continue next time the page is hit. Although that could cause more slowness issues.
- jawngee 7y ago> reusing connections to databases pgBouncer and ProxySQL are going to give you a better bang for the buck than a stateful web app will.
- dijit 7y agoMaybe. Kinda. Not really. You can have an awful implementation of a connection pooler, sure, but opening an authenticated socket is more expensive by far than just referencing one. Less so for a unix socket/named pipe- but still much slower than a memory lookup. Of course you probably don’t care until you hit a certain scale or number of backend system accesses.
- johannes1234321 7y agoFetching a connection from a (sane) pool isn't just a memory lookup. Database conenctions have to be cleared of state (transactions, temp tables, prepared statement handles, ...) which takes time as well. Otherwise one runs into "funny" bugs at some point in time.
- dehrmann 7y agoUnless they're local (and managing that fleet would get pretty annoying), there's still unnecessarily TCP overhead, and even the possibility of exhausting ports. I'm not arguing for a truly stateful webapp, but the connecting pooling you get for free (or some library wrangling) with a long-lived process does a lot for performance and scalability.