go を使用して redis と aerospike のパフォーマンスと実装を少し比較しようとしていますが、私の aerospike コードで「コマンドの実行がタイムアウトしました」というメッセージが表示されます。しばらくするとエラー。
サイトに従って aerospike サーバーをインストールしました。go クライアントで提供されたベンチマークはエラーなしで動作するので、コードで何か間違ったことをしている可能性がありますか?
でテストを実行します
-bench="1AerospikeCounter" -benchtime 30s -cpu=1 -parallel=1
ロギングを有効にすると、これが出力されます。PutObject の後のエラー チェックでパニックが発生します。
2015/05/14 10:20:55 Connection to address `127.0.0.1:3000` failed to establish with error: dial tcp 127.0.0.1:3000: cannot assign requested address
2015/05/14 10:20:55 Node BB9DC1A8E565000 127.0.0.1:3000: dial tcp 127.0.0.1:3000: cannot assign requested address
panic: command execution timed out.
goroutine 20 [running]:
backend/gateway/core/database.UpdateWithDelta(0xc218aeea20, 0x60c7c, 0x3fde23dba43075e1, 0xc221f181d0, 0x0, 0x0)
/root/go/src/backend/gateway/core/database/database_test.go:247 +0x294
私のコードは次のようになります
type Counter struct {
Id int
Pop float64
}
func Benchmark2AerospikeCounter(b *testing.B) {
logger.Logger.SetLevel(logger.INFO)
clientPolicy := aerospike.NewClientPolicy()
asclient, err := aerospike.NewClientWithPolicy(clientPolicy, "127.0.0.1", 3000)
if err != nil {
b.Fatal(err)
}
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
x := rand.Intn(1000000)
y := rand.Float64()
delta := Counter{Id: x, Pop: y}
_, err := UpdateWithDelta(asclient, delta)
if err != nil {
b.Fatal(err)
}
}
})
}
func UpdateWithDelta(client *aerospike.Client, delta Counter) (*Counter, error) {
key, err := aerospike.NewKey("test", "counters", delta.Id)
oldCounter := &Counter{}
err = client.GetObject(client.DefaultPolicy, key, oldCounter)
if v, ok := err.(types.AerospikeError); ok {
if v.ResultCode() != types.KEY_NOT_FOUND_ERROR {
return nil, err
}
} else if err != nil {
return nil, err
}
newCounter := &Counter{
Id: delta.Id,
Pop: oldCounter.Pop + delta.Pop,
}
err = client.PutObject(client.DefaultWritePolicy, key, newCounter)
if err != nil {
panic(err)
}
return newCounter, err
}
仮想化された CentOS ボックスで実行し、基本的な aerospike のインストール手順に従い、開始しました。データベースを別のマシンに配置すると、同じエラーが発生することに注意してください。
ps。aerospike の誰かが読んでいる場合: フォーラムで Google にサインアップすることはできないようです。