FAQ
Dear all

i'm experiencing some performance-gap using http-proxy.

I've got a very simple server that does the following:

var http = require('http');
var httpProxy = require('http-proxy');
var proxy = httpProxy.createProxyServer({});


var server = http.createServer(function(req, res) {
    proxy.web(req, res, {
        target : 'http://127.0.0.1:19007'
    });
});

server.listen(19081);


if i test my server with:

ab -c 100 -n 10000
http://foo:19081/data/_8d51df079d51bc090dc2307310b474fc_CONTENT

i have:
Requests per second: 553.79 [#/sec] (mean)
Time per request: 180.575 [ms] (mean)
Time per request: 1.806 [ms] (mean, across all concurrent requests)
Transfer rate: 36467.65 [Kbytes/sec] received


but if try to go directly to the port 19007 (served by apache):

ab -c 100 -n 10000
http://foo:19007/data/_8d51df079d51bc090dc2307310b474fc_CONTENT

i have:
Requests per second: 1713.75 [#/sec] (mean)
Time per request: 58.352 [ms] (mean)
Time per request: 0.584 [ms] (mean, across all concurrent requests)
Transfer rate: 112853.17 [Kbytes/sec] received

i've tried also to enable cluster and fork some more process in the nodejs
script but i'm not able to take over ~700 req/sec.

Can you help me to figure it out ?

- is a problem of implementation of my simple proxy ?
- is a "normal" gap ?
- maybe http-proxy has too many features and in this scenario i need
something lighter and faster ?

Thanks to all in advance

--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/0c427804-eda3-4345-ad32-eb106080c5cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Nik600 at Nov 21, 2014 at 1:43 pm
    A couple of additional info:

    i've tried also with a different set-up of the proxy object:

    var http = require('http');
    var httpProxy = require('http-proxy');

    httpProxy.createProxyServer({target:'http://127.0.0.1:19007'}).listen(19081);


    but performances are the same

    just to compare the overhead of a proxy interface i've tried to setup the
    same feature with nginx and i have ~1500 req/sec


    --
    Job board: http://jobs.nodejs.org/
    New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
    Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    To post to this group, send email to nodejs@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/e45e5b4f-4fb5-40b0-9820-4b148d40685d%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Ryan Graham at Nov 23, 2014 at 7:27 am

    On Fri, Nov 21, 2014 at 2:40 AM, nik600 AT 10^100 wrote:

    Dear all

    i'm experiencing some performance-gap using http-proxy.

    I've got a very simple server that does the following:

    var http = require('http');
    var httpProxy = require('http-proxy');
    var proxy = httpProxy.createProxyServer({});


    var server = http.createServer(function(req, res) {
    proxy.web(req, res, {
    target : 'http://127.0.0.1:19007'
    });
    });

    server.listen(19081);

    First the general recommendation:

    Is this an accurate representation of what your real proxy will be doing?
    If it is, and performance is a real concern, you should probably look at
    using something like NGINX for your proxying instead of using Node.

    If writing your own proxy really is necessary, then there are some things
    to look at.

    From a quick scan of the http-proxy README, I see that it has an agent
    option that is uses internally for http.request(). This strongly suggests
    to me that you will run into issues with the default
    http.globalAgent.maxSockets being 5.

    Try adding something like the following to your proxy code above:

    http.globalAgent.maxSockets = 50;

    You'll want to play around with different values to see which gives you the
    best performance for your request sizes and durations.

    ~Ryan
    --
    http://twitter.com/rmgraham

    --
    Job board: http://jobs.nodejs.org/
    New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
    Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    To post to this group, send email to nodejs@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/CAGjmZGwK3iSAeY%3DAt3j1Y7EwBViiba9qM%2BjXoG6BBE9y-FFOmw%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupnodejs @
categoriesnodejs
postedNov 21, '14 at 1:24p
activeNov 23, '14 at 7:27a
posts3
users2
websitenodejs.org
irc#node.js

2 users in discussion

Nik600: 2 posts Ryan Graham: 1 post

People

Translate

site design / logo © 2022 Grokbase