Skip to content

fetchSockets() is extremely slow when more than 1 server is connected #31

@aureus1

Description

@aureus1

Reproduces with this code:

import { Redis } from "ioredis";
import { Server } from "socket.io";
import { createAdapter } from "@socket.io/redis-streams-adapter";

const redisClient = new Redis();

const io = new Server({
  adapter: createAdapter(redisClient)
});

io.listen(parseInt(process.argv[2]));

const loopFn = async () => {
  console.time('fetchSockets');
  await io.fetchSockets();
  console.timeEnd('fetchSockets');    
}
setInterval(loopFn, 1000);

Execute a single instance (i.e. node server.js 3000), and timing on fetchSockets() is generally 0.05ms or quicker. Bringing up a second instance (i.e. node server.js 3001 in a new console) causes this to immediately spike to ~200ms.

Note that I do not see the same behavior when using @socket.io/redis-adapter

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions