DB sessions, performances worries...

[eluser]Référencement Google[/eluser]

Using the db_session library to store some session data at almost each page view for each users, I am worry about performances when the website will go live and will have 1000 visitors / hour.

Is it possible that the use of native PHP sessions could be better than using DB to store things like the actual page wich is viewing the visitor in real time (the reason for that is to get him back to the point he was viewing before a redirection for exemple).

What do you think ?

You could store the sessions in a heap-table.


That should be fast enough.


Native sessions use the file system that is faster than the db, but less secure, especially on a shared host, the above solution might be good for you, but here are some alternatives:

You can use native sessions for non sensitive data (lie you mentioned) and keep db session for sensitive data (this will result in 2 session cookies, unless you set your own native session handlers, for php, but you loose some security, having 2 session cookies should be ok)

Also you can add a destructor to the session library if your run php5 to iterate with the database only at the beginning and the end of the lifetime. (if you don't set all session variables at once)

[eluser]Référencement Google[/eluser]
Thank to both of you for your answers.

Your solution Alibi looks great for me, I didn't know about that kind of engine, I will try.
One question about it, as they said in the MySQL documentation, it is very fast, but will the MySQL server not too much overloaded while there will be 1000 visitors logged in at the same time on the website ?

Your solution Alpar looks also good, but seems very complex to script, then I will choose the MySql Heap table engine solution.

Im thinking that if you are not overusing sessions or not using a P3 as your hosting CPU, 1000 visitors per hour is a joke load-wise.

[eluser]Référencement Google[/eluser]
No, sure not a P3, intel Xeon Dual core 2Go, should be enough I think
Thanks for your answer.

You could ofc try it out with a simple load tester or something.
Perhaps just make a simple controller using some session stuff which requires DB hits and spam it with requests. See how high requests per second or queries per seconds your app can handle.

[eluser]Référencement Google[/eluser]
ok, I will try it

But when using HEAP/MEMORY table I don't think you can use text datatype.

[eluser]Référencement Google[/eluser]
tobben your are right, this is the only problem with Memory tables.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.