Repository navigation
[5.x] Add redisPersistentConnection setting to reuse the Redis connection per PHP process - #371
Merged
snake14 merged 1 commit intoNov 16, 2026
Conversation
…er PHP process (matomo-org#369) * Add redisPersistentConnection setting to reuse the Redis connection per PHP process Every tracking request opened a new connection to Redis (Queue\Backend\Redis::connect). With the setting on, the standalone Redis backend uses pconnect, with one persistent id per database so a client sharing the connection cannot select() another database. Off by default; configurable in config.ini.php only, like redisTimeout. Closes matomo-org#55 Co-Authored-By: Claude Opus 5.5 <[email protected]> * Bump to 6.0.5 and assert the persistent connection id in tests The Factory and database-separation tests passed without the feature. They now check getPersistentID(), so they fail if the setting is not wired or the database is missing from the id. Co-Authored-By: Claude Fable 5.2 <[email protected]> * Address review: drop the restart caveat, test database separation without pooling phpredis reconnects a dropped persistent connection by itself, so the FAQ caveat about a failed first request after a Redis restart did not hold. With connection pooling on, two clients never share a socket, so the separation test passed even with a constant persistent id; it now runs with pooling off. queuedtracking:test marks the setting as standalone Redis only. Co-Authored-By: Claude Fable 5.2 <[email protected]> --------- Co-authored-by: Eric Cobos <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> (cherry picked from commit 8e5dc00)
snake14
approved these changes
Nov 16, 2026
snake14
left a comment
Contributor
There was a problem hiding this comment.
Thank you for the PR @psykologist90! The changes work as described for Matomo 5. 👍
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Backport of #369 to
5.x-dev, as offered there. It is a cherry-pick of 8e5dc00; the only differences are the version (5.2.3) and the changelog entry.Adds an opt-in
redisPersistentConnectionsetting. When it is on, the standalone Redis backend connects with phpredispconnect()instead ofconnect(), so each PHP-FPM worker keeps one connection open instead of opening a new one on every tracking request.redisPersistentConnection(bool, defaultfalse). LikeredisTimeout, it is not exposed in the UI and is set inconfig.ini.php:Factorywires it up for the standalone backend only. Sentinel and Cluster are unchanged.queuedtracking-<database>, so a client sharing the connection cannotselect()another database. This matters whenredis.pconnect.pooling_enabledis off; with pooling on (the default) two live clients never share a socket.queuedtracking:testprints the setting asPersistentConnection (standalone Redis only). FAQ entry and changelog added.Trade-off (also in the FAQ): Redis sees up to
pm.max_childrenconnections per web server.Issue No
Related to #55 (closed by #369 on
6.x-dev)Steps to Replicate the Issue
INFO statstotal_connections_receivedgrows by N.Checklist
5.x-devon PHP 8.4, MySQL 8.0, Redis 7 + Sentinel: 310 tests, no failures, one intended Sentinel skip; phpcs clean; changed files lint on PHP 7.2)SettingsTest,FactoryTest,RedisTest)5.2.3inplugin.jsonand the changelog)🤖 Generated with Claude Code