3 ms·
I think the problems identified with the architecture are being wrongly imputed on REST. REST is synchronous in terms of request/reply, but that doesn't mean t
by icebraining 11y ago
I think the problems identified with the architecture are being wrongly imputed on REST.
REST is synchronous in terms of request/reply, but that doesn't mean that higher-level actions must (or even should) be restricted to that cycle, so subprocesses like the notification should never have to block the stock update. Even if the requester needs to be informed about that, the stock updating mechanism should instead create a new Resource that tracks the notifications, and send the link to it so that the client can see how it's going.
But this wouldn't be necessary, because I agree that the stock updating shouldn't have to known about the notifications - but again, REST does not require it to!
The way to architect this using REST would be for the Notification Service to track how the stock of each product is currently. Since polling each product is inefficient, the stock manager could offer a feed that lists the latest stock updates, just like blogs do with posts.
This doesn't require a SPOF like a messaging bus, it doesn't suffer from the "service going pop" problem (since we've eliminated the dependency the inventory service had on the email system) and it's proven to work at a huge scale - the web.
- mateuszf 11y ago> the stock manager could offer a feed How does it differ from polling?
- icebraining 11y agoIt doesn't, it differs from polling each product, since it provides a single resource for all of them. An alternative would be for the Inventory system to allow the Email system to register a callback URL (aka Webhook) with it that gets called when the stock updates - allowing for push events while maintaining a decoupled architecture -, but that is only useful if the stock only gets updated sporadically, as you should still have a resource that can be polled, in case the Email system dies and then needs to check what happened when it was offline.
- HappyTypist 11y agoPolling a "show me all updates since X" endpoint is a reasonable approach that is loosely coupled and minimises the amount of transfer needed.
- edem 11y agoSo you imply that the OP is defeating a straw man, right?
- ah- 11y agoThat polling endpoint is a message bus, just disguised as a REST endpoint. You point about the SPOF is that you prefer distributed state inside the individual services over having events stored in the message bus? Then you're back to high coupling between the inventory manager and notifier, if the former is down the latter won't be able to send out any notifications.
- icebraining 11y agoIf the inventory manager is down, no updates to the stock can occur, so what notifications are there to be sent? You can't eliminate coupling that arises from the semantics of the model, only obscure it by adding a layer of indirection. The coupling that should be eliminated is the reverse, ie., the inventory being unable to update stock if the notifier is down, which the article claimed was inevitable using REST. I tried to show it isn't. Regarding the message bus, I actually meant the broker, which is the SPOF being introduced in the proposed architecture.
- gmtgmt 11y agoIt looks like ESB implementations from a decade back is being reasoned out into REST, like fitting a round peg in a square hole in many places in their diagrams
- eternalban 11y agoAnd finally reduced to TX monitor. Rinse and repeat.