Re: [Nethttpd-plex] Poor performance on FreeBSD 8.2

Matías Giovannini <[email protected]> Tue, 5 Jul 2011 17:30:16 -0300
Newsgroups gmane.comp.lang.ocaml.lib.net.devel
Message-ID <CALzEXo9AsBX77Pez_jub4xsdJik7+c4TpS6iAF0DjUjjzBnuVw@mail.gmail.com>
Stéphane,
it's odd, as testing the cURL script against a minimal server I get good
throughput:

$ ./curl_test -v -n 1000 'http://127.0.0.1:9999/'
Total time: 0.149 s (6699.49 req/s)
cURL  time: 0.122 s (8206.21 req/s)
successes: 1000/1000

The server code is:

(* $Id: echo_test.ml 84 2011-07-03 15:15:48Z mgiovann $ *)

let buf_len = 1024

let dialog socket =
let send str = ignore (Unix.send socket str 0 (String.length str) []) in
let buf = String.create buf_len in
let _len = Unix.recv socket buf 0 buf_len [] in
send "HTTP/1.0 200 OK\r\n";
send "Content-Length: 0\r\n"

let serve () =
let open Unix in
let server_sock = socket PF_INET SOCK_STREAM 0 in

(* so we can restart our server quickly *)
setsockopt server_sock SO_REUSEADDR true;

(* build up my socket address *)
let address = (gethostbyname "localhost").h_addr_list.(0) in
bind server_sock (ADDR_INET (address, 9999));

(* Listen on the socket. Max of 10 incoming connections. *)
listen server_sock 10;

(* accept and process connections *)
try while true do
let (client_sock, _client_addr) = accept server_sock in
begin try dialog client_sock
with Unix.Unix_error (e, _, _) ->
Printf.eprintf "Error: %s\n%!" (Unix.error_message e)
end;
shutdown client_sock SHUTDOWN_ALL;
close client_sock
done with Unix.Unix_error (e, _, _) ->
Printf.eprintf "Error: %s\n%!" (Unix.error_message e);
shutdown server_sock SHUTDOWN_ALL;
close server_sock

let () = serve ()

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2

_______________________________________________
Ocamlnet-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ocamlnet-devel