Pergunta

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

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top