My business is like below:
.Net Client(WinFrom Application) send request to a Socket Server (implement by IOCP), and when each request was received in Socket Server side, then Server will get the document from Couchbase. But I found that there is a low performance. At first, It only 1~2 request can be processed in Server side, Some time later the performance was increased, and it will be faster and faster.
If without get document from Couchbase, Socket Server will process 10000+ request per second.
It is my code:
public class CouchbaseAccess
{
private static string _server = string.Empty;
private static string _bucketName = string.Empty;
private static string _userName = string.Empty;
private static string _password = string.Empty;
private static IBucket _bucket = null;
static CouchbaseAccess()
{
_server = "http://127.0.0.1:8091/";
_bucketName = "default";
_userName = "";
_password = "";
Initialize();
}
public static void Initialize()
{
var config = new ClientConfiguration();
config.BucketConfigs.Clear();
config.Servers = new List<Uri>(new Uri[] { new Uri(_server) });
config.BucketConfigs.Add(
_bucketName,
new BucketConfiguration
{
BucketName = _bucketName,
Username = _userName,
Password = _password,
PoolConfiguration = new PoolConfiguration
{
MaxSize = 5,
MinSize = 2,
SendTimeout = 12000,
BufferSize = 1024
}
});
ClusterHelper.Initialize(config);
_bucket = Bucket();
}
private static CouchbaseAccess instance = null;
public static CouchbaseAccess Instance
{
get
{
if (instance == null)
{
instance = new CouchbaseAccess();
}
return instance;
}
}
public static IBucket Bucket()
{
return ClusterHelper.GetBucket(_bucketName);
}
public static IBucket Bucket(string bucketName)
{
return ClusterHelper.GetBucket(bucketName);
}
public IOperationResult<byte[]> Get(string key)
{
return _bucket.Get<byte[]>(key);
}
public byte[] GetDocument(string key)
{
IDocumentResult<byte[]> documentResult = _bucket.GetDocument<byte[]>(key);
return documentResult.Content;
}
}
Cloud you please can help me out?
Thank you in advance