Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Session to store Datatable

currently we are using Sessions to store datatables in our pages so that we don't have to make Database hits to get the same datatable again and again. But my worry is that it is using the server memory and if large number of users login some day, the response of the server will become slow and our application might crash as well.

Please tell me is it a good idea to store datatables into Sessions or should we get the datatables from DB everytime?

like image 613
Usman Khalid Avatar asked Dec 02 '22 21:12

Usman Khalid


1 Answers

As a general rule of thumb I would say don't use session. I haven't had to use session for a long time. As soon as you move into a web farm situation session either gets a lot slower or a lot more complicated or both.

Whether you will get away with it or not really depends on how much data you are storing in session, and how many users will be active within the session timeout period.

There are a lot of caching and in memory database options available today that may be a better option. Finally, while the solution as described sounds questionable, I wouldn't optimize the existing solution until you have actually measured a problem.

like image 159
ScottS Avatar answered Dec 18 '22 21:12

ScottS