Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started



ted_176239 avatar image
ted_176239 asked ted_176239 edited

Why do connections with PHP driver rise from 5K to 12K, drop then spike again?

Hi all,

Wondering if anyone can shed some light on the methodology for establishing connections with the PHP driver.

We have a few servers and for some reason they all seem open new connections at the same time. It will drop to around 5k connections, rise to 10k-12k and then slowly drop, until it is time to spike again.

Problem is these connections and associated queries are causing major latency for actual requests. And also when it is connecting, there is a query for some metadata that is large, which is requested for each connection?

Any ideas?



10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Fero avatar image
Fero answered ted_176239 edited


There are a couple ways to mitigate this issue until we are able to implement a more long-term solution. To do so you can disable the some of the expensive startup procedures and use the whitelist policy to target a smaller set of nodes in the cluster.

$cluster = Cassandra::cluster()
  ->withTokenAwareRouting(false) # This may dramatically reduce your startup time.
  ->withWhiteListHosts(...) # Use a single or small number of hosts
$session = $cluster->connect();

Note: $session->schema() will always return an empty object.

One long-term solution that could be implemented would be a shared memory bridge to the persistent sessions. By having a single process managed by the php-driver extension where persistent sessions would be cahced and utilize IPC to communicate with that manage process. This would solve the following problems:

  1. Decouples the number of Cassandra connections created from the number of child processes.
  2. Persistent sessions (which are enabled by default) are connected once regardless of the number of child processes.


Michael Fero

1 comment Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.


Thank you for the detailed answer, I will give that a try.

The issue seemed to get worse when we upgraded from Scylla 2.3 to 3.0. We are using the latest PHP driver available (1.3.2) from 2017, which I believe uses CPP-Driver 2.7.

I see an open Pull Request from 7 days ago that looks to switch to CPP 2.13, so hopefully that goes somewhere.

Thanks again,


0 Likes 0 ·