We have to compute a schedule for a set of students and teachers in a school. The program takes a large amount of data. The time it takes to compute a schedule for a given input cannot be determined. It could take 2 seconds or 30 minutes. In some cases it might not be able to compute a schedule because of some conflicts even after 1 hour. We call this program the scheduler.
Option 1: Have a web server running. When the client makes a GET
request, start the computation immediately and return the output when it's done.
Option 2: Have a web server running. When the client makes a GET
request, take the input data and put it in a job queue, return a message to the client stating that the job is in a queue. A separate thread will keep checking the queue for new jobs. If the queue is empty, it will wait. If there is a job, it will start the scheduler with the input. When the scheduler returns the output, we take the data and send it to an endpoint that was specified when we received the job request.
Additional Information:
The server doesn't store the output anywhere. It computes the output and sends it to the client. If the scheduler didn't have a solution for a given input, it sends an
INFEASIBLE
status code.The server also contains some other endpoints that provide some other functionality. The scheduler is not used in these endpoints.
We have implemented both of the options right now.
Questions:
We are taking a
GET
request for the endpoint in both the cases. We are not sure whether it should beGET
orPOST
. What should be the correct method?Which option do you think is better? What other designs would work better for us?
Any kind of help will be appreciated! Thanks!