Welcome Guest, Not a member yet? Register   Sign In
Session storage
#1

[eluser]Unknown[/eluser]
Im dont know yet how exactly should i handle session data. Is there an experienced php programmer around here to give me some hints?


I have the following problems:
~my site requires more than 4kb of data to be stored in the session(i read that the cookie in which the session is stored can only hold that amount of data).

~i cannot store the session data in my DB because i have a huge site and i dont want to overwhelm the DB transactions.

~the site is already making too many queries(in the DB) so i was thinking about implementing memcache in the CI's database class(=>some advice please)




And now 2 questions:
-where is the session data stored on the server(considering the fact that session data is saved in cookies on the clients harddisk)

-if the above answer is "in the servers memory", how do i make the session data available on multiple servers? My site is running on 3 servers and one balancer which redirects the client on whatever server is less busy. So if a user logins to my site(on server 1 for example) and after few clicks the balancers redirects him to another server, how do i make it so that the user still has his session data?




Thanks alot to whoever finds the time to give some input.
#2

[eluser]barbazul[/eluser]
I think the answer to all your problems is to use memcache.

First of all, don't use php native sessions for your server structure because they use local files for storing data and each server won't know what data is being held on which other server. That's also the main reason to fall back to cookies, it wont matter which server processes the request because session data will always be available.
I also understand why you don't want to use the db for this.

So I would say you should definitely move forward with Memcache. Seems like the best solution to all your problems

In case you (or someone else reading this) don't know how memcache works, its simple: A memcache server has a certain amount of memory to store data on a key-value basis.
As its a different server to which all servers connect to, all of the will have access to it and the information stored will be unique.mo.

Memcache also comes with a module to replace php native sessions which i never used but seems like the optimal solution

Hope you find this useful
#3

[eluser]Rascal2pt0[/eluser]
4KB is A LOT of data to be storing in a session. Also you need to consider that the database is built to handle insane amounts of transactional processing. The database can handle it. The better question is if its actually necessary to put that much data in the session variable. I typically store only the user id in the session everything else is handled by the db, session specific information etc...

memCache is more of the icing on the cake for a well developed web app.




Theme © iAndrew 2016 - Forum software by © MyBB