Question

I know optaplanner scales very well wrt problem size. But how can it scale wrt the number of problem requests? Currently, we have exposed optaplanner as a REST service. It can get hundreds of scheduling requests per day. Search is stopped after 10 seconds. This means that at some peaks there are several scheduling requests in the queue. What could we do to parallelize the requests on multiple machines?

Was it helpful?

Solution

All low-level support for a multi-tenant setup (on a cluster) is available:

  • The SolverFactory is thread safe, 1 per node
  • 1 Solver per thread per node. Because a single Solver hogs a single Thread (it does not do any IO, unlike web requests etc), I recommend against running more Solvers than there are Threads.
  • Solver.terminateEarly() is thread-safe and can be called on all Solvers if the node is exiting.

However, there is no high-level support for a multi-tenant setup yet. So you 'll need to build that yourself:

  • Queue requests to be handled, in case more requests come in than threads are available. A JDK ExecutorService with the size of the number of CPU cores should suffice for this. Simply submit the requests as Future's. Build the Solver in the Future. Build the SolverFactory at bootstrap.
  • Optionally play with allowing more/less time depending user saturation. terminateEarly() can help in this regard.
  • Load balancing over nodes of the cluster. Each cluster has 1 ExecutorService.
  • Work stealing?
  • High-availability
  • Failover
  • ...

We 'll build high-level support in the future. Please add your requirements in this jira issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top