CodeIgniter Forums
DB sessions, performances worries... - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: DB sessions, performances worries... (/showthread.php?tid=2712)



DB sessions, performances worries... - El Forum - 08-20-2007

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

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 ?


DB sessions, performances worries... - El Forum - 08-21-2007

[eluser]Unknown[/eluser]
You could store the sessions in a heap-table.

http://dev.mysql.com/doc/refman/5.0/en/memory-storage-engine.html

That should be fast enough.

Andreas


DB sessions, performances worries... - El Forum - 08-21-2007

[eluser]alpar[/eluser]
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)


DB sessions, performances worries... - El Forum - 08-22-2007

[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.


DB sessions, performances worries... - El Forum - 08-22-2007

[eluser]Akademik[/eluser]
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.


DB sessions, performances worries... - El Forum - 08-22-2007

[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.


DB sessions, performances worries... - El Forum - 08-22-2007

[eluser]Akademik[/eluser]
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.


DB sessions, performances worries... - El Forum - 08-22-2007

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


DB sessions, performances worries... - El Forum - 09-17-2007

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


DB sessions, performances worries... - El Forum - 09-17-2007

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