We’ve adopted to use an event bus in our modular monolith, and have seen a very positive return on that investment (in managing dependencies between packs, and the system capabilities enabled).
However, as we analyze our system behavior at runtime (under real traffic), we’ve observed a situation with which folks here might have experience.
For context, we’re building an Ads platform… to manage the sale of advertising space as well as to manage the delivery of those ads with other vendors.
We have fine grained things (like an Ad) and course grained things (like an Order, containing 1000s of Ads). When 1 Ad changes, an event is fired… then an event handler will execute to update an Order (eg, the total price of an Ad changes, triggering an update in a total price of a pending Order); that will in turn generate an event announcing the Order has updated.
So, Update Ad => Ad Updated Event => Update Order => Order Updated Event
However, when all 1000 ads in an Order change, you can guess what happens: 1000 updates of the order (999 are needless), and 1000 events announcing the Order was updated (999 are needless). Those 999 superfluous events are causing processing delays of other events.
Questions for the community:
- do you have an event bus in your modular monolith?
- did you find a need to debounce certain events?
- does your event bus technology (eg, RabbitMQ) already support this requirement?
- did you build your own? If so, describe your solution.