Hi,I am trying to understand Lagom Framework with Chirper application. Pardon my newbie questions. As far as possible I tried to see if these are answered before on forum or in documentation.- Where are the entities stored after Persist directive? I could understand that they are stored in event log and the state is updated with the latest event. From documentation, I understand that active entities are in memory. But I guess they are also persisted somewhere (perhaps cassandra) permanent. If it is cassandra, which part of code does this? Also, what are the default connection settings for Cassandra if I were to look at the data?
- In production scenario, if we were to use PersistentEntity, does it mean that all the service instances (nodes) are active and must be taking requests? In other words, is it possible to keep some nodes up but not taking external requests but open for internal requests?
--Thanks,Mangesh
You received this message because you are subscribed to the Google Groups "Lagom Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lagom-framework+unsubscribe@googlegroups.com.
To post to this group, send email to lagom-framework@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lagom-framework/16dbf097-02f0-43ca-9803-3b680819182e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On 3 December 2016 at 06:22, Mangesh Deshmukh <mang...@gmail.com> wrote:Hi,I am trying to understand Lagom Framework with Chirper application. Pardon my newbie questions. As far as possible I tried to see if these are answered before on forum or in documentation.- Where are the entities stored after Persist directive? I could understand that they are stored in event log and the state is updated with the latest event. From documentation, I understand that active entities are in memory. But I guess they are also persisted somewhere (perhaps cassandra) permanent. If it is cassandra, which part of code does this? Also, what are the default connection settings for Cassandra if I were to look at the data?The entities are not persisted anywhere - that's the point of event sourcing, you just store the events, which can be implemented very simply, be easily distributed, and done with very high performance since it's just an append operation. When an entity needs to be loaded, the events for that entity are loaded, and the event handlers that you've declared to handle the events then process each event to produce the current entity state.
As an optimisation, the entities do hang around in memory for a limited amount of time, as you've pointed out. It's important to note that this is just an optimisation, it doesn't strictly need to be done, your entity could be reloaded from the persisted events in the database every time you needed to handle a command, it's just that this can be a fairly expensive operation, and since often the same entity tends to be used multiple times in a short timespan, it can be a great benefit to keep them around in memory for a limited amount of time.As a further optimisation, Lagom supports something called snapshotting. This is where every so many events (I think we default to 100), the entity state itself is stored to a database. This means that from then on, to load the entity, Lagom will first load the snapshot, and then it will load all the events since the snapshot, and replay them - this ensures that loading an entity doesn't become prohibitively expensive as the number of events increases. But once again, this is just an optimisation, and not something that your application code should have any knowledge of. And in fact, at any time, you can drop the snapshots table, and not lose any data, since it's all there still in the events.
In dev mode, by default, Cassandra is run on port 4000. The events are stored, by default, in a table called "messages".
- In production scenario, if we were to use PersistentEntity, does it mean that all the service instances (nodes) are active and must be taking requests? In other words, is it possible to keep some nodes up but not taking external requests but open for internal requests?
This question isn't really related to persistent entities. Do you mean HTTP requests? This all depends on the configuration of your service gateway, if you're using haproxy, this would be ConductR. Out of the box there's nothing really that allows you to configure that, but there is certainly no reason why you couldn't create two different configurations, and tell haproxy to only route to one of them.
Thanks,Mangesh
--
You received this message because you are subscribed to the Google Groups "Lagom Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lagom-framewo...@googlegroups.com.
To post to this group, send email to lagom-f...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lagom-framework/16dbf097-02f0-43ca-9803-3b680819182e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
HI James,Thanks for the detailed response. Please see comments inline.
On Sunday, December 4, 2016 at 3:44:15 PM UTC-8, James Roper wrote:On 3 December 2016 at 06:22, Mangesh Deshmukh <mang...@gmail.com> wrote:Hi,I am trying to understand Lagom Framework with Chirper application. Pardon my newbie questions. As far as possible I tried to see if these are answered before on forum or in documentation.- Where are the entities stored after Persist directive? I could understand that they are stored in event log and the state is updated with the latest event. From documentation, I understand that active entities are in memory. But I guess they are also persisted somewhere (perhaps cassandra) permanent. If it is cassandra, which part of code does this? Also, what are the default connection settings for Cassandra if I were to look at the data?The entities are not persisted anywhere - that's the point of event sourcing, you just store the events, which can be implemented very simply, be easily distributed, and done with very high performance since it's just an append operation. When an entity needs to be loaded, the events for that entity are loaded, and the event handlers that you've declared to handle the events then process each event to produce the current entity state.[MD] Got it. I assume the events are stored in Cassandra as soon as generated as well as the last event is stored as a state in memory. I also remember reading somewhere that the request is automatically routed to the service instance that hosts the entity. If so, is the request routing decided by gateway? Or is it more of a cassandra functionality?
As an optimisation, the entities do hang around in memory for a limited amount of time, as you've pointed out. It's important to note that this is just an optimisation, it doesn't strictly need to be done, your entity could be reloaded from the persisted events in the database every time you needed to handle a command, it's just that this can be a fairly expensive operation, and since often the same entity tends to be used multiple times in a short timespan, it can be a great benefit to keep them around in memory for a limited amount of time.As a further optimisation, Lagom supports something called snapshotting. This is where every so many events (I think we default to 100), the entity state itself is stored to a database. This means that from then on, to load the entity, Lagom will first load the snapshot, and then it will load all the events since the snapshot, and replay them - this ensures that loading an entity doesn't become prohibitively expensive as the number of events increases. But once again, this is just an optimisation, and not something that your application code should have any knowledge of. And in fact, at any time, you can drop the snapshots table, and not lose any data, since it's all there still in the events.[MD] Very good explanation. Thanks.In dev mode, by default, Cassandra is run on port 4000. The events are stored, by default, in a table called "messages".[MD] Was able to connect to Cassandra and browse the data. It helps to understand what is happening under the hood.- In production scenario, if we were to use PersistentEntity, does it mean that all the service instances (nodes) are active and must be taking requests? In other words, is it possible to keep some nodes up but not taking external requests but open for internal requests?This question isn't really related to persistent entities. Do you mean HTTP requests? This all depends on the configuration of your service gateway, if you're using haproxy, this would be ConductR. Out of the box there's nothing really that allows you to configure that, but there is certainly no reason why you couldn't create two different configurations, and tell haproxy to only route to one of them.[MD] Correct. It was totally separate question. Unrelated to persistent entities. Should have clarified that.Yes I was talking about HTTP requests. My question was based on my assumption that the request gets automatically routed to the service instance hosting persistent entity. In which case, I thought if the node is up and there is a request for an entity on this node, it will have to serve the request (internal or external).The reason why one would want to keep some nodes up and not take any live traffic is when we make changes to the service and deploy it. In this case, one would want to test the changes internally first (on few nodes) before opening them up for external use. Hope I am making sense.
--Thanks,Mangesh
You received this message because you are subscribed to the Google Groups "Lagom Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lagom-framewo...@googlegroups.com.
To post to this group, send email to lagom-f...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lagom-framework/16dbf097-02f0-43ca-9803-3b680819182e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
--
You received this message because you are subscribed to the Google Groups "Lagom Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lagom-framework+unsubscribe@googlegroups.com.
To post to this group, send email to lagom-framework@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lagom-framework/f23cf5f9-b70d-40d6-9884-db6b081bbd97%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lagom-framework/f23cf5f9-b70d-40d6-9884-db6b081bbd97%40googlegroups.com.