Skip to content

app.publish is faster than ws.send? #998

Description

@omar-mi

I am currently working on a game, and I am sending the info of all 100 players to each other.

The way I am currently doing this is by doing

for (ws in wsArr) {
    ws.send(data, true); // data is around 2000 bytes big
}

I benchmarked this loop and found that it takes around 12ms.

But when I switched to this

app.publish('global', data, true) // same size of data

It only took around 3ms

So what's the catch here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions