Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

126
Views
Decision whether to use simple HTTP requests or WebSockets

We are implementing a service which is used by a lot of users in the same time. In peaks we can have tens of thousands of people online.

Critical part of our service needs reimplementation and so we try to think of new ways of doing it. At the moment we send simple and very short/small AJAX HTTP request based on user interaction:

  • Ping: I am still active
  • Activity: I have done this and please write it to the database
  • Finishing: I have finish my activities so close my requests

At the same time, in some case (1 in 10) we have open EventSource from which we read some modifications on the server.

The question is whether this model is good enough or if it is better to open a WebSocket and pass everything via WebSockets.

  • Advantage – for each user we would maintain only one connection instead of sending multiple requests.
  • Disadvantage - when lots of people online, we would keep thousands of connections active

What should be the decision for the right implementation?

It was noted that this question answers the same: WebSockets protocol vs HTTP – however I ask for specific use-case. The related question is rather asked in general.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

  • Disadvantage - when lots of people online, we would keep thousands of connections active

You can implement your service to close idle websocket connection after a timeout. That's probably the same way how EventSource works for you, so you don't keep too many active connections. (Similar performance characteristics.)

(But if you are relying on the automatic reconnection of EventSource provided by the browser, then switching to WebSocket means you need to write more code for the logic of reconnection.)

Typically WebSocket should have less network traffic overhead. But how much difference depends on how your current service is implemented. If you have already optimized your logic and squeezed out every bit of performance with AJAX and EventSource, using WebSocket might be a marginal improvement.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!