DEV Community

Cover image for Regular Requests vs. WebSockets
Dmytro Klimenko
Dmytro Klimenko

Posted on

Regular Requests vs. WebSockets

Let’s say you visit a crypto exchange website to check the altcoin price. Normally, your browser sends an HTTP request, gets the price as a response, and that’s it. But while you’re on the page, the price changes, and you have to refresh the page to see the latest value.

WebSockets solve this problem by creating a persistent connection between the client and the server, allowing the server to instantly send updates as soon as something changes.

Basically, it’s like the difference between:
❌ Constantly asking: "Hey, what’s the $WBT price now?"
✅ Simply listening to the server, which tells you: "Hey, the price just updated, here’s the new value!"

Where Are WebSockets Especially Useful?
📌 Crypto exchanges – Prices, orders, and trading volumes must update instantly.
📌 Chats and messengers – Messages should arrive without delays.
📌 Online games – Everything must happen in real-time, not via page refreshes.

And that’s when it hit me: all major crypto exchanges, including OKX, CoinBase, and WhiteBIT, use WebSockets for real-time price updates. Otherwise, imagine looking at an outdated price and placing an order that is no longer relevant – that would be a disaster.

What I Learned About WebSockets?
1️⃣ They’re not as scary as they seem – Implementing them in code is easier than I thought.
2️⃣ They save resources – Instead of endless requests, you have one open connection that just works.
3️⃣ They make working with crypto more efficient – If you're building crypto-related apps, you'll need WebSockets sooner or later.

My Conclusion
If you’re a junior dev like me and you’re still afraid of WebSockets – don’t be. It’s an awesome technology that makes applications faster and more efficient.

The best way to understand them is to try them out! Even a simple WebSockets-based chat or a real-time crypto price feed will give you a clear understanding of how they work – and bring you one step closer to becoming a senior dev!

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay