2019-09-08
2436
#node
Fernando Doglio
5657
Sep 8, 2019 ⋅ 8 min read

Writing a working chat server in Node

Fernando Doglio Technical Manager at Globant. Author of books and maker of software things. Find me online at fdoglio.com.

Recent posts:

the replay oct 15 graphic

The Replay (10/15/25): AI’s accessibility problem, React 19.2, and more

Discover what’s new in The Replay, LogRocket’s newsletter for dev and engineering leaders, in the October 15th issue.

Matt MacCormack
Oct 15, 2025 ⋅ 34 sec read
AI has an accessibility problem: What devs can do about it

AI has an accessibility problem: What devs can do about it

Jemima Abu examines where AI falls short on accessibility and how we can best harness AI while still building products that everyone can use.

Jemima Abu
Oct 15, 2025 ⋅ 10 min read

Want to run your AI model locally? Here’s what you should know

Cloud AI made scaling easy, but local AI brings control, cost stability, and data privacy. Explore the hardware realities, tradeoffs, and strategies shaping this shift.

Clara Ekekenta
Oct 15, 2025 ⋅ 6 min read

Stop writing REST APIs from scratch in 2025

Writing REST APIs by hand is a thing of the past. Frameworks like tRPC, Fastify, and Hono eliminate boilerplate with schema-driven design, improving speed and safety.

Ikeh Akinyemi
Oct 14, 2025 ⋅ 3 min read
View all posts

3 Replies to "Writing a working chat server in Node"

  1. This is a nice breakdown of Socket chat servers. I’m currently doing something similar on a personal project. I also have events emitted when a user sends a friend request, accepts the request, etc.

    Do you recommend storing that Socket instance to user ID map in a service like Redis? I’m thinking of ways to scale up my current implementation.

  2. Hey O. Okeh, thanks for reading!
    In regards to your question, it depends. If what you’re looking for is scaling up to accommodate more users, you need more instances running. +
    I’m assuming you’ve created a dedicated chat service, which you should be able to clone.Then storing session information in Redis will help you more than storing the socket instance-user id map, because that way, your services can remain stateless, and clients can connect to any copy of your service (and any service will have access to the shared memory that Redis represents) without without losing session data.

    So my recommendation would be to use Redis as a shared memory if that is what you need, and keep cloning your chat services with a possible load balancer in front of them.

Leave a Reply