First of all, Akka persistence stores data using a journal. Data in that journal (both events and snapshots) are stored after being serialized. This seems to pose several problems:
- You can't have access to data as you may have in a SQL or NoSQL database, so it seems to be hard to diagnose corrupt data or relationships among that data. Am I missing anything here?
- Storing data in a journal seems great for storing immutable data and recovering events for event sourced data, but... how do you manage to do queries on that data? I mean, if you store orders using Akka persistence, how do you get orders for example between two dates? The only thing I can think of here is to use PersistenceQueries in order to keep a traditional database in sync with the journal, but that kind of defeats the purpose of Akka persistence, doesn't it?
Regarding how to keep actors in memory, you may have several requests that access the same entity (persistent actor) so I guess they have a different life cycle than request specific actors, that can be destroyed after serving the request. The point is that you seem to end up with the whole database in memory if you don't provide a mechanism to shut down actors that hasn't been used recently. But then you may be shutting down actors that may be used in a short amount of time and have a negative impact on performance due to the actor reloading its state. I guess this is somehow alleviated with the use of snapshots. Again, am I missing anything here?
Hi!I've been reading about Akka persistence, and it seems the way to go to persist data in a reactive application, using event sourcing and immutable data models. I have no experience doing this, so I'd love to hear about your experience. Any way, after reading the docs, I have the following doubts (please, correct any false assumption I may have made):First of all, Akka persistence stores data using a journal. Data in that journal (both events and snapshots) are stored after being serialized. This seems to pose several problems:
- You can't have access to data as you may have in a SQL or NoSQL database, so it seems to be hard to diagnose corrupt data or relationships among that data. Am I missing anything here?
- Storing data in a journal seems great for storing immutable data and recovering events for event sourced data, but... how do you manage to do queries on that data? I mean, if you store orders using Akka persistence, how do you get orders for example between two dates? The only thing I can think of here is to use PersistenceQueries in order to keep a traditional database in sync with the journal, but that kind of defeats the purpose of Akka persistence, doesn't it?
Regarding how to keep actors in memory, you may have several requests that access the same entity (persistent actor) so I guess they have a different life cycle than request specific actors, that can be destroyed after serving the request. The point is that you seem to end up with the whole database in memory if you don't provide a mechanism to shut down actors that hasn't been used recently. But then you may be shutting down actors that may be used in a short amount of time and have a negative impact on performance due to the actor reloading its state. I guess this is somehow alleviated with the use of snapshots. Again, am I missing anything here?
Thanks!!José