Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

263
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda