Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between session in file and in database [closed]

What is the difference between storing sessions in file and in database?

like image 715
hd. Avatar asked Apr 22 '12 04:04

hd.


1 Answers

The primary difference is that fetching the session info from a database can be quite a bit faster than from a file system. This is partly because of DB caching, but also because if there are large numbers of sessions files the file system may not cope well with it. Most file systems start to degrade when there are a few thousand files in a single directory, whereas DBs don't run into this problem.

Other reasons include fine-grained security, replication, and/or sharding, all of which are meat and potatoes to DBMSes, but not to filesystems.

If you only have a few sessions it doesn't matter, but when there 10,000 or 10,000,000 sessions it definitely does.

like image 162
Peter Rowell Avatar answered Nov 10 '22 09:11

Peter Rowell