Skip to content

Optimize Data Persistence (Batching) #3

Description

@samarkun23

Current Issue: Currently messages.worker.ts writes every single stroke/message to the database one by one. In a busy room, this will overwhelm Prisma/PostgreSQL.

Improvement: Message Batching.

  • Modify the worker to collect messages in a small buffer (e.g., for 500ms or until 50 messages) and use prisma.chatSchema.createMany() to save them in one go.
    Result: Drastically reduces the number of database connections and write operations.

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