Documentation
¶
Overview ¶
Package sociallab is SocialLab, a social network's API: a home feed built from the accounts a user follows, posts, likes, comments, follows, and notifications delivered live over a WebSocket. It is the reference app for the social pack.
Twenty celebrity accounts are followed by everyone, which is where a viral spike lands.
Planted bottlenecks (see README.md), each switched off by a fix flag:
- timeline: the home feed is built on every read by gathering every post of every followed account and sorting them all (fix "timeline" keeps a per-user timeline filled as posts are written, and merges in only the newest celebrity posts when it is read).
- likes: every like takes one global lock, checks for a repeat like by scanning the post's list of likers and writes the like row (2ms) before letting go, so likes run one at a time across the whole app and a viral post's likes slow down as they pile up (fix "likes" keeps likers in a set under the post's own lock and writes the row outside it).
- notify: each notification is stored (2ms) and written to the recipient's open sockets inside the like, comment or follow request, under one notification lock, so a burst of likes queues up behind it and a celebrity's sockets slow every like down (fix "notify" hands notifications to a queue whose worker stores them and passes them to each socket's own writer).
Index ¶
Constants ¶
View Source
const ( // Users is how many accounts SocialLab has (user0001 ... user5000). Users = 5000 // Celebrities are user0001 ... user0020, followed by everyone. Celebrities = 20 // Password is every account's password. Password = "sociallab-pass" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.