Q: Running multiple socket.io server in NextJS Hello after taking a look at the Chapter 7 of this article I think I need to run multiple socket.io server instances to efficiently use the resources of my server.
How can I achieve this? At the moment this is the following code of my socket.io server in NextJS:
import { Server } from "socket.io";

export default async function SocketHandler(req: any, res: any) {
    if (res.socket.server.io) {
        return res.end();
    }

    const io = new Server(res.socket.server);
    res.socket.server.io = io;

    io.on("connection", async (socket) => {

        socket.on("disconnect", async () => {
            io.socket.emit("user-disconnected");
        });
    });

    res.end();
}

