0

I am working on a system based on Apache Cassandra and written using Akka and I am learning to live without an RDBMS. However, I have a singular problem that I would like to have feedback on how to implement it. Basically I have learned to work without ACID and have come to the conclusion that even banking systems can be done in a database so long as it has the (A)tomic in the ACID. Purchases for products, inventory management and so on are solvable and I have solved them. The question, then, revolves around a simple activity, namely registering users.

When a user registered the constraints are that a user may not be registered with a username used by another user nor an email used by another user. However this is a global constraint and cassandra gets in my way. I can't first check the DB for the username and then write the user in a distributed implementation because I lack the (I)isolated aspect inside of Cassandra. For most other things I can spin up an actor to handle a single product or vendor or customer and handle messages in those actors and enforce constraints there but in this case I am dealing with a global resource.

To solve the problem I have resorted to a cluster singleton to implement the registration process and all registration is funneled through this actor which enforces the constraints but having a single point of failure makes me uneasy.

So that leaves me to the question. Using only Cassandra and Akka, do people have any suggestions for how I could implement user registration, while keeping the global constraints, in a distributed environment without a cluster singleton. This kind of implementation should be applicable other other global resources in the system as well.

I eagerly look forward to your ideas.

Robert Simmons Jr.
  • 1,182
  • 8
  • 21

1 Answers1

1

Cassandra can handle this for you with the following concept:

https://www.datastax.com/dev/blog/lightweight-transactions-in-cassandra-2-0

Near the end there is an example which is practically poster child for your case.

Then if you need to know if insert was successful or not, this might help: https://stackoverflow.com/a/31390601/7413631

Lightweight transactions are not as performant as the regular insert, but in your case I guess it's just 1% of the work load so it's totally fine to use them there.

Community
  • 1
  • 1
Marko Švaljek
  • 2,071
  • 1
  • 14
  • 26