Disk inodes full due to PHP sessions [closed]

From a systems perspective, on real hardware, the solution is to create a new file system with a different inode_ratio or even a new FS type that is designed around massive amounts of small files. Your hosting provider may or may not provide this functionality if your are cloud based vs. colocated HW or "dedicated" VPSes. SEE EDIT BELOW

If you can change the code to the shopping system, you should store carts for logged in users in a database, and let the session expire as normal and have the old session files cleaned up. Sessions should have relatively short lives, and session files should be cleaned up/deleted for old inactive sessions on a regular basis.

Storing info in the DB has lots of advantages - both technological (easier to split webserver load across a CDN) and business purposes ("hey, you've had this item in your wish list for a while and it is almost out of stock - buy now!" emails have gotten me to open my wallet more than once) and this is the direction I would head. But at the very least start deleting old expired session files....

Edit to add -

One hacky way of getting a new FS would be to create a sparse file of appropriate size, format it with the file system of choice, and mount it on a loop back setup. Of course, you'll need sufficient space, etc. to do this....


Zebra Session acts as a wrapper for PHP's default session handling functions, but instead of storing session data in flat files it stores them in a MySQL database, providing better security and better performance

it is a drop-in and seamingless replacement for PHP's default session handler: PHP sessions will be used in the same way as prior to using the library; you don't need to change any existing code!

https://github.com/stefangabos/Zebra_Session

Exactly what I was looking for.

Another solution: https://stackoverflow.com/questions/36753513/how-do-i-save-php-session-data-to-a-database-instead-of-in-the-file-system