Skip to content

User model will not scale with embeded lists of references to followers #181

@face

Description

@face

What version of Node.js are you using?

v14.18.1

What version of Yarn are you using?

1.22.10

What browser are you using?

Firefox

What operating system are you using?

Fedora 34

Describe the Bug

The user model has links to all followers and following. If one famous person uses the network, and has 15 million followers, their user document will have 171 megabytes of follower links (a mongodb _id is 12 bytes). Fetching the user model will be slow.

Reference to scalability issue in source code: https://github.com/ElevenSymbols/orca/blob/536dc81096fcd2799eb3ed599c392769296b3540/packages/orca-api/src/db/follow.ts#L17

Other embedded references in the User document will cause similar issues. Over time a user might contribute lots of posts, messages, and comments which all cause the User document to grow without bounds.

Expected Behavior

A user with millions of followers will have a small User document in mongodb.

Steps to reproduce

  1. Create a popular social network

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions