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

260
Views
Should I use `Express` and `Socket.IO` separately?

For example we have this simple code:

var http = require('http');
var express = require('express');
var app = express();

var server = http.createServer(app);
var io = require('socket.io').listen(server);

server.listen(80);

When / is loaded and start button pressed via socket.io request sent which starts on back-end heavy stuff (lot of different http requests which could be from 5 to 10 sec) and when response comes it immediately are throw back to the browser.

So the main question: should I split the app in to two pieces?

  1. back-end with Socket.IO as one process
  2. front-end with Express as second process

I'm aware that when the long requests comes it will block Express. For example when one user do search for others site will be down while long requests are in progress.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

There is only a definitive answer about one vs. two processes by fully understanding and probably profiling/testing your actual code and clients. If your node.js code (whether regular http requests or socket.io requests) is properly using non-blocking I/O and is not CPU intensive, then you can field a surprisingly high number of requests with a single process. That is a primary advantage of the node.js architecture.

If, on the other hand, you have some heavy CPU-intensive calculation as part of most requests, then you may indeed want to cluster your whole app. I would recommend clustering over splitting socket.io from http because that gives you multiple CPUs to work on either your socket.io requests or your http requests.

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!