To view parent comment, click here.
To read all comments associated with this story, please click here.
"BTW do you know any other optimization tricks?"
I'd be happy to take a look, can you post a link to your latest code?
As far as documentation, check out http://golang.org/pkg/
Specifically regarding headers: http://golang.org/pkg/net/http/#Header
Nothing special, just:
GOMAXPROCS=4
hello.go ----------------------------------------------
package main
import (
"net/http"
"fmt"
"strconv"
)
var hellostr string="HelloWorld"
var hellolen string=strconv.Itoa(len(hellostr))
func handler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain; charset=UTF-8")
w.Header().Set("Content-Length", hellolen) // this icreases server performance 2x ,from 11kRPS to 22k RPS (requests per second)
fmt.Fprintf(w, hellostr);
}
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8080", nil)
}
---------------------------------------------------





Member since:
2011-04-23
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).