-1

I want ask this question more on design perspective rather than any implementation. Lets, start with an example of a routing engine (or anything else) that can be configured using some rule engine or some configuration based way where intention behind both the ways is, for example, to lookup the destination for incoming requests.

In my point of view, rule engine is relevant when the system need to take dynamic decision on where to route any particular request, whereas configuration based systems are more performant (since they dont have rule execution overhead) if the routing logic is predefined and agnostic of incoming request data.

Any other relevant aspect or pros-cons we should consider from application designing/architecture perspective?

Abhishek Chatterjee
  • 1,962
  • 2
  • 23
  • 31
  • I think this question is too generic/broad to be able to provide valuable answer. Could you please provide a bit more concrete problem? – Peter Csala Aug 03 '23 at 08:06
  • Also please bear in mind that the two techniques are **not** mutually exclusive. For example the weights can come from configuration which is used by the rule engine. – Peter Csala Aug 03 '23 at 08:07
  • 1
    True, they are not mutually exclusive. But my question is more around the recommended approach between config-driven and rule-driven. For example, a message hub that is reponsible for transferring messages from different parties, i.e. taking from P1 and send to P2,P3, taking from P2 and send to P1, P4 etc. where the routing logic can widely vary but is already known at compile time (and its not a content based routing). This problem can be achieved by both the approaches, but which one to adopt. – Abhishek Chatterjee Aug 06 '23 at 10:39

1 Answers1

0

As I stated in the comments section the question is too broad to be able to provide specific answer IMHO. So, here I can only help you by providing a bit more generic comparison and advice.

Variations

Going with your routing example the rule driven design is considered more static than the configuration driven one. Whereas rules are usually coded with imperative techniques, the configs are considered more as a declarative approach.

And there can be huge differences between dynamic approaches:

  • Are the configs editable only by service team or by a broader audience?
  • Are the configs stored in files or records?
  • Are the configs accessible via a database or via a web service?
  • Are the configs retrieved only at service start or periodically/continuously?
  • Are the changes propagated via pooling or is it push-based?
  • etc.

Comparison

Here is a small comparison which might help you during your trade-off analysis

Pros Cons
Dynamic Rule changes can be applied more quickly Harder to debug the rule resolution especially when the engine supports multi-source and override
Static Easier to verify correctness via unit tests There is a tendency that over time the engine and rules become more complex and tenant-specific

My general rule of thumb would be to stick with a simpler approach until you bump into a limitation of the given solution. Try to think about it as an iterative approach rather than building a starship from day 1.

Peter Csala
  • 17,736
  • 16
  • 35
  • 75