Hi Kumar,
This is a tricky problem because, the way Realtime Database is set up, it's made so you don't have to iterate over all the scores to find an entry.
If you want to get a person's rank in real time, it means counting the # of scores that are better than theirs, which could mean a lot of iterations, and it gets worse the more popular a game is!
Another potential solution, if the ranking doesn't have to be in real time, is to have a periodic Cloud Function that sorts all the current scores and ranks them by adding a "rank" field to each one. Then you could use that data in your display. The obvious downside is that you don't get the rank of a score as it's posted.
However, for the first method, I haven't tried making a RTDB query that sorts by the score, starts at the user's score, pulls all the better scores with no limit and just calls "ChildrenCount" on the result. It's possible this would be cost effective at various score counts, and might be worth trying.
Best,
DZ