RavenDB long response time for query, while was processed on server very fast
Question
Raven.Server started and binded to port 8022. I initialize DataStore in the following way:
var store = new DocumentStore() { Url = "http://localhost:8022" };
store.Initialize();
Then i'm making such query:
using (var session = store.OpenSession())
{
Stopwatch watch = new Stopwatch();
watch.Start();
var result = session.LuceneQuery<Item>("Raven/DocumentsByEntityName")
.WhereEquals("Tag", "Items")
.ToList();
watch.Stop(); // watch.ElapsedMilliseconds == ~550 ms
return result;
}
And watch.ElapsedMilliseconds
is always ~550 ms.
But when i look to RavenDB console i see that query was processed in 3 ms:
Request # 170: GET - 3 ms - 200 - /indexes/Raven/DocumentsByEntityName?query=Tag%253A%255B%255BItems%255D%255D&start=0&pageSize=128
Thus ~ 99.5% of time have been spent not in RavenDB. What is the problem? (RavenDB 147)
When i switch to self-hosting of RavenDB (i.e. as embedded client) everything is okay (~3ms).
To clarify that issue not in network, http debuggers, dns servers etc. i also tested this:
Stopwatch watch = new Stopwatch();
watch.Start();
WebClient client = new WebClient();
var result = client.DownloadString("http://127.0.0.1:8022/indexes/Raven/DocumentsByEntityName?query=Tag%253A%255B%255BItems%255D%255D&start=0&pageSize=128");
watch.Stop(); // watch.ElapsedMilliseconds == ~3-10ms
Fast. But switching to Raven.Client.Lightweight increase response time in 200 times (550-600 ms)
Solution
Problem was because of middleman on my computer - NOD32. If you are also using it - uncheck the following checkbox:
Setup -> Advanced setup -> Antivirus and antispyware -> Protocol filtering -> "Enable application protocal content filtering"
Simple disabling of antivirus or firewall doesn't help!
OTHER TIPS
Maybe nitpicking and maybe just a typ-o but sometimes the silliest things can drive us nuts;
your statement:"Raven.Server started and binded to port 8082. I initialize DataStore in the following way:"
your code example reads: "var store = new DocumentStore() { Url = "http://localhost:8022" };"
the port in your title is 8082 and the port in your example is 8022.
I realize your typ-o may not be in your actual code but it never hurts to check.
'm jus' sayin'
P