I’m trying to bulkinsert some existing data from a RDMS into couchbase through Sync Gateway REST API and sync them with mobile clients (Xamarin).
Performance is terrible, so I’ve set up a simple test - insert 1000 small documents
string json =
@"{
""Code"": "":Code"",
""Name"": ""Product description""
}";
for (int i = 0; i < 1000; i++) {
string DocId = "BulkInsertTest::" + Guid.NewGuid().ToString();
var request = new RestRequest(DocId, Method.PUT);
request.JsonSerializer.ContentType = "application/json";
request.AddParameter("application/json", json, ParameterType.RequestBody);
json = json.Replace(":Code", i.ToString());
IRestResponse response = new RestClient(URL).Execute(request);
}
The code above takes more than a minute to complete, i.e. I can only manage 15 inserts per second.
Is this the normal performance I should expect?
All the setup is running on a single PC, pretty decent HW - SSD, 16Gb RAM, i7 cpu.
Thanks in advance!
Edit.
I tried to bypass the Sync Gateway and test insert performance of Couchbase.
I’ve run this code:
var config = new ClientConfiguration(); config.Servers = new List<Uri> { new Uri("http://localhost:8091") }; config.BucketConfigs.FirstOrDefault().Value.BucketName = "MyTestBucket"; config.UseSsl = false; ClusterHelper.Initialize(config); bucket = ClusterHelper.GetBucket("MyTestBucket"); for (int i = 0; i < 1000; i++) { Document<Product> doc = new Document<Product>() { Content = new Product() { Code = i.ToString(), Name = "Product description" }, Id = "BulkInsertDirect::" + Guid.NewGuid().ToString() }; var res = bucket.Upsert<Product>(doc); }
And it took 76 seconds to complete. That’s about 15 inserts per second?!
I’m stumbled.
Please, give me a hint - is this the normal / expected performance of the product and there is no need to further test or try to optimize?