我们正在尝试使用 ServiceStack 包装器在 Redis 中存储一些大缓冲区(每个 8MB)。我们使用“RedisNativeClient.Set(string key, byte[] value)” API 来设置缓冲区。客户端和服务器都驻留在同一台机器上。坚持残疾人。我们目前正在使用 ServiceStack 的评估版。
问题是我们的性能很差——大约 60 MB/秒。使用一些不同的 c# 包装器(“Sider”),我们可以获得更好的性能(~400 MB/秒)。
我用于测量的代码:
public void SimpleTest()
{
Stopwatch sw;
long ms1, ms2, interval;
int nBytesHandled = 0;
int nBlockSizeBytes = 8000000;
int nMaxIterations = 5;
byte[] pBuffer = new byte[(int)(nBlockSizeBytes)];
// Create Redis Wrapper
ServiceStack.Redis.RedisNativeClient m_serviceStackRedisClient = new ServiceStack.Redis.RedisNativeClient();
// Clear DB
m_serviceStackRedisClient.FlushAll();
sw = Stopwatch.StartNew();
ms1 = sw.ElapsedMilliseconds;
for (int i = 0; i < nMaxIterations; i++)
{
m_serviceStackRedisClient.Set("eitan" + i.ToString(), pBuffer);
nBytesHandled += nBlockSizeBytes;
}
ms2 = sw.ElapsedMilliseconds;
interval = ms2 - ms1;
// Calculate rate
double dMBPerSEc = nBytesHandled / 1024.0 / 1024.0 / ((double)interval / 1000.0);
Console.WriteLine("Rate {0:N4}", dMBPerSEc);
}
可能是什么问题?
谢谢,伊坦。