3

I am evaluating NCache for usage in the ongoing project as a "read-through" cache - in order to take off load from SQL server.
At client-side, the project has a polling routine that receives items filtered (at server-side) by last polling datetime.
The polling occurs at fixed interval at separate thread.
The pseudo code for client-side
1) first time fetch:

  1. fetch all existing items
  2. set LastHandledDate to now

2) non-first time fetch (polling thread)

  1. fetch existing items that were created after LastHandledDate
  2. update LastHandledDate to now

At server-side,when the polling query is received, the following pseudo-code is executed:

  1. query NCache for all matching items with CreationDate >= LastHandledDate
  2. IF query results are empty
    1. query SQL database for all matching items with CreationDate >= LastHandledDate
    2. if query is not empty then update NCache with SQL query results
    3. return SQL query results
  3. ELSE return NCache query result

To query NCache I am using it's linq provider, and the query is similar to SQL query:

SELECT * FROM Messages WHERE Message.SessionId = 1234 AND Message.EntryDate >= ‘2012-10-6’

Edit: During testing,on the client-side there is a thread 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 polling setup with 100 clients for about an hour, I've noticed a steady decline in requests/sec the web-service was performing.

Running the above setup with only reads from NCache, without SQL reads at all (without paragraph 2 at server-side pseudo-code) yielded the same decline pattern in requests/sec.

I have several questions:

  • It seems that NCache's query performance depends on total number of objects in the cache. Is this the case in similar solutions (NoSQL / Distributed Cache)
  • Which NoSQL/Distributed Cache solution is optimized for querying speed?
  • Maybe in the NCache the querying can be somehow more optimized?
  • Perhaps I am missing something- and my usage pattern of distributed cache is incorrect - how can I use distributed cache such as NCache efficiently in my use case?
Michael
  • 860
  • 7
  • 19

1 Answers1

1

Try using Query Indexes for your classes.

I'm using with 100k items in cache (appr. 250kb sized each) and not having any performance issues.