Don't overthink it. 100mb of RAM will get you something like half a million clients.
Don't think the size really matters... an IP is 4 bytes, and the port another byte, plus lets say 4 bytes for the UserId. So with some overhead, you can practically put about 100k addresses in 1 MB.
With that many addresses, you should probably be more concerned about the lookup than the storage. I'd probably put then in a Dictionary[UserId, SocketData].
Websockets don't usually stay alive for long periods, so there's not much point of storing them in a database. Unless you're building something serverless, but then I wouldn't build something myself, but just use Firebase Cloud Messaging instead
Why do you want to store them? I used socket.io in one app and I used channels to manage who gets what but disconnects/reconnects would happen often so I didn't use the connection directly, but emitting messages to clients currently subscribed to a given channel.
Agents log into the dashboard - connect and the server subscribes them to the "agents" channel to which ticket list items messages are emitted. Clicks on a ticket - that's a ticket_id unique channel to which he gets subscribed. Any disconnect/reconnect would create a new connection, the old one is dropped and the agent is once again subscribed to these channels based on where in the dashboard he is in.
Socket.io is abstracting away the client connection details, so is doing the storage itself.
Socket.io might not be available for the chosen language, socket.io might not be suitable for the project, some people want to develop things themselves.
Web Development
Welcome to the web development community! This is a place to post, discuss, get help about, etc. anything related to web development
What is web development?
Web development is the process of creating websites or web applications
Rules/Guidelines
- Follow the programming.dev site rules
- Keep content related to web development
- If what you're posting relates to one of the related communities, crosspost it into there to help them grow
- If youre posting an article older than two years put the year it was made in brackets after the title
Related Communities
- !html@programming.dev
- !css@programming.dev
- !uiux@programming.dev
- !a11y@programming.dev
- !react@programming.dev
- !vuejs@programming.dev
- !webassembly@programming.dev
- !javascript@programming.dev
- !typescript@programming.dev
- !nodejs@programming.dev
- !astro@programming.dev
- !angular@programming.dev
- !tauri@programming.dev
- !sveltejs@programming.dev
- !pwa@programming.dev
Wormhole
Some webdev blogs
Not sure what to post in here? Want some web development related things to read?
Heres a couple blogs that have web development related content
- https://frontendfoc.us/ - [RSS]
- https://wesbos.com/blog
- https://davidwalsh.name/ - [RSS]
- https://www.nngroup.com/articles/
- https://sia.codes/posts/ - [RSS]
- https://www.smashingmagazine.com/ - [RSS]
- https://www.bennadel.com/ - [RSS]
- https://web.dev/ - [RSS]