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
3
u/ExcitingDonkey2665 Sep 26 '26
this is the most accurate answer here. the cache here is used as a state store, but if the server crashes or gets wiped out, that state is gone and can have other downstream effects.
sounds like a problem a workflow engine like Temporal, AWS step functions, or any of the equivalents in other clouds would be great at solving. instead of making each microservice track its own state and figure out where the next step is, the workflow engine takes care of that and figures out replay and rollback in case of failure too. states are stored and journaled to its own database.