Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance issues with chunked response #20

Open
darklow opened this issue Jan 12, 2012 · 3 comments
Open

Performance issues with chunked response #20

darklow opened this issue Jan 12, 2012 · 3 comments

Comments

@darklow
Copy link

darklow commented Jan 12, 2012

We are building autocompletion using nodejs, sphinx and trying out limestone.

Autocompletion containts only 6 items
Everything works perfect except one performance issue.

When searching we use limit: 6, so we need quite small amount of data to return.
Sphinx returns results in average time from 1 - 9ms

However with header Transfer-Encoding': 'chunked. it takes browser 180-200 ms to receive data. And it is huge time loss for us.
If i turn off chunked header, then browser recieved data in 10-16ms, which id perfect and desired result, but the response is not complete if headers ar not specified as chunked.

If i take full response data as string from chunked result and send it directly as body, then it also takes 10-16ms. So the problem is definately in that chunked data output or buffering.

Is there any way to output straight and not chunked data for small amounts of items? Otherwise these 180-200ms are huge performance loss for us.

Thanks

@darklow
Copy link
Author

darklow commented Jan 12, 2012

Well after lot of debugging finaly found nodejs parameter and it resolved all the chunk and performance issues

response.chunkedEncoding = false;

If there are no comments on this, please close issue and sorry for bothering :)
Thanks for such a great code!

@JoeZ99
Copy link
Contributor

JoeZ99 commented Jan 13, 2012

@darklow I'm on a somehow similar thing. That thing about the "chunks", never heard of it, but I'll check and maybe I can gain a few ms , too!

@darklow
Copy link
Author

darklow commented Jan 13, 2012

If anyone is interested here is how i got performance i wanted, avoiding chunked response. Now it takes maximum 10-15ms until request is received by browser:

  1. Set chunkedEncoding= false, so that it don't use chunked encoding
response.chunkedEncoding = false;
  1. Don't specify header:
    'Transfer-Encoding': 'chunked'

  2. For content-length header use: buffer.byteLength and not data.length:

var buffer = require('buffer');
...
"Content-Length": buffer.Buffer.byteLength(data, 'utf8'),

This works if you have small amount of data, i guess if you have lot of data, then chunked encoding might be faster

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants