That's strange, here is another similar post.
Laravel file based sessions - move to Redis or prune outside requests?
Hello!
We currently use file based sessions in our Laravel app. We have default configuration; life time is 14 days and the lottery is 2%. We have roughly 750.000 files in sessions directory.
I troubleshoot some slow requests and found out that StartSession middleware could take up to 7 seconds. After simulating the code where garbage control happens and deletes all older session files, that could take 7 seconds.
Two options I see could help me improve the performance for these slow requests;
-
Move pruning outside the requests Basically, change session config ('lottery' => [0, 100]) so that the built in pruning never takes place and instead have a bash script or Laravel command to delete older sessions in the background.
-
Move sessions to Redis Instead of file based sessions, completely move to Redis.
What are your thoughts? Do you use Redis or file sessions (or anything else)?
Please or to participate in this conversation.