got around 4000r/s

This commit is contained in:
Radu Ioan Fericean
2012-01-25 19:03:58 +02:00
parent 4e04267291
commit d7d774eef3
6 changed files with 15 additions and 27 deletions

View File

@@ -28,7 +28,7 @@ func callRater(key string) (reply string) {
log.Printf("Got en error from rater: %v", err)
}
}
log.Print(fmt.Sprintf("Result: %v", reply))
//log.Print(fmt.Sprintf("Result: %v", reply))
return
}

View File

@@ -32,7 +32,10 @@ func (rl *RaterList) RegisterRater(clientAddress string, replay *byte) error {
}
rl.Clients[clientAddress] = client
log.Print(fmt.Sprintf("Rater %v registered succesfully.", clientAddress))
rl.balancer_mutex.Unlock()
if len(rl.Clients) == 1 {
// unlock the balancer on first rater
rl.balancer_mutex.Unlock()
}
return nil
}
@@ -54,8 +57,8 @@ func (rl *RaterList) startBalance() {
go func(){
for {
rl.balancer_mutex.Lock()
for addr, client := range rl.Clients {
log.Printf("using server %s:", addr)
for _, client := range rl.Clients {
//log.Printf("using server %s:", addr)
rl.Balancer <- client
}
if len(rl.Clients) != 0 {

View File

@@ -29,10 +29,10 @@ func (s *Storage) Get(args string, reply *string) (err error) {
func main() {
flag.Parse()
//getter, err := NewKyotoStorage("storage.kch")
//defer getter.Close()
getter, err := NewRedisStorage("tcp:127.0.0.1:6379")
getter, err := NewKyotoStorage("storage.kch")
defer getter.Close()
//getter, err := NewRedisStorage("tcp:127.0.0.1:6379")
//defer getter.Close()
if err != nil {
log.Printf("Cannot open storage file: %v", err)
os.Exit(1)

View File

@@ -1,18 +0,0 @@
package main
import (
"net/rpc"
"fmt"
)
func main(){
client, _ := rpc.DialHTTPPath("tcp", "localhost:2000", "/rpc")
var reply string
for i:= 0; i < 5 * 10e6; i++ {
client.Call("Responder.Get", "test", &reply)
}
fmt.Println(reply)
}

Binary file not shown.

View File

@@ -9,8 +9,11 @@ import (
func main(){
client, _ := rpc.DialHTTPPath("tcp", "localhost:2000", "/rpc")
var reply string
client.Call("Responder.Get", "test", &reply)
fmt.Println(reply)
i:= 0
for ; i < 5 * 10e4; i++ {
client.Call("Responder.Get", "test", &reply)
}
fmt.Println(i, reply)
}