Pregunta

I have Java server with one generic operation which caters multiple functionalities internally.

Execution of one or more functions during server call depends on which client is calling and what parameters client is passing.

Server performs functionality orchestration internally based on client parameters (usually parameters are type of customer, country, product type etc)

As part of server currently we have set of if/else block to determine this but any change in this requires code changes and release.

I am planning to change this and use very light weight rules engine where I can pass set of parameters and orchestrate functionality by rules (or knockout from there).

Most important requirement is, this rules engine can be configured on the fly (thru some UI) without any code release (like rules stored in cache).

Also, my server takes 10s of millions requests per day and it has to be super fast in terms of response and I cannot afford DB hit or heavy rules engines on every HIT.

One of the idea I had was to introduce feature matrix (using some data structure) and publish it to cache and every server HIT will first check this matrix and determine what needs to be done for this request, I can change feature matrix configuration thru some UI and new configuration will be published to cache ASAP and next server request will use new configuration.

Any ideas or suggestions on implementation?

¿Fue útil?

Solución

You could use Prolog as a rules engine: a number of lightweight implementations exist.

Of course these are not always lightning-fast, but possibly fast enough for you, especially if rules are written with care.

Then you can cache the results.

If you have an usual bunch of parameters, make that bunch an object, provide with a hash function depending on contents of parameters, and use as a key into a hash map. To keep the size of the cache reasonable, implement a LRU list for the keys.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top