php - Best place to store large amounts of session data -


i'm building application needs store , re-use large amounts of data per session.

so example, user selects large list of list items (say 2000 or more) have numeric value key save selection , go off page, else , come original page , need load selections page.

what quickest , efficient way of storing , reusing data?

in text file saved session id?

in temp db table?

in session data (db sessions size isn't limit) using serialized string or using gzcompress or gzencode?

although i'd recommend users keep data in database rather simple files, exception. in general, there slight overhead in storing data in database compared files - former provides lot of flexibility on access , removes lot of locking problems. unless expect page turns particularly slow and users run multiple browsers accessing same session, concurrency not big problem, i.e.

using sort of database slower

(also, if you're going dealing large cluster of webservers - more 200 - sharing same session, yes, distributed database may outperform cluster filesystem on san).

you want think how session written. default handler writes data disk every time regardless if has changed or not - such large session, i'd suggest use write own session handler writes, not serialized session data file, stores hash of serialized data - when read in session, store hash in static variable. in save handler, generate new hash , compare static variable populated @ load time - write session if has changed. extend further applying heuristics seperate session parts update , parts less changed, record these in seperate files.

using compression not going performance.

there's scope lot of os level tuning optimize - don't os is. assuming posix , system isn't on knees, perormance hits going be:

latency in accessing data file , parsing data

(time read file relatively small, , write should buffered).

as long there enough cache, file read memory rather disk, latency negligible.

c.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -