i would like to ask if is ok to save authorization token as a file in the specific folder. Or will be faster with every request connect to database and compare with token save in the table ? Thanks for answer
Asked
Active
Viewed 1,228 times
0
-
The performance impact of establishing a connection to the database is minimal if that's what you are asking about. – Reed Jan 08 '18 at 21:02
1 Answers
1
From the "what's faster" standpoint...
Accessing, writing and reading files on the hard disk has its overhead and bears - compared to accessing memory - some performance loss. Databases (again, typically) also store their data on the hard disk, but also often keep data loaded in memory. That's because accessing memory is much faster than accessing files on a hard drive.
So, if you're asking...
What's faster?
The answer would be (most of the times): Database.
And does it really matter?
Depends on your application.
- If you're having five requests per second reading your access tokens, then: no, it doesn't matter, and storing them on the disk is - performance wise - absolutely enough.
- If you need to read access tokens (tens, hundreds of) thousands of times per second, then using a database might be a slightly better (faster) option for you.

Smuuf
- 6,339
- 3
- 23
- 35