Why Lagom uses Cassandra as a default persistent layer not Kafka?

One of our new joiners is asking this question:

Why Lagom uses Cassandra as a default persistent layer instead of Kafka?

In fact, I start to see quite few companies doing event sourcing with Kafka only, i.e. kafka as an event journal storage.

One of the reasons why we need Cassandra I can think of is because we need to recover the actor’s latest state fast. i.e. Cassandra lets you query the snapshots table and the messages table whereas the same operation can be quite difficult to achieve with Kafka.

Kafka supports infinite retention periods of their logs so basically people can use it as a database if they want.

Are there any other good reasons to add here?

Thanks,

Joo

Hi Lejoow,

I have also seen people using Kafka as a event source backend. The main issue with that you mention yourself. You must be able to read a journal by picking only the events for one specific persistence id. You don’t want to read a whole topic and filter out all the events and only pick those for the PersistenceEntity you are rehydrating.

I have seen people saving snapshots on each event to avoid this. So yes, you can use Kafka as a event source backend, but it comes with a bunch of drawbacks requiring some hacks to make it work smoothly.

Cheers,

Renato

6 Likes