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

Terrible performace with Keep-Alive #346

Closed
xkrt opened this issue Dec 4, 2015 · 9 comments
Closed

Terrible performace with Keep-Alive #346

xkrt opened this issue Dec 4, 2015 · 9 comments

Comments

@xkrt
Copy link
Contributor

xkrt commented Dec 4, 2015

Hi guys! I think I found a problem with Keep-Alive.

Test server:

open System
open System.Net
open Suave
open Suave.Types
open Suave.Http
open Suave.Http.Applicatives
open Suave.Http.Successful

let config = { Web.defaultConfig with bindings = [ HttpBinding.mk HTTP IPAddress.Any 6001us ] }
let data = String('x', 1024)

let app = GET >>= path "/" >>= (fun x -> printf "."; OK data x)

[<EntryPoint>]
let main _ =
    do Web.startWebServer config app
    Console.ReadLine() |> ignore
    printfn "done"
    0

Run Apache benchmark (from Windows 7) without Keep-Alive:

>ab -c 10 -n 1000 http://remote-host:6001/
...
Concurrency Level:      10
Time taken for tests:   0.882 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      1169000 bytes
HTML transferred:       1024000 bytes
Requests per second:    1133.67 [#/sec] (mean)
Time per request:       8.821 [ms] (mean)
Time per request:       0.882 [ms] (mean, across all concurrent requests)
Transfer rate:          1294.20 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   0.4      1       2
Processing:     1    8   1.0      8      11
Waiting:        0    4   2.1      4      10
Total:          2    9   1.0      9      12

Percentage of the requests served within a certain time (ms)
  50%      9
  66%      9
  75%      9
  80%     10
  90%     10
  95%     10
  98%     11
  99%     11
 100%     12 (longest request)

Most important line: Requests per second: 1133.67 [#/sec] (mean)

Now lets run with Keep-Alive (-k):

>ab -k -c 10 -n 1000 http://remote-host:6001/
...
Concurrency Level:      10
Time taken for tests:   20.305 seconds
Complete requests:      1000
Failed requests:        0
Keep-Alive requests:    1000
Total transferred:      1193000 bytes
HTML transferred:       1024000 bytes
Requests per second:    49.25 [#/sec] (mean)
Time per request:       203.050 [ms] (mean)
Time per request:       20.305 [ms] (mean, across all concurrent requests)
Transfer rate:          57.38 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       2
Processing:   194  202   3.7    201     212
Waiting:        0    1   0.6      1      10
Total:        194  202   3.7    201     212

Percentage of the requests served within a certain time (ms)
  50%    201
  66%    201
  75%    201
  80%    201
  90%    210
  95%    211
  98%    211
  99%    211
 100%    212 (longest request)

Requests per second: 49.25 [#/sec] (mean)

Note that remote server should be really remote host, on localhost this problem doesnt reproduce for me.

As remote host I was check Windows Server 2012R2 (.NET 4.5) and Ubuntu Server 15.10 with Mono (under docker with mono:latest image).

@xkrt
Copy link
Contributor Author

xkrt commented Dec 4, 2015

Actually this problem reproduces somehow on localhost too (ab should be runned with http://127.0.0.1:6001/, not http://localhost:6001/ on Windows for unkown reason).

Without Keep-Alive I have ~2600 reqs/sec, with Keep-Alive ~1300 reqs/sec.

PS: Suave 0.33, .NET 4.5

@xkrt
Copy link
Contributor Author

xkrt commented Dec 7, 2015

I just found #313.
I think this is same problem and it unrelated to libuv at all.

@haf run tests on Example project, I repeat it, but on remote host and with log level = info.
Server under Windows 2012R2, ab runned under Windows 7.

Without Keep-Alive:

>ab -c 15 -t 20 http://remote-host:8082/hello
...
Requests per second:    886.25 [#/sec] (mean)
...

With Keep-Alive:

>ab -k -c 15 -t 20 http://remote-host:8082/hello
...
Requests per second:    73.26 [#/sec] (mean)
...

If I run Example under Linux/Mono I have similar numbers.

Tests was on rev 88a8e6e
I think this is serious problem since all connections are persistent by default since HTTP 1.1

ademar added a commit that referenced this issue Dec 8, 2015
@ademar
Copy link
Member

ademar commented Dec 8, 2015

@xkrt Very interesting. I think a37f7ea solves the issue.

Do you want to give it another try ?

@xkrt
Copy link
Contributor Author

xkrt commented Dec 8, 2015

@ademar great! now with Keep-Alive I have 7879 reqs/sec running Example console! Keep-Alive in action :)

FYI there is a problem running Example with this branch on Windows/.NET: haf/YoLo#1

@ademar
Copy link
Member

ademar commented Dec 8, 2015

Cool.

Regarding the other issue - Don't know if it is the case but the rake build
script will generate the required AssemblyVersionInfo files.

On Tuesday, 8 December 2015, Pavel Martynov notifications@github.com
wrote:

@ademar https://github.com/ademar great! now with Keep-Alive I have
7879 reqs/sec with Example console! Keep-Alive in action :)

FYI there is a problem running Example with this branch on Windows/.NET:
haf/YoLo#1 haf/YoLo#1


Reply to this email directly or view it on GitHub
#346 (comment).

Ademar Gonzalez
+1-647-891-3606
http://ademar.name
https://github.com/ademar

@xkrt
Copy link
Contributor Author

xkrt commented Dec 8, 2015

Ok, I see, I just used build.cmd.

@haf
Copy link
Contributor

haf commented Dec 8, 2015

Yeah, I could extend that code to support assemblies with no version... PR?

@xkrt
Copy link
Contributor Author

xkrt commented Dec 8, 2015

@haf I see you replace Value with getValue() with last YoLo commit, I update YoLo dependency with #349

@haf
Copy link
Contributor

haf commented Dec 8, 2015

Merged! Thank you

@ademar ademar closed this as completed Dec 8, 2015
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

3 participants