Skip to content

Persistent Sessions aren't cleaned up or reused properly #110

@K-Leon

Description

@K-Leon

I've noticed an issue when enabling persistent sessions using withPersistentSessions(true) in conjunction with PHP-FPM. Specifically, there seems to be a constant growth in the number of connections to the database server.

We are talking about thousands of connections.
(The usable outgoing Ports on the application Server are getting saturaded). We're talking about quiet a bit of load and strong Application Servers. Practically this means that a server is out of ports in about 1-5 Minutes.

It appears that connections are not being cleaned up or closed properly, leading to this buildup over time. If check it in phpinfo persistent connection count is always 1.

I couldn't pinpoint it yet, but disabling persistent sessions didn't resulted in higher latency which leads me to think that it doesn't reuse the connection properly.

(The wrapper is a bit more complex, but this is the gist of it)

$client = new Cassandra()::cluster()
            ->withContactPoints(implode(',', config('scylla.hosts')))
            ->withRandomizedContactPoints(true)
            ->withPersistentSessions(false) // Setting to false helps obviously. => true we see this issue
            ->build();
$session = $client->connect(config('scylla.keyspace'));
///---- Some Stuff getting executed ---- //
$session?->close(); (Added in conjunction with disabling persistent sessions)

I want to thank also everyone for their hard work on this project—it's incredible helpful!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions