Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Redis session handler and/or better: Let plugins define session handlers #6800

Closed
tsteur opened this issue Dec 3, 2014 · 6 comments
Closed
Labels
c: Performance For when we could improve the performance / speed of Matomo. c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.
Milestone

Comments

@tsteur
Copy link
Member

tsteur commented Dec 3, 2014

I think it makes sense to offer the possibility to use Redis to manage sessions as mentioned in #6637 and later by another user in #6075. Redis is just perfect for storing sessions when using multiple frontend nodes as an alternative to database. All operations are performed in memory making reads and writes blazing fast.

It is very easy to configure in case the Redis extension phpredis is installed which is required for Queued Tracking #6075 anyway.

session.save_handler = redis 
session.save_path    = tcp://127.0.0.1:6379  // I think multiple servers can be configured comma separated
@tsteur tsteur added Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. c: Performance For when we could improve the performance / speed of Matomo. c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. labels Dec 3, 2014
@tsteur
Copy link
Member Author

tsteur commented Dec 4, 2014

I noticed this is already possible to do by setting the following save_handler in config.ini.php

[General]
session_save_handler = ""

and in php.ini configure the save_handler manually as mentioned above eg.

[Session]
session.save_handler = redis
session.save_path = tcp://127.0.0.1:6379

How could we better promote this for "clusters" (using multiple front nodes)? I also worked for 15 min on a plugin and it would be easily doable to write a simple plugin for this as well. Would be maybe the best / easiest way to promote this kind of session handler to show how other people could add their own session handlers?

@mattab
Copy link
Member

mattab commented Dec 7, 2014

For most people the database session handler is enough I think. I guess redis session handler will be most useful for power users like InnoCraft who use redis also for the tracker API via https://github.com/piwik/plugin-QueuedTracking

Therefore maybe it'd be enough to document it in a new FAQ similar to that one.. and link it from there, and from this one. thoughts?

@trucleavinetworks
Copy link

Hi, I didn't mean that we use Redis for frontend admin session.
My idea is when tracker records the log file into database, tracker query the database to get session data from log_visit and log_link_visit_action table.
With redis, we could use expire functionality. But it just set by TTL, with bulk import the time that we actually record might be delayed for hours. So that I used sorted set and periodically expire old sesion data.
This is about how to use redis to increase the performance (reduce database track loading).

@mattab
Copy link
Member

mattab commented Dec 8, 2014

@trucleavinetworks you make a good point, maybe we could use Redis to cache the visitors in the last window_look_back_for_visitor and this could bring performance to the importing process. but i'm not sure if there is big need for this change (because it's quite complex one and maybe there are other improvements we could make?)

@tsteur
Copy link
Member Author

tsteur commented Dec 9, 2014

It should be at least recommended in an article where it is described how to setup "Piwik with multiple front nodes" and in case there is an article "Piwik high performance" as it is good to use it even when not using QueuedTracking. Should be also mentioned as you said where "setup alternative to file sessions".

I'd have a plugin here that I developed quickly as mentioned and it works. Only problem that I didn't solve was to restore the original session handler again in case someone wants to disable the plugin again. But do not plan to release it for now. Waiting for #6609 . Otherwise if someone enters a wrong save path in "Plugin Settings" it would be no longer able to access Piwik I think. In case someone is interested in the code ping me.

@mattab mattab added this to the Short term milestone Dec 9, 2014
@mattab mattab modified the milestones: Piwik 2.14.0, Short term, Mid term Apr 7, 2015
@mattab
Copy link
Member

mattab commented Apr 25, 2015

this new features will be documented as a FAQ in #7767

@mattab mattab closed this as completed Apr 25, 2015
@mattab mattab modified the milestones: Piwik 2.13.0, Mid term Apr 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Performance For when we could improve the performance / speed of Matomo. c: Platform For Matomo platform changes that aren't impacting any of our APIs but improve the core itself. Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.
Projects
None yet
Development

No branches or pull requests

3 participants