Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

socket.io slow response after using nginx

I have used my local setup without nginx to serve my node.js application, I was using socket.io and the performance was quite good.

Now, I am using nginx to proxy my request and I see that socket.io has a huge response time, which means my page is getting rendered fast, but the data rendered by socket.io is order of magnitude slower than before.

I am using NGINX 1.1.16 and here is the conf,

gzip  on;

server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;

    access_log  logs/host.access.log  main;

    location / {
        proxy_pass http://localhost:9999;
        root   html;
        index  index.html index.htm;
    }

Even though everything is working, I have 2 issues,

  1. socket.io response is slower than before. With NGINX, the response time is around 12-15sec and without, it's hardly 300ms. tried this with apache benchmark.

  2. I see this message in the console, which was not there before using NGINX,

    [2012-03-08 09:50:58.889] [INFO] console -    warn  - 'websocket connection invalid'
    
like image 414
user644745 Avatar asked Oct 12 '25 08:10

user644745


1 Answers

You could try adding:

proxy_buffering off;

See the docs for info, but I've seen some chatter on various forums that buffering increases the response time in some cases.

like image 153
Kief Avatar answered Oct 14 '25 09:10

Kief