You all might have seen that we can see our friend group's rank list on codeforces in real-time. It makes me wonder how this feature is implemented at the BackEnd? I surely know that they initialize these customised lists at the time of registration because we can see registered friends too. Can anyone from the tech-team or anyone who has an idea help me know this. Do they keep a sorted-set kind of thing to implement this friends-ranklist and also is the score updation event-driven? MikeMirzayanov
Let me preface this with I'm not by any means a DB expert and I don't know how CF works. But I do have a decent amount of experience making stuff on the internet.
From a theoretical point of view, this is quite an interesting question. In practice (abusing properties of the real world), I would guess the naive check every time the page is refreshed is fine. For instance, I probably have more friends than ~90% of CF users (and I only have 154). In the last div2, only 16 of my friends either competed during the contest or have yet VP'd it.
So I would imagine the performance would be pretty much fine if you just did a DB query generally like:
Since almost everyone on CF has a very small number of friends competing in any given contest live, this probably isn't more than an order of magnitude harder than just displaying any particular individual's score.
this might be helpful .