ActiveMQ
  1. ActiveMQ
  2. AMQ-3028

ActiveMQ broker processing slows with consumption from large store

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 5.4.1
    • Fix Version/s: 5.4.2
    • Component/s: Broker
    • Labels:
      None
    • Environment:

      CentOS 5.5, Sun JDK 1.6.0_21-b06 64 bit, ActiveMQ 5.4.1, AMD Athlon(tm) II X2 B22, local disk

      Description

      In scalability tests, this problem occured. I have tested a workaround that appears to function. A fix will gladly be submitted - would like some guidance, though, on the most appropriate solution.

      Here's the summary. Many more details are available upon request.

      Root cause:

      • Believed to be simultaneous access to LRUCache objects which are not thread-safe (PageFile's pageCache)

      Workaround:

      • Synchronize the LRUCache on all access methods (get, put, remove)

      The symptoms are as follows:

      1. Message rates run fairly-constant until a point in time when they degrade rather quickly
      2. After a while (about 15 minutes), the message rates drop to the floor - with large numbers of seconds with 0 records passing
      3. Using VisualVM or JConsole, note that memory use grows continuosuly
      4. When message rates drop to the floor, the VM is spending the vast majority of its time performing garbage collection
      5. Heap dumps show that LRUCache objects (the pageCache members of PageFile's) are far exceeding their configured limits.
      The default limit was used, 10000. A size of over 170,000 entries was reached.
      6. No producer flow control occurred (did not see the flow control log message)

      Test scenario used to reproduce:

      • Fast producers (limited to <= 1000 msgs/sec)
        • using transactions
        • 10 msg per transaction
        • message content size 177 bytes
      • Slow consumers (limited to <= 10 msg/sec)
        • auto-acknowledge mode; not transacted
      • 10 Queues
        • 1 producer per queue
        • 1 consumer per queue
      • Producers, Consumers, and Broker all running on different systems, and on the same system (different test runs).

      Note that disk space was not an issue - there was always plenty of disk space available.

      One other interesting note - once a large database of records was stored in KahaDB, only running consumers, this problem still occurred.

      This issue sounds like it may be related to 1764, and 2721. The root cause sounds the same as 2290 - unsynchronized access to LRUCache.

      The most straight-forward solution is to modify all LRUCache objects (org.apache.kahadb.util.LRUCache, org.apache.activemq.util.LRUCache, ...) to be concurrent. Another is to create concurrent versions (perhaps ConcurrentLRUCache) and make use of those at least in PageFile.pageCache.

      1. LRUCache.patch
        2 kB
        Arthur Naseef

        Activity

        Hide
        Arthur Naseef added a comment -

        Patch which synchronizes org.apache.kahadb.util.LRUCache and org.apache.activemq.util.LRUCache on get(), put(), and remove() calls.

        Show
        Arthur Naseef added a comment - Patch which synchronizes org.apache.kahadb.util.LRUCache and org.apache.activemq.util.LRUCache on get(), put(), and remove() calls.
        Hide
        Arthur Naseef added a comment -

        Is there something I can do to further assist with this issue?

        Testing with the attached patch was successful - all of the problems were aleviated.

        I have considered writing a JUnit to test it, but that is not trivial because (a) the time needed to learn JUnit, (b) the impact of configuration on reproducing the problem in a timely manner (increasing JVM memory may delay detection of the issue), and (c) detecting the problem requires internal access to the LRUCache or some other method with which I am unfamiliar.

        Show
        Arthur Naseef added a comment - Is there something I can do to further assist with this issue? Testing with the attached patch was successful - all of the problems were aleviated. I have considered writing a JUnit to test it, but that is not trivial because (a) the time needed to learn JUnit, (b) the impact of configuration on reproducing the problem in a timely manner (increasing JVM memory may delay detection of the issue), and (c) detecting the problem requires internal access to the LRUCache or some other method with which I am unfamiliar.
        Hide
        Dejan Bosanac added a comment -

        Fixed with svn revision 1038566

        I didn't make LRU cache synced in general, just synced the usage of pageCache. Let us know if it helps with your scenario.

        Show
        Dejan Bosanac added a comment - Fixed with svn revision 1038566 I didn't make LRU cache synced in general, just synced the usage of pageCache. Let us know if it helps with your scenario.
        Hide
        Arthur Naseef added a comment -

        I will test with the update and post the results when complete. With any luck, it'll be done today.

        Show
        Arthur Naseef added a comment - I will test with the update and post the results when complete. With any luck, it'll be done today.
        Hide
        Adam Sussman added a comment -

        Are you saying their solution isn't good enough?

        Show
        Adam Sussman added a comment - Are you saying their solution isn't good enough?
        Hide
        Arthur Naseef added a comment -

        Oh hey Adam - different message thread.

        I was just indicating that I need to run my tests to feel confident it's resolved.

        Show
        Arthur Naseef added a comment - Oh hey Adam - different message thread. I was just indicating that I need to run my tests to feel confident it's resolved.
        Hide
        Arthur Naseef added a comment -

        My tests just finished and ran without a problem. In addition to consistent performance throughout the test, a heapdump with VisualVM shows the LRUCache objects all stayed within their limits.

        Thank you!

        Show
        Arthur Naseef added a comment - My tests just finished and ran without a problem. In addition to consistent performance throughout the test, a heapdump with VisualVM shows the LRUCache objects all stayed within their limits. Thank you!
        Hide
        Dejan Bosanac added a comment -

        Thanks for confirming!

        Show
        Dejan Bosanac added a comment - Thanks for confirming!

          People

          • Assignee:
            Dejan Bosanac
            Reporter:
            Arthur Naseef
          • Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development