This discussion is archived
2 Replies Latest reply: Oct 18, 2009 10:12 AM by alexey.ragozin RSS

Is replicated cache single threaded?

alexey.ragozin Explorer
Currently Being Moderated
Hi,

Replicated cache scheme do not has <thread-count> configuration option.
1. Can replicated scheme have a poll of worker threads?
2. Which thread is used for get operations of replicated cache, caller thread or cache service event dispatch thread?
3. Where entry aggregation are executed (local or remote node, caller or event dispatch thread) ?

Thank you,
Alexey
  • 1. Re: Is replicated cache single threaded?
    ggleyzer Explorer
    Currently Being Moderated
    Hi Alexey,

    1. Replicated cache does not currently use the worker threads
    2, 3. All the "read" operations are executed on the caller's thread

    Regards,
    Gene
  • 2. Re: Is replicated cache single threaded?
    alexey.ragozin Explorer
    Currently Being Moderated
    Hi Gene,

    Thank you very much for an answer.

    I think, I should elaborate my problem a bit more.
    We have graph of objects stored in cache (objects reference each other by ID). Initially it was stored in distributed cache. Our business logic have required much of graph traversal and performance of solution was bad. Near cache has not improved performance due extensive usage of indexes. Next step was switching to replicated scheme (which should eliminate network and deserialization overhead). But in tests performance of replicated scheme was even worse than distributed, it was surprising.
    In tests we have many parallel requests, what is why I were asking about thread pool.
    After a little more investigation I have noticed, what we actually have only one test request and it is accessing the same every time.

    I did some micro benchmarking on concurrent access to cache.
    In benchmark cache is populated with 100k of object.
    And concurrent threads do random read operation.

    In first test number of total reads per second, grows slowly while increasing number of threads and after 4 threads (I have 4 core) stabilizes.
    Performance of 4 threads was 120% of single threaded version (while CPU usage grow from 95% to 380%).

    Then I have run this tests another 3 times but limiting accessed key range to 100, 10 and 1 key.
    This tests have shown considerable degradation of total performance with increasing concurrency.

    !http://www.mydisk.se/web/dbase/1c1542e89ed4ae1a6c8085eaf804d2ad.jpg!
    (X - concurrent threads, Y - operation per second from all threads)

    Finally I just used synchronized block to guard access to cache object, with external synchronization multithreading performance degradation has reduced (in case of one key and 10 thread, using external synchronization increases performance 4 time)

    !http://www.mydisk.se/web/dbase/117e0c60c642cc469f9b12ef363dcd38.jpg!
    (X - concurrent threads, Y - operation per second from all threads)

    This is also unexpected, external synchronization should never increase concurrent throughput but it does, in case of small intensively accessed data subset.

    Could you explain concurrency model of replicated cache?
    1. Does it is using segment locking?
    2. Does it utilize read/write locks?
    3. In case of aggregation, how long lock for entries are being held?

    Thank you,
    Alexey

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points