Databases · Senior · Question 74 of 75

How do you keep a denormalized value like posts.comments_count correct under concurrency?

Explanation

Read-modify-write in the app loses updates. For very hot counters, consider sharded counters or async aggregation with occasional reconciliation.

Further reading

Problem with a question

Databases · Senior · question 74

Test yourself

Take the Databases · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz