spdy-http2 / node-spdy

SPDY server on Node.js
2.81k stars 196 forks source link

SPDY slowing down requests? #156

Closed ghost closed 10 years ago

ghost commented 10 years ago

I can't for the life of me figure out if it's my fault or a bug with the node-spdy module. In short, https responds within ~50 milliseconds of every API request, while spdy takes ~250 milliseconds.

I'm not really doing anything too fancy, just a few simple GET requests to the server API. I've eliminated all the possibilities and narrowed it down to the usage of the spdy module; i.e., all I've done so far is essentially replaced the https module with the spdy one. I'm using Express with Node v0.10.21.

I've tried everything I could think of over the past few hours. Am I missing some important configuration detail?

var https = require('spdy'), //require('https'),
    server = https.createServer({
        key: fs.readFileSync(key),
        cert: fs.readFileSync(crt),
        ca: fs.readFileSync(pem)
    }, app).listen(serverPort);
indutny commented 10 years ago

May I ask you how you are measuring the response time?

ghost commented 10 years ago

Chrome's inspector.

ghost commented 10 years ago

Man, I was really hoping I'd be able to get this working well! I'd rather not have to put something in front of node for SPDY support. Any idea what the issue could be?

indutny commented 10 years ago

I think you are probably doing following thing:

  1. Starting https server
  2. Opening browser and measuring speed of the page
  3. Restarting server as spdy
  4. Refreshing page and seeing 250ms response time

Is it correct? If so - could you please try refreshing it second time? I'm afraid that 250ms is totally unrelated to spdy and is in fact TLS/SSL handshake that is performed in case of both https and spdy.

ghost commented 10 years ago

It's still over 250ms after refreshing multiple times. It actually seems like the first few requests upon refreshing are pretty quick (50ms), and then each request afterward is slowed (250ms), no matter what type of request. Although actions performed via websockets feel normal (50ms).

On Thu, May 1, 2014 at 6:56 PM, Fedor Indutny notifications@github.comwrote:

I think you are probably doing following thing:

  1. Starting https server
  2. Opening browser and measuring speed of the page
  3. Restarting server as spdy
  4. Refreshing page and seeing 250ms response time

Is it correct? If so - could you please try refreshing it second time? I'm afraid that 250ms is totally unrelated to spdy and is in fact TLS/SSL handshake that is performed in case of both https and spdy.

— Reply to this email directly or view it on GitHubhttps://github.com/indutny/node-spdy/issues/156#issuecomment-41966434 .

indutny commented 10 years ago

I'm afraid that this is just a timing issue with handshakes and web inspector, it appears to be much faster on my computer and servers where I am using it. If you could supply a test case that will demonstrate the problem using internal SPDY client or at least spdycat - I'd reopen the issue.

Sorry, closing it for now! I'd just recommend you to ignore page response time for now and take a look at how fast all other resources are loaded.

Cheers.