hostproxy

96 views
Skip to first unread message

Mikeal Rogers

unread,
Apr 19, 2013, 4:57:59 PM4/19/13
to nod...@googlegroups.com
Time for another log on the "http proxy" bonfire.

I've been poking at this problem a long time and I think I may have cracked it.

Node should have the fastest HTTP load balancer, and it doesn't currently. The fastest open source HTTP balancer I know of is haproxy in TCP mode (does not fully parse HTTP). I've taken the same approach, not parsing HTTP, and pushed the first release today of hostproxy (https://github.com/mikeal/hostproxy).

hostproxy does not parse HTTP, it doesn't even parse headers other than host. It gives you an API to return a stream that the incoming connection will be piped to along with an API for inserting new headers (like x-forwarded-for).

var hostproxy = require('hostproxy')
  , net = require('net')
  ;

hostproxy(function (host) {  
  if (host === 'mysite.com') return net.connect(80, 'mysite.com')
  return net.connect(80, 'fallback.com')
}).listen(80)

There is still plenty of optimizing to be done. Lots of return early functions that aren't inlined and a few copies buffer copies that could get factored out but until I have a good way of benchmarking it I'm not comfortable poking at it. If people have some good benchmarking systems setup I'd love to know how it performs next to haproxy in TCP mode.

-Mikeal

Arnout Kazemier

unread,
Apr 19, 2013, 5:04:54 PM4/19/13
to nod...@googlegroups.com
Isn't this more or less the same as bouncy? https://github.com/substack/bouncy
Also, HAProxy doesn't need to run TCP mode, it parses HTTP as you can select
different backends based on hostnames or paths.
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: 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 post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
 
---
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+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Mikeal Rogers

unread,
Apr 19, 2013, 5:08:53 PM4/19/13
to nod...@googlegroups.com
HAProxy has a TCP mode and HTTP mode, TCP mode is much faster.

Bouncy parses HTTP it just uses a minimal pure JavaScript parser which, last time i checked, wasn't faster than the node's HTTP parser but does support some offset information that is needed for header injection.

-Mikeal

substack

unread,
Apr 20, 2013, 1:20:22 AM4/20/13
to nod...@googlegroups.com
> Bouncy parses HTTP it just uses a minimal pure JavaScript parser which, last time i checked,
> wasn't faster than the node's HTTP parser but does support some offset information that is
> needed for header injection.

In version 3 bouncy switched back to using the core http module but it exposes the raw underlying tcp stream.
hostproxy is still useful since it fulfills a slightly different niche.

Mikeal Rogers

unread,
Apr 20, 2013, 4:59:22 PM4/20/13
to nod...@googlegroups.com
Oh yeah, i forgot one detail. hostproxy *only* works on 0.10 :) I used the streams API exclusively to see what it was like.

On Apr 19, 2013, at 9:40PM, Matthias Götzke <mgt...@gmail.com> wrote:

> It would be awesome if it also parsed the URL..
>
> We tried bouncy before , but it is not compatible with 0.10
>
> Also we are looking for support of keep alive, https / spdy / websockets so the proxy would have to know the SSL key,cert of the backends...
>
> I believe that might not be possible, but I will try with your project...
>
> Test example is proxying ntlm authentication or spdy...
>
> Great that the community has not given up on proxy 😊

Arunoda Susiripala

unread,
Apr 20, 2013, 5:18:49 PM4/20/13
to nod...@googlegroups.com
why not readable-streams use for 0.8 ?

Mikeal Rogers

unread,
Apr 20, 2013, 5:22:17 PM4/20/13
to nod...@googlegroups.com
pure laziness :)

Arunoda Susiripala

unread,
Apr 20, 2013, 9:08:30 PM4/20/13
to nod...@googlegroups.com
Ha ha. :) 
Reply all
Reply to author
Forward
0 new messages