Performance issues with NCache queries
I am evaluating NCache for use in the current project as a "pass-through" cache - to offload the load from the SQL server.
On the client side, the project has a polling routine that gets the items filtered (server side) by the last day and day of the poll.
Polling occurs at a fixed interval in a separate thread.
Pseudocode for client side
1) First time pick:
- select all existing items.
- set LastHandledDate now
2) not the first timing (polling flow)
- retrieve existing items created after LastHandledDate
- update LastHandledDate now
On the server side, when a poll request is received, the following pseudocode is executed:
- NCache request for all matching items with CreationDate > = LastHandledDate
- IF query results are empty
- query the SQL database for all matching items with CreationDate > = LastHandledDate
- if the query is not empty, update NCache with the results of the SQL query
- return SQL query results
- ELSE returns the result of an NCache query
To query NCache I use its linq provider and the query is similar to SQL query:
SELECT * FROM Messages WHERE Message.SessionId = 1234 AND Message.EntryDate >= ‘2012-10-6’
Edit: There is a thread during client side testing that adds new items at a constant rate
The server side part is hosted in a web service (WCF in IIS).
After load testing the above 100 client polling setup for an hour, I noticed a steady decline in the number of requests / sec made by the web service.
Doing the above setup with read-only from NCache without reading SQL (no paragraph 2 on pseudocode server side) yields the same rejection pattern in requests / sec.
I have several questions:
- It seems that the performance of NCache queries depends on the total number of objects in the cache. This applies to similar solutions (NoSQL / Distributed Cache)
- Which NoSQL / Distributed Cache solution is optimized for speed query?
- Perhaps in NCache the query could be optimized in some way?
- Perhaps I am missing something - and my distributed cache usage pattern is wrong - how can I efficiently use a distributed cache like NCache in my use case?
source to share