Skip to content

Caronte: Non-keepalive requests are proxied as keep-alive requests #477

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

Closed
Rush opened this issue Sep 17, 2013 · 3 comments
Closed

Caronte: Non-keepalive requests are proxied as keep-alive requests #477

Rush opened this issue Sep 17, 2013 · 3 comments

Comments

@Rush
Copy link
Contributor

Rush commented Sep 17, 2013

Please run the example from README:

var http = require('http'),
    caronte = require('./index.js');
//
// Create your proxy server
//
caronte.createProxyServer({target:'http://localhost:9000'}).listen(8000);

//
// Create your target server
//
http.createServer(function (req, res) {
  res.writeHead(200, { 'Content-Type': 'text/plain' });
  res.write('request successfully proxied!' + '\n' + JSON.stringify(req.headers, true, 2));
  res.end();
}).listen(9000);

Please use the tool from apache2-utils package:

# ab2 -v 2 -c 1 -n 1 http://127.0.0.1:8000/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)...INFO: POST header == 

---
GET / HTTP/1.0
Host: 127.0.0.1:8000
User-Agent: ApacheBench/2.3
Accept: */*
                      <---------- no Connection: Close, and no Keep-Alive

---
LOG: header received:
HTTP/1.1 200 OK
content-type: text/plain
date: Tue, 17 Sep 2013 08:44:19 GMT
connection: keep-alive
transfer-encoding: chunked

90
request successfully proxied!
{
  "host": "127.0.0.1:8000",
  "user-agent": "ApacheBench/2.3",
  "accept": "*/*",
  "connection": "keep-alive"   <--------- server got Keep-Alive so it is waiting
}

<IT HANGS IN HERE WAITING>

With -k option in ab2 you may see it properly (well, almost - but this would be another issue) working as it sets keep alive in the initial header:

# ab2 -v 2 -c 1 -n 1 -k http://127.0.0.1:8000/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)...INFO: POST header == 

---
GET / HTTP/1.0
Connection: Keep-Alive
Host: 127.0.0.1:8000
User-Agent: ApacheBench/2.3
Accept: */*


---
LOG: header received:
HTTP/1.1 200 OK
content-type: text/plain
date: Tue, 17 Sep 2013 08:53:36 GMT
connection: keep-alive
transfer-encoding: chunked

90
request successfully proxied!
{
  "connection": "Keep-Alive",
  "host": "127.0.0.1:8000",
  "user-agent": "ApacheBench/2.3",
  "accept": "*/*"
}

..done


Server Software:        
Server Hostname:        127.0.0.1
Server Port:            8000

Document Path:          /
Document Length:        150 bytes

Concurrency Level:      1
Time taken for tests:   0.003 seconds
Complete requests:      1
Failed requests:        0
Write errors:           0
Keep-Alive requests:    1
Total transferred:      284 bytes
HTML transferred:       150 bytes
Requests per second:    323.94 [#/sec] (mean)
Time per request:       3.087 [ms] (mean)
Time per request:       3.087 [ms] (mean, across all concurrent requests)
Transfer rate:          89.84 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:     3    3   0.0      3       3
Waiting:        3    3   0.0      3       3
Total:          3    3   0.0      3       3
@yawnt
Copy link
Contributor

yawnt commented Sep 17, 2013

yep, sounds about right.. that's what i was thinking as well.. the commit i just pushed (2c10f25) should fix it

i apologize for the late fix... with the tests rewriting going on, i kinda miscalculated the time i had

@Rush
Copy link
Contributor Author

Rush commented Sep 17, 2013

You are very kind and no need to apologize. I am happy it is moving forward. Thank you for your support! Now let's do some testing - I will paste only some noteworthy lines:

Without keep-alive (spoiler: very good!!)

# ab2 -c 1 -n 100 http://127.0.0.1:8000/
Time taken for tests:   0.142 seconds
Complete requests:      100
Failed requests:        0
Requests per second:    804.82 [#/sec] (mean)

Just for the sake of benchmarking (it IS an utterly useless benchmark I know):

# ab2 -c 1 -n 100 http://127.0.0.1:9000/
Requests per second:    4487.73 [#/sec] (mean)

Now the real problem, testing with Keep-Alive:

# ab2 -c 1 -n 100 -k http://127.0.0.1:8000/
Server Software:        
Server Hostname:        127.0.0.1
Server Port:            8000

Document Path:          /
Document Length:        0 bytes

Concurrency Level:      1
Time taken for tests:   1.970 seconds
Complete requests:      100
Failed requests:        48
   (Connect: 0, Receive: 0, Length: 48, Exceptions: 0)
Write errors:           0
Non-2xx responses:      2
Keep-Alive requests:    100
Total transferred:      28900 bytes
HTML transferred:       14450 bytes
Requests per second:    50.77 [#/sec] (mean)
Time per request:       19.697 [ms] (mean)
Time per request:       19.697 [ms] (mean, across all concurrent requests)
Transfer rate:          14.33 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:     0   20  19.5      2      40
Waiting:        0    1   0.6      0       2
Total:          0   20  19.5      2      40
WARNING: The median and mean for the waiting time are not within a normal deviation
        These results are probably not that reliable.

48% of failed requests and very slow response. I hope this helps ...

@yawnt
Copy link
Contributor

yawnt commented Sep 17, 2013

oh wow, that's not good .. i'll look into this.. if you can figure out what's wrong please let me know..
i'm closing this one and opening another issue related to keepalive

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