Back to articles
Why We Don't Use Socket Connections for Everything

Why We Don't Use Socket Connections for Everything

via Dev.torajat

Sockets (such as TCP sockets or WebSockets) enable persistent, two-way communication between a client and a server. Because of this, they are extremely useful for real-time applications like chat systems, live notifications, and online games. However, in most web applications we do not use socket connections for every request . Instead, many systems still rely on HTTP-based communication . Let’s explore why. 1. Persistent Connections Consume More Resources A socket connection remains open for a long time . Example: Client ⇄ Server The server must maintain this connection in memory and keep track of its state. If a system has 1 million users connected simultaneously , the server must maintain 1 million open connections . This requires: Memory for each connection CPU for connection management File descriptors from the operating system Because of these costs, keeping many persistent connections can become expensive and difficult to scale . In contrast, HTTP connections are usually short-l

Continue reading on Dev.to

Opens in a new tab

Read Full Article
3 views

Related Articles