I'm hoping the experienced Java developers here can share some insight about this problem we have been trying to solve for so many months.
We're currently building a Java web application that uses Jetbrains Xodus as its database. The web application itself is pretty much "done" except for a major issue which the database by design is not designed to be used on a horizontal-scaling environment[I may be wrong], plus the fact that we're pretty much constrained in using NGINX Unit as our application server.
The problem with Horizontal Scaling
Our server is not a typical server that processes just CRUD database requests and can return a response quickly, it processes custom logic that can take up form 0 to 10 seconds (the hard limit) depending on the logic. This brings us to the problem that if the application is not scaled horizontally then these request processing becomes a "blocking" problem. It blocks other requests for seconds.
The problem with Vertical Scaling
Given the first problem, vertical scaling is our next best option, however NGINX Unit (at least it's Java runtime) does not play well with this, it's runtime can only do single thread processing of a request. Thus, even we scale up the cores and memory of the server Unit will just process the request in a single-threaded fashion, making it a "blocking" problem also.
This brings us again to the notion of why we don't just scale horizontally by configuring Unit to spawn more processes (since you can hard set Unit to allow 1 to n processes), the problem is with the database, Jetbrains Xodus is accessed by the application through an embedded Java object which is locked into one process. Accessing it from another process while it is locked to one will not work. So currently, we run our Unit at the max of "1" process.
We've tried to solve this by using off-heap caching, but the database object can't be serialized so this object can only go as far as the heap of the application process, other processes cannot access this object. Also tried to research on sharing objects across multiple Java processes but looking at it, it seems it not a reality atm.
What could be the best approach to solve this within given the given constraints? Using Jetbrains Xodus and NGINX Unit.