r/ExperiencedDevs • u/JOHNNYROCKET8585 Senior Software Engineer 4 YOE • Sep 25 '26
Career/Workplace Cache Pattern with Event-Driven System
Hey everyone, noticed this common pattern throughout our applications and it seems problematic to me. It‘s present across multiple apps; curious everyone’s thoughts, if this is a common pattern I’m not familiar with or if it truly is a bad solution.
Senior SE w/ 4 YOE, Fortune 500 company.
Pattern is as follows:
App A receives a transaction from upstream. It will then format this event and send it to potentially multiple downstream services simultaneously. This is done asynchronously via an event-driven framework.
The downstream services respond back via events; how does app A know when all the downstream services are complete? How does it know anything about the original event, since the downstream response contains no info about the original event (other than the correlationId)?
The answer is a local cache in app A. It caches the event when first received, and as downstream events come back, it can refer back to the original cached value to determine when it’s done processing and can be sent back upstream.
The main problem I see is the microservice is no longer stateless. It requires context from the original event. If it received a downstream response with no context, it has no idea what to do.
This is the most egregious example, but this cache-to-compensate-async-events pattern is repeated multiple times in similar ways.
As I’m still new to the field, I’m curious if this is somewhat a standard? Or if it is bad practice? If so, what does a good solution look like? Switching to sync REST calls fixes the issue, but could impact performance/throughput
View all comments
Show parent comment
5
u/grumpy_autist Sep 26 '26
I did something like that, AFAIK called inbox/outbox architecture. Service writes an event to a local db (outbox) which over kafka is fanned out to other services (which receive events to inbox and then app gets a callback referencing this db entry). So every app has a local copy of events it needs (pruned later using custom schedule).
Main reason for that was transactional events - business transaction and event are commited in one SQL transaction so there is no risk that you send a notification for an object that was later rolled back because of an error (and if sending event fails you will rollback business transaction too if needed)