Session Usage vs SQL Query Function

Asked

Viewed 35 times

0

I am developing a system and today I have some 10 modules, currently I do the permission storage of each module in a separate boolean Session.

The Value of each Session receives the module name followed by its permission on Default startup and leaves it stored.

It would have a lot of performance impact if I changed this permissioning system by Session using a direct query in the database at the time of checking the module checking its permissions ?

Thank you.

  • It depends on the type of DBMS you will use. If you are going to use a relational one, you will not get any. Because, both Séssion and most relational, will read on disk (with some caveats). However, if the storage system is performance-specific (or "in-memory"), such as Redis, Mongo, and some cache managers, it may give you a very sinitional performance boost. The link below is interesting (example in PHP): https://forum.imasters.com.br/topic/407092-resolver%C2%A0sess%C3%B5es-php-com-nosql/

  • Dude, if you don’t have a memory problem and your Septssion is in memory, don’t pass it to the bank. You are leaving for a place where the order of magnitude of the access time is several times higher.

1 answer

1

Depends, where is this Séssion saved? In memory?

How often do you do this check on a Request? If you do this more than once, you will get performance loss, since now you will have to go to the bank to run the query, the bank will process and respond. Even if the bank and application are on the same machine, there is a communication cost, meanwhile, if Session is in memory it is much faster to read.

You should also analyze if the system will grow. For example, if in the future it is necessary to put the application running on a farm, the best option would be a central cache and not several machines with the same memory. In this scenario it is a good idea to think of something like Redis, since it is much faster than a relational database.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.