To view parent comment, click here.
To read all comments associated with this story, please click here.
So I'm looking at your programs, are they both being called when someone navigates to the URL? Or are you just statically servering the .c file (which would make no sense)?
If some kind of CGI is running your C program, then it is doing less work:
puts("Hello World!\n");
VS.
fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])
Your Go program should be:
fmt.Print("Hello World!\n")
Also, I assume whatever CGI is running your C program is not using chunking, so you should set your Go response to also not use chunking... I also assume the C CGI is not putting the date/time in the response header, go is by default to you should tell it not to.
Sorry posted a wrong code the correct one is:
fmt.Fprintf(w, "Hello World")
Result is correct. You can see it in this line:
Document Length: 11 bytes
fmt.Pritf() prints into terminal, not to response string.
I run test again with original hello code and result was (req per second):
10441.31 [#/sec] (mean)
VS
10038.96 [#/sec] (mean) (old)
Almost the same.
Im using http://gwan.ch/ (G-WAN) as a C servlet server.
Edited 2012-03-29 23:36 UTC
Without chunking:
19k RPS. not bad, but still below level of ecceptance.
330% diference. I could accept 50% max
Incresed CPU time = wasted money.
Both response headers:
--------------------------------------------------- C Serv
HTTP/1.1 200 OK
Server: G-WAN
Date: Thu, 29 Mar 2012 23:47:36 GMT
Last-Modified: Thu, 29 Mar 2012 23:47:36 GMT
Etag: "441d9cc1-4f74f498-b"
Vary: Accept-Encoding
Accept-Ranges: bytes
Content-Type: text/html; charset=UTF-8
Content-Length: 11
Connection: Keep-Alive
---------------------------------------------------- Go
HTTP/1.1 200 OK
Content-Length: 11
Content-Type: text/plain
Date: Fri, 30 Mar 2012 01:16:24 GMT
----------------------------------------------------------
BTW do you know any other optimization tricks?
Another thing is a heavy lack of documentation. I wasted a lot of time just to find how to write to header. Yes, Id found it but in some other part of internet. At least their search engine is fine (Google).





Member since:
2011-04-23
Not that kind of benchmark.
I did some testing using ApacheBench.
I manually managed to go up to 10k RPS for Go (setting up number of cores). But all this is still too slow (7 times slower).
http://pokazywarka.pl/aiuo77/