简体   繁体   中英

except session any other option to keep data in spring MVC application

I am developing Online Examination software, where thousands of students can give online exam from their college/school at a same time. So considering concurrent hits and server performance i am finding the different and best way to store some exam related data:

In application each student will get questions randomly. I am thinking to store student wise questions in session but i am worried about storing such a large (question its options) data in session .

Consider an scenario let each student will have 30 ques and in a single slot 10k students are there. Then session object will become too big, isn't it?

Also there are some settings/configurations related to exam which i want to keep ready (i don't want to fetch the configurations from DB each time).

Consider an scenario let each student will have 30 ques and in a single slot 10k students...

I suppose some students get the same question. In case you really have 300k different questions, you can stop reading now.

In application each student will get questions randomly . I am thinking to store student wise questions in session

I guess you don't need to store anything then. Generate a single random masterSeed , take a studentId , and compute seed = secureHash(masterSeed, studentId) . Use this seed for selecting the questions. Recompute if needed.

Concerning storing the questions, use the database and caches as usual, forget the session.

Requested details about question selection

The answer to "Can you please provide some more exposure to selecting questions using seed and caches" is "actually no". Why?

  • Whatever randomized algorithm the OP uses for choosing the question will work the same with my above proposal. Just create new Random(seed) (with the seed coming from above) and run the same algorithm. 1

  • All the caching magic a web and database servers are capable of, applies here too. My point is that there's nothing to gain by storing the questions in the session . Quite the opposite:

    • The data stored in the session are "dirty" and the server has to serialize them in case of low memory.
    • Whenever the same question for two students gets deserialized, you have two distinct pieces of data taking twice as much memory as before.

So you have more IO (a cached data can be simply discarded), more memory consumption, and you can't use the database server's memory in case it runs on a different machine.


1 This can get complicated in case the algorithm is not really random and tries to choose different question for students sitting next to each other, but that's a different problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM