I have a Spring REST API.
Let's say /students/122/gpa
endpoint gives us GPA of the student with id=122
Let's assume that we are pre-calculating all GPA data and write into an HashMap.
I don't want to query database for each request.
The problem is:
- GPA calculation process (let's sat
/calculate
endpoint) is a hard mathematical process consumes almost all CPU. - When I trigger /calculate endpoint to refresh GPA HashMap,
/students/{studentId}/gpa
endpoint responses very slow as all the CPU is consumed by calculation.
Is there any way to under-prioritize some endppoints or some service tasks in Spring REST?