ls1intum / Artemis

Artemis - Interactive Learning with Automated Feedback
https://docs.artemis.cit.tum.de
MIT License
459 stars 274 forks source link

Test Exams: Generating Student Exams takes too long #6208

Open Strohgelaender opened 1 year ago

Strohgelaender commented 1 year ago

Describe the bug

For test exams, student exams get automatically generated when the student opens the exam for the first time.

On our production system, we noticed some cases where generating one individual exam would take up to 8 seconds:

grafik

This is an issue, since the student can and might do additional requests during this generation time. This leads to multiple student exams related to the same user:

grafik

Artemis assumes that one student can only have up to one student exam, so this leads to internal server errors: grafik

To Reproduce

Create a new student exam for a test exam.

Expected behavior

Each student should only have one related student exam. The generation process should only take a few ms.

Screenshots

grafik

Which version of Artemis are you seeing the problem on?

6.0.2

What browsers are you seeing the problem on?

Other (specify in "Additional context")

Additional context

Generation of StudentExams: StudentExamRepository#createRandomStudentExams

Relevant log output

No response

krusche commented 1 year ago

The server generates repos and build plans so we cannot make it a lot faster. However, we can check if the student exam already exists and only create one and immediately save it if it does not exist. A loading screen / progress bar on the client might also help to prevent that students execute this action multiple times

krusche commented 1 year ago

I just looked into it again and the repos/build plans are generated at a later point of time, so this could not be the issue. I am not sure why this is slow, maybe SecureRandom in StudentExamRepository:313 is sometimes slow? see e.g. https://stackoverflow.com/questions/137212/how-to-deal-with-a-slow-securerandom-generator

I am not sure if we really need a SecureRandom here