1

I'm managing a site which, despite our best efforts, creates upwards of 10,000 session files. We've configured the gc and it has helped to control somehow the growth of files, but we still have "a lot" of these files at peak hours.

Are 10,000+ too much session files? File size is not an issue, just wondering how many files are "too much" compared to your experiences.

Jaime G. Wong
  • 13
  • 1
  • 3
  • Have you looked at storing in a database, or memory? – Zoredache Feb 04 '13 at 19:10
  • 2
    First step is to identify if it's really an issue or these many files are above average; then look at other storage options. – Jaime G. Wong Feb 04 '13 at 19:59
  • Meh, I generally prefer database storage as a rule, since it makes it easier for me to setup DR, and it is pretty easy to implement. But you are right, it is good to be cautious, and only make changes if you actually need them. – Zoredache Feb 04 '13 at 20:53

2 Answers2

3

"Too many" session files? Well, you're gonna need one per session. So however many sessions you're willing to maintain, that's how many session files you're going to end up with. You can tweak how long the files persist via gc, as you've done, but short of reducing the number of clients (presumably not your goal), nothing's going to reduce the absolute number of files created.

That said, 10,000 files is not a shockingly large number for any reasonably modern filesystem.

Jeff Albert
  • 1,967
  • 9
  • 14
1

Generally speaking you won't hit a problem unless the OS is 32-bit and you have billions of files. If you're concerned about file limits, make sure to use a file system designed for absurdly huge numbers of files. XFS comes to mind for this purpose. You can create a new volume, format it as XFS, and mount it wherever your PHP application writes its session files. This requires no modification of the application itself.

Joel E Salas
  • 5,562
  • 15
  • 25