OpenEJB
  1. OpenEJB
  2. OPENEJB-1235

New Stateless pool options: PoolMin, IdleTimeout, MaxAge, Flush and more

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.1.3
    • Component/s: None
    • Labels:
      None

      Description

      1. Specifies the minimum number of bean instances that should be
      2. in the pool for each bean. Pools are prefilled to the minimum
      3. on startup. Pool "shrinking" is achived through WeakReferences
      4. and natural vm garbage collection. All but the minimum are allowed
      5. to be garbage collected by the VM when memory is needed.

      PoolMin 0

      1. Specifies the maximum time that an instance should live before
      2. it should be retired and removed from use. This will happen
      3. gracefully. Useful for situations where bean instances are
      4. designed to hold potentially expensive resources such as memory
      5. or file handles and need to be periodically cleared out.
        #
      6. Usable time units: nanoseconds, microsecons, milliseconds,
      7. seconds, minutes, hours, days. Or any combination such as
      8. "1 hour and 27 minutes and 10 seconds"

      MaxAge = 0 hours

      1. Applies to MaxAge usage and would rarely be changed, but is a
      2. nice feature to understand.
        #
      3. When the container first starts and the pool is filled to the
      4. minimum size, all those "minimum" instances will have the same
      5. creation time and therefore all expire at the same time dictated
      6. by the MaxAge setting. To protect against this sudden drop
      7. scenario and provide a more gradual expiration from the start
      8. the container will spread out the age of the instances that fill
      9. the pool to the minimum using an offset.
        #
      10. The MaxAgeOffset is not the final value of the offset, but
      11. rather it is used in creating the offset and allows the
      12. spreading to push the initial ages into the future or into the
      13. past. The pool is filled at startup as follows:
        #
      14. for (int i = 0; i < poolMin; i++) { # long ageOffset = (maxAge / poolMin * i * maxAgeOffset) % maxAge; # pool.add(new Bean(), ageOffset)); # }

        #

      15. The default MaxAgeOffset is -1 which causes the initial
      16. instances in the pool to live a bit longer before expiring. As
      17. a concrete example, let's say the PoolMin is 4 and the MaxAge is
      18. 100 years. The generated offsets for the four instances created
      19. at startup would be 0, -25, -50, -75. So the first instance
      20. would be "born" at age 0, die at 100, living 100 years. The
      21. second instance would be born at -25, die at 100, living a total
      22. of 125 years. The third would live 150 years. The fourth 175
      23. years.
        #
      24. A MaxAgeOffset of 1 would cause instances to be "born" older
      25. and therefore die sooner. Using the same example PoolMin of 4
      26. and MaxAge of 100 years, the life spans of these initial four
      27. instances would be 100, 75, 50, and 25 years respectively.
        #
      28. A MaxAgeOffset of 0 will cause no "spreading" of the age of the
      29. first instances used to fill the pool to the minimum and these
      30. instances will of course reach their MaxAge at the same time.
      31. It is possible to set to decimal values such as -0.5, 0.5, -1.2,
      32. or 1.2.

      MaxAgeOffset = -1

      1. Specifies the maximum time that an instance should be allowed to
      2. sit idly in the pool without use before it should be retired and
      3. removed.
        #
      4. Note that all instances in the pool, excluding the minimum, are
      5. eligible for garbage collection by the virtual machine as per
      6. the rules of java.lang.ref.WeakReference, so the use of an
      7. IdleTimeout is not required to conserve JVM-managed memory or
      8. shrink the pool.
        #
      9. Usable time units: nanoseconds, microsecons, milliseconds,
      10. seconds, minutes, hours, days. Or any combination such as
      11. "1 hour and 27 minutes and 10 seconds"

      IdleTimeout = 0 minutes

      1. The frequency in which the container will sweep the pool and
      2. evict expired instances. Eviction is how the IdleTimeout,
      3. MaxAge, and pool "flush" functionality is enforced. Higher
      4. intervals are better. Expired instances in use while the pool
      5. is swept will still be evicted upon return to the pool.
        #
      6. Usable time units: nanoseconds, microsecons, milliseconds,
      7. seconds, minutes, hours, days. Or any combination such as
      8. "1 hour and 27 minutes and 10 seconds"

      PollInterval = 5 minutes

      1. OPENEJB-1235.txt
        12 kB
        David Blevins

        Activity

        David Blevins made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Resolution Fixed [ 1 ]
        David Blevins made changes -
        Assignee David Blevins [ dblevins ]
        David Blevins made changes -
        Summary New Stateless pool options: MaxAge, IdleTimeout, PoolMin New Stateless pool options: PoolMin, IdleTimeout, MaxAge, Flush and more
        Description     # Specifies the minimum number of bean instances that should be
            # in the pool for each bean. Pools are prefilled to the minimum
            # on startup. Pool "shrinking" is achived through WeakReferences
            # and natural vm garbage collection. All but the minimum are allowed
            # to be garbage collected by the VM when memory is needed.

            PoolMin 0

            # Specifies the maximum time that an instance should live before
            # it should be retired and removed from use. This will happen
            # gracefully. Useful for situations where bean instances are
            # designed to hold potentially expensive resources such as memory
            # or file handles and need to be periodically cleared out.
            #
            # Usable time units: nanoseconds, microsecons, milliseconds,
            # seconds, minutes, hours, days. Or any combination such as
            # "1 hour and 27 minutes and 10 seconds"

            MaxAge = 0 hours

            # Applies to MaxAge usage and would rarely be changed, but is a
            # nice feature to understand.
            #
            # When the container first starts and the pool is filled to the
            # minimum size, all those "minimum" instances will have the same
            # creation time and therefore all expire at the same time dictated
            # by the MaxAge setting. To protect against this sudden drop
            # scenario and provide a more gradual expiration from the start
            # the container will spread out the age of the instances that fill
            # the pool to the minimum using an offset.
            #
            # The MaxAgeOffset is not the final value of the offset, but
            # rather it is used in creating the offset and allows the
            # spreading to push the initial ages into the future or into the
            # past. The pool is filled at startup as follows:
            #
            # for (int i = 0; i < poolMin; i++) {
            # long ageOffset = (maxAge / poolMin * i * maxAgeOffset) % maxAge;
            # pool.add(new Bean(), ageOffset));
            # }
            #
            # The default MaxAgeOffset is -1 which causes the initial
            # instances in the pool to live a bit longer before expiring. As
            # a concrete example, let's say the PoolMin is 4 and the MaxAge is
            # 100 years. The generated offsets for the four instances created
            # at startup would be 0, -25, -50, -75. So the first instance
            # would be "born" at age 0, die at 100, living 100 years. The
            # second instance would be born at -25, die at 100, living a total
            # of 125 years. The third would live 150 years. The fourth 175
            # years.
            #
            # A MaxAgeOffset of 1 would cause instances to be "born" older
            # and therefore die sooner. Using the same example PoolMin of 4
            # and MaxAge of 100 years, the life spans of these initial four
            # instances would be 100, 75, 50, and 25 years respectively.
            #
            # A MaxAgeOffset of 0 will cause no "spreading" of the age of the
            # first instances used to fill the pool to the minimum and these
            # instances will of course reach their MaxAge at the same time.
            # It is possible to set to decimal values such as -0.5, 0.5, -1.2,
            # or 1.2.

            MaxAgeOffset = -1

            # Specifies the maximum time that an instance should be allowed to
            # sit idly in the pool without use before it should be retired and
            # removed.
            #
            # Note that all instances in the pool, excluding the minimum, are
            # eligible for garbage collection by the virtual machine as per
            # the rules of java.lang.ref.WeakReference, so the use of an
            # IdleTimeout is not required to conserve JVM-managed memory or
            # shrink the pool.
            #
            # Usable time units: nanoseconds, microsecons, milliseconds,
            # seconds, minutes, hours, days. Or any combination such as
            # "1 hour and 27 minutes and 10 seconds"

            IdleTimeout = 0 minutes

            # The frequency in which the container will sweep the pool and
            # evict expired instances. Eviction is how the IdleTimeout,
            # MaxAge, and pool "flush" functionality is enforced. Higher
            # intervals are better. Expired instances in use while the pool
            # is swept will still be evicted upon return to the pool.
            #
            # Usable time units: nanoseconds, microsecons, milliseconds,
            # seconds, minutes, hours, days. Or any combination such as
            # "1 hour and 27 minutes and 10 seconds"

            PollInterval = 5 minutes
        David Blevins made changes -
        Summary Stateless pool min/max and reduction New Stateless pool options: MaxAge, IdleTimeout, PoolMin
        David Blevins made changes -
        Field Original Value New Value
        Attachment OPENEJB-1235.txt [ 12436184 ]
        David Blevins created issue -

          People

          • Assignee:
            David Blevins
            Reporter:
            David Blevins
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development