Are PHP sessions reliable?

I'm wondering if PHP sessions are reliable; especially when there are 200-300 simultaneous users writing to it. This question is in context of the Quizzr App on CrazyEngineers IO that makes use of PHP Sessions to store some temporary data. We've noticed that when there are large number of simultaneous users, there 'might' be a case that the sessions tend to lose some of its data. This 'might' result into weird behaviour of the app for some of the quiz-takers. I'm saying 'might' because we haven't been able to pin-point the issue so far. It certainly NEVER occurs in our testing environment when there are 20-30 simultaneous users.

The server runs on HHVM and makes use of the SSD; so session R/W should not be an issue. I am unsure whether HHVM actually does in-memory caching of the sessions data to speed up the things and the last I checked, memcached doesn't play nice with HHVM. That said, I've also noticed app performance issue when running PHP 7.1.

Does anyone among us have thoughts or opinions about using php sessions? Would love to hear from you.

Tagging #-Link-Snipped-# and #-Link-Snipped-# and #-Link-Snipped-# to kick-start this discussion.

Replies

  • simplycoder
    simplycoder
    Generally speaking sessions on web servers are not something I prefer if any other option is available.

    One of reason is it decreases the scalability of application.
    Also you have mentioned temporary data, it is also important how much is that data in terms of size.
    Generally 1-2KB data is acceptable (This needs to be measured though).

    Its tough to answer this question unless we know for what purpose session is used (Like keeping user profile info or quiz-ids etc).
  • Kaustubh Katdare
    Kaustubh Katdare
    Thanks, #-Link-Snipped-# . This discussion is in reference to the Quizzr App; where we keep lot of our data in the sessions when the user is playing the quiz. Once the quiz is over, we write the data to the database.

    At the time of designing the system, I thought I'd be able to cache the data using memcached and thus avoid accessing the disk while the quiz is in progress. However, we've now been using HHVM and it does not support memcached. I'm now stuck with writing sessions data to files on the disk.

    The system still works because we have SSDs and haven't faced any issues. I'm now thinking of replacing sessions with Redis so that we can do a better job of maintaining the data in memory and make it available faster for all the results calculation.

    The only issue I've faced so far is that sometimes, some of the members lose access to the sessiosn data; but I've not been able to confirm this with 100% confdence. I'm not sure if it's the sessions or something else; because the issue appears only when we've 500-800 people playing the quiz at the same time, each writing to sessions.
  • kunaljd
    kunaljd
    Using redis will be a good idea. i would recommend to use mongodb, as it is very very fast and you can store the data of every transaction quickly.
    All depends on the HHVM,as it may or may not support MongoDB.
  • Kaustubh Katdare
    Kaustubh Katdare
    kunaljd
    i would recommend to use mongodb, as it is very very fast and you can store the data of every transaction quickly.
    Thanks. MongoDB ain't the ideal solution for the job. We'll need to have an in-memory cache and Redis seems to be the ideal candidate.
  • kunaljd
    kunaljd
    Yes, for in-memory cache, redis will be best option possible. mongo db is disk based db,but it can also handle big volume of data.I assumed that Mango Db is fast but what i have read about redis, its lighting fast.

    Supporting Docs:
    #-Link-Snipped-#

    Please check this video:


    So as per the this video, using redis as a buffer before Mongo DB . this is one option can be used for large chunk of data. May be this can handle 15k quizzer users per quiz.😁

    Thanks

You are reading an archived discussion.

Related Posts

20 Spectacularly Nerdy Math Jokes
Cisco has rolled out a new generation of firewalls: FIREPOWERS popularly known as "Cisco Firepowers". Firepower is gaining the market with the best features of NGFW. Cisco uses both images...
Here's a list of top scorers of the Game of Thrones Quiz. We hope you enjoyed playing. We've got a mega quiz coming up and you'll be notified. There will...
Hi, my name is Will, and I live in Bali, Indonesia. After 10 years of not practicing what I studied, I went straight to converting own's logistics center/complex from an...
Hi, this is my first post. I recently took over a project where I get to convert an old factory (basic steel frame) into a modern warehouse building, while expanding...