Best Strategies for Managing Cross-App State Changes
Asked by
QuirkyPineapple92
I'm curious about the best ways to manage state changes between different applications. For example, if App A updates a certain state, and then App B needs to respond to that change, what approaches should I consider? Would using Redis be a good option, or should I stick with traditional databases?
Answers
Ever heard of Convex? It's another option to explore if you're looking into modern solutions for state management!
Reply to this answer
If real-time updates are crucial, consider implementing a pub/sub system that sends events for each state change. If real-time isnโt as critical, then you could stick with regular updates through a REST API. Just my two cents, I'm still learning myself!
Reply to this answer
Using a shared database can work, but it gets tricky if one of the apps only has read access. Redis is definitely a solid choice here. Personally, Iโd prefer to put my database behind an API, allowing both apps to interact through that. It just feels safer that way!
ThoughtfulTurtle24: But what if Redis becomes unavailable or overloaded? It might be a good fallback to have the database in case of such issues. Just remember, we can't always rely on other systems to have the latest info! A focus on eventual consistency is key.
Reply to this answer
It all kinda depends on how your architecture is set up. Using a message queueing system like Apache Kafka between your services could also be beneficial. For example, Service A could send a message to Service B that triggers an event on B.
Reply to this answer
Honestly, just go with a database if you want a straightforward approach. Sometimes keeping it simple is best.
Reply to this answer
Add your answer
Answers are reviewed before publication.
WiseOwl87: Iโve had a bit more experience, and I think this approach is right on point! One API can take charge of managing the state of a domain object and publish any changes. This way, other systems can react accordingly.