Questions about brainCloud Friends and Social Leaderboard behavior
-
Context
Hello brainCloud team,
We are designing a follow/friend system for our game and would like to confirm a few details before implementation.
Our intended model is:
- We maintain our own
FOLLOWCustom Entity as the source of truth. - A game “friend” is defined only when two users follow each other mutually.
- When mutual follow is established, we plan to call
FriendService.AddFriends([targetProfileId]). - When either side unfollows, we plan to call
FriendService.RemoveFriends([targetProfileId]). - We may later use brainCloud Friends as an optimized source for social leaderboards.
Questions
1. Friend Relationship Direction
Are
AddFriendsandRemoveFriendsbidirectional for internal brainCloud friends?- If user A calls
AddFriends([B]), will B also see A inListFriends("brainCloud")? - Will both A and B see each other in
GetSocialLeaderboardresults if they both have leaderboard scores? - If A calls
RemoveFriends([B]), is the friend relationship removed from both users?
2. Idempotency
Are
AddFriendsandRemoveFriendsidempotent?- What happens if
AddFriends([B])is called when A and B are already friends? - What happens if
RemoveFriends([B])is called when they are not friends?
3. Consistency and Caching
Are friend changes immediately visible?
- After
AddFriendsorRemoveFriends, shouldListFriends("brainCloud")andGetSocialLeaderboardreflect the change immediately? - Or is there any eventual consistency or caching delay we should expect?
4. Friend Count Limits
Is there a hard or recommended limit for the number of brainCloud friends per user?
- We could not find a documented hard cap.
- Are there practical performance limits we should design around?
5.
GetSocialLeaderboardBehavior With Many FriendsHow does
GetSocialLeaderboardbehave when a user has many friends?- Does it return all recognized friends plus self, with no paging or limit?
- Is there any hidden maximum result count or payload limit?
- Are pacers included in this result as well?
6. Recommended API for Top-N Friend Leaderboards
What is the recommended API for a top-N friends leaderboard?
- Can we use
GetMultiSocialLeaderboard([leaderboardId], leaderboardResultCount, replaceName)with a single leaderboard ID? - Is
leaderboardResultCountapplied after social filtering and score sorting? - Is there a maximum allowed value for
leaderboardResultCount? - Is this API preferred over
GetSocialLeaderboardwhen we only need the top 50 friends?
7. Social Leaderboard Pagination
Is regular pagination supported for social leaderboards?
- We found
GetGlobalLeaderboardPagefor global leaderboards, but did not find an equivalent offset/page API for social leaderboards. - Is there any supported way to retrieve friend leaderboard entries 51-100, 101-150, etc., without requesting all prior entries?
8. Billing and API Counts
Is
GetSocialLeaderboardcounted as one API call regardless of the number of friends returned?- Are there additional billing or performance considerations based on response size or number of leaderboard entries returned?
9. Recommended Usage
Are brainCloud Friends suitable as an app-specific “mutual follow friend cache”?
- We will not use brainCloud Friends for unrelated gameplay relationships.
- We plan to keep
FOLLOWas our source of truth and use brainCloud Friends only as a derived mirror/cache for mutual follow relationships. - Does this align with recommended brainCloud usage?
Thank you.
- We maintain our own
-
Hi @gyutaelee ,
Thanks for the detailed questions.
1. Friend Relationship Direction - Yes, bidirectional
AddFriends: When user A callsAddFriends([B]), both A and B see each other inListFriends("brainCloud")- Both A and B will appear in each other's
GetSocialLeaderboardresults (if they have scores) RemoveFriends: Removes the relationship from both users atomically
2. Idempotency - Yes, both are idempotent
- Calling
AddFriends([B])when already friends: No-op, no error thrown (skips DB write) - Calling
RemoveFriends([B])when not friends: No-op, no error thrown
3. Consistency and Caching - Immediate
- Friend changes are persisted immediately to the database (no write-behind caching)
ListFriends("brainCloud")andGetSocialLeaderboardreflect changes immediately afterAddFriends/RemoveFriends- No eventual consistency or caching delay
4. Friend Count Limits - No hard cap
- No code-enforced limit on brainCloud friends per user
- Practical consideration: Friend IDs stored as array on UserProfile; very large arrays (>10K) may impact read/write performance
5.
GetSocialLeaderboardBehavior - Returns all friends + self + pacers, no limit- Returns all recognized friends + self + pacers
- No hidden maximum result count
- Pacers are included (if leaderboard has pacers configured)
- Warning: Response payload grows linearly with friend count
6. Recommended API for Top-N - Yes, use
GetMultiSocialLeaderboardGetMultiSocialLeaderboardwith a single leaderboard ID is a correct approach for top-N resultsleaderboardResultCountis applied after social filtering and score sortingleaderboardResultCountis capped bymaxMultipleLeaderboardScoreLimitapp property (default 10, can be raised in app-basis)- Preferred over
GetSocialLeaderboardfor top-N because it has built-in truncation
7. Social Leaderboard Pagination - Not supported
- No
GetSocialLeaderboardPageAPI exists (onlyGetGlobalLeaderboardPagefor global leaderboards) - Social leaderboards always return the full friend set (potentially truncated by
leaderboardResultCountonly in the multi variant) - I will forward your pagination request for team review
8. Billing and API Counts - 1 API call per request
GetSocialLeaderboard= 1 API call regardless of friends/entries returnedGetMultiSocialLeaderboard= 1 API call even with multiple leaderboardsAddFriends/RemoveFriends= 1 API call even though they modify both users' profiles
9. Recommended Usage - Yes, your design aligns perfectly
-
Hello, thank you for the clarification.
Based on your answer, I understand the following:
GetSocialLeaderboardreturns the full set of friends + self + pacers, and there is no hidden max result limit.GetMultiSocialLeaderboardcan return only the Top N results usingleaderboardResultCount, after social filtering and score sorting.- However, there is no page/offset-based pagination API for social leaderboards like
GetGlobalLeaderboardPage. leaderboardResultCountis limited by the app propertymaxMultipleLeaderboardScoreLimit, whose default value is 10.- Friend IDs are stored as an array in the
UserProfile, so very large friend lists may affect read/write performance.
I have two follow-up questions:
-
How can we increase the
maxMultipleLeaderboardScoreLimitvalue?
Is this app property something we can change directly in the Console, or does it require a request to brainCloud Support?
If a Support request is required, could you let us know what information we need to provide and whether there is a recommended maximum value? -
We are planning to build a friends-based social leaderboard for up to around 10,000 friends.
In this case, is the recommended approach to callGetSocialLeaderboard, retrieve the full friends leaderboard, and then handle paging on the client/server side?
Or, at this scale, would you recommend using a separate Custom Entity, Cloud Code, external ranking cache, or another leaderboard structure instead?
To clarify, our requirement is not just to fetch the Top 50 users.
We want to continuously page through a friends-based leaderboard like this:rank 1–50 rank 51–100 rank 101–150 ...Based on your previous answer, I understand that social leaderboard pagination is currently not supported.
Could you please advise on the recommended architecture or best practice for implementing this kind of UX with a friends leaderboard of up to 10,000 users?Thank you.