Yes, they definitely store it in their database, because they definitely have more than one server that needs to access the data.
As for scalability, I'm sure they use a lot of caching.
Here is an example:
If you need to go through 1 million rows, the index can do O (logn) = 20 operations (in the worst case) just to find what you need.
For 2 million, you only need 21 operations (in the worst case) to find what you need.
Each time you double the number of users to go through, you just need only 1 operation (in the worst case) with an index of O (logn).
They also have a distributed architecture or cluster database.
source share