In Firebase, what is the main reason to use distributed counters instead of a single document counter?
Think about what happens when many users try to update the same counter at once.
Distributed counters split increments across multiple documents to reduce write contention and improve scalability. A single document can become a bottleneck when many writes happen simultaneously.
Given a distributed counter with 5 shards, what happens when you increment one shard document in Firebase?
Consider how distributed counters store counts across shards.
Each shard document holds part of the total count. Incrementing one shard increases only that shard's count. The total count is calculated by summing all shards.
Which Firebase security rule best prevents unauthorized users from arbitrarily modifying distributed counter shard values?
Think about limiting increments to small controlled changes by trusted users.
Security rules should allow increments only of 1 by authenticated users to prevent tampering. Allowing unrestricted writes or denying all writes would either be insecure or prevent updates.
You want to configure a distributed counter in Firebase to handle up to 1000 increments per second without contention. Which shard count is most appropriate?
More shards reduce contention but increase cost and complexity.
100 shards provide a good balance to handle 1000 increments per second by spreading writes, reducing contention, and controlling costs compared to 1000 shards.
You have a distributed counter with 4 shards having counts: 12, 15, 10, and 13. What is the total count returned when you read the counter?
Sum all shard counts to get the total.
The total count is the sum of all shard counts: 12 + 15 + 10 + 13 = 50.