1

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?

Denny
  • 11
  • 3
  • instead of a HashMap I would use a cache like CaffeineCache. This could be utilized to delegate the calculation to a separate cache pool at least. – sschrass Apr 08 '18 at 10:52

0 Answers0