2

I have mobile app with backend server running in nodejs with cassandra as database. The app is like social network where you can share pictures and follow other people. Some operation like updating username, the nodejs runs select query to find all pictures shared by user and updates the username there and some other tables wherever username is present and then finally returns.

Sometimes it ends up updating 5-10k records and takes around 15-20 secs. I tried running those updates on different tables in parallel fashion using async library, could not get significant improvements. How to handles this scenario where client app shouldn't have to wait for that long? Also how does facebook handles this kind of scenario?

2

If you need to SELECT before UPDATE you are doing it wrong. Cassandra is faster at writing than it is at reading. You will never get 100k writes / s if you need to read before write.

I suggest you would use an id for the user. In that case you would not need to update all the other tables when the username changes.

Finally, if you don't want to do any of the above, you could try to optimize by:

  1. Using BATCHes for the updates. This would eliminate overhead.
  2. Make sure you are not using LWT. Read there why.
  3. You could also reduce the consistency to one, but I guess you don't want to do that since it means loosing consistency. The data you read before the write would not be the "latest" representation.

You will have to ask Facebook on how they do it. As far as I now they're not using Cassandra any more.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.