Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

265
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda