Created
May 17, 2012 23:01
-
-
Save codeboost/2722169 to your computer and use it in GitHub Desktop.
Source code for test scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"net/http" | |
"log" | |
"fmt" | |
) | |
func main() { | |
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | |
w.Header().Set("Content-Type", "text/plain") | |
fmt.Fprintf(w, "Hello, World\r\n") | |
}) | |
log.Printf("Server running at http://127.0.0.1:1337/") | |
http.ListenAndServe("0.0.0.0:1337", nil) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cluster = require('cluster'); | |
var http = require('http'); | |
var numCPUs = require('os').cpus().length; | |
if (cluster.isMaster) { | |
// Fork workers. | |
for (var i = 0; i < numCPUs / 2; i++) { | |
cluster.fork(); | |
} | |
cluster.on('death', function(worker) { | |
console.log('worker ' + worker.pid + ' died'); | |
}); | |
} else { | |
// Worker processes have a http server. | |
http.Server(function(req, res) { | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
res.end("hello world\n"); | |
}).listen(1338, '0.0.0.0'); | |
} | |
console.log('Server running at http://127.0.0.1:1338/'); |
Not sure how relevant it is, but note that GOMAXPROCS variable used to default to 1.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See
https://gist.github.com/2722254
For results.