Our system has structured model (about 30 different entities with several kind of relations) entirely kept in memory (about 10 Gb) for performance reasons. On this model we have to do 3 kind of operation:
- update one or a few entities
- query for a particular data (this usually require to read thousands of entities)
- get statistical data (how much memory is used, how many queries for kind etc.)
Currently the architecture is a fairly standard one, with a pool of threads for servlets that use a shared model. Inside the model there are a lot of concurrent collections, but still there are many waits because some entities are "hotter" and mostly of threads want to read/write them. Note also that usually queries are much more cpu and time consuming than writes.
I'm studying the possibility to switch to a Disruptor architecture keeping the model in a single thread, moving everything possible (validity checks, auditing, etc.) out of the model in a separate consumers.
First question of course is: does it make sense?
Secondo question is: ideally write requests should take precedence over read ones. Which is the best way to have a priority in disruptor? I was thinking about 2 rings buffers and then try to read from the highpriority one more often than from the low priority one.
To clarify the question is more architectural than about the actual code of LMAX Disruptor.
Update with more details
Data is a complex domain, with many entities (>100k) of many different types (~20) linked between them in a tree structure with many different collections.
Queries usually involve traversing thousands of entities to find the correct data. Updates are frequent but quite limited like 10 entities at time, so in the whole data are not changing very much (like 20% for hour).
I did some preliminar tests and it appears the speed advantages of querying the model in parallel outweigh the occasional write locks delays.