Reputation: 4573
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).
Upvotes: 1
Views: 552
Reputation: 46482
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.
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:
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.
Upvotes: 1