[jboss-jira] [JBoss JIRA] (WFLY-12581) Optimize distributed web/ejb expiration schedulers

Paul Ferraro (Jira) issues at jboss.org
Wed Sep 25 15:38:00 EDT 2019


     [ https://issues.jboss.org/browse/WFLY-12581?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Ferraro updated WFLY-12581:
--------------------------------
    Description: 
WFLY-12321 added a new expiration scheduler implementation for SFSBs specifically optimized for non-distributed environments.  The key features of this implementations are:
* Uses a single scheduled task instead of a scheduled task per SFSB
* Uses a double-linked list to track SFSBs to be expired

Because most scheduled tasks will be canceled before they are executed, the performance of a given scheduler implementation is primarily limited by the cost of insertion and removal into the backing data structure.  The goal of this jira is to generalize the scheduler implementation introduced by WFLY-12321 such that it can be used for scheduling of both local and distributed web sessions and SFSBs.

In the scheduler implemented as part of WFLY-12321, the use of a linked queue is based on the following assumptions:
# All SFSB using a given scheduler use the same @StatefulTimeout
# A given call to Scheduler.schedule(...) is always the last item to be scheduled

Unfortunately, the second assumption is not valid for distributed SFSBs as a member may assume the responsibility of expiring a SFSB previously owned by another member.
Additionally, the second assumption is not valid for local nor distributed web sessions, as a given web session can override the default session timeout of the application.

This jira proposes the following:
* Generalize the Scheduler interface for reuse between SFSBs and web sessions.
* Generalize the new local scheduler implementation such that the same scheduler can support both local and distributed objects using different data structures for tracking scheduled items
* Replace ExpirationTracker with a ConcurrentDirectDeque to support local case, which has O(1) add/remove characteristics
** ConcurrentDirectDeque outperforms ExpirationTracker under concurrent load (see attached graph)
* Local web sessions and all distributed use cases will store scheduled entries within a ConcurrentSkipListSet, which has O(log N) add/remove characteristics


  was:
WF18 added a new expiration scheduler implementation for SFSBs specifically optimized for non-distributed environments.  The key features of this implementations are:
* Uses a single scheduled task instead of a scheduled task per SFSB
* Uses a double-linked list to track SFSBs to be expired

Because most scheduled tasks will be canceled before they are executed, the performance of a given scheduler implementation is primarily limited by the cost of insertion and removal into the backing data structure.  The goal of this jira is to generalize the scheduler implementation introduced by WFLY-12321 such that it can be used for scheduling of both local and distributed objects.

The use of a linked queue is based on the following assumptions:
# All SFSB using a given scheduler share the same @StatefulTimeout
# A given call to Scheduler.schedule(...) is always the last item to be scheduled

Distributed SFSBs cannot use the same implementation because the second assumption is not valid, as a member may assume the responsibility of expiring a SFSB previously owned by another member.  They can, however, leverage the strategy of using a single scheduled task instead of a task per SFSB.  Due to the nature of the scheduler, that most scheduled tasks will be cancelled/removed and rescheduled, this strategy outperforms the current implementation.

This jira proposes the following:
* Generalize the Scheduler interface for reuse between SFSBs and web sessions.
* Generalize the new local scheduler implementation such that the same scheduler can support both local and distributed SFSBs using different queue implementations for tracking scheduled items
* Distributed use case uses a DelayQueue, which has O(log N) add/remove characteristics
* Replace ExpirationTracker with a ConcurrentDirectDeque to support local case, which has O(1) add/remove characteristics
** ConcurrentDirectDeque outperforms ExpirationTracker under concurrent load

Local web session expiration cannot use the same expiration scheduler used by local SFSBs because the first assumption is not valid, since a given web session can override the default max inactive interval.  However, we can still optimize the local web session case by delegating expiration to the PriorityBlockingQueue-based implementation if the session uses a non-default max inactive interval, and to the ConcurrentDirectDeque-based implementation if the session uses the default max inactive interval.



> Optimize distributed web/ejb expiration schedulers
> --------------------------------------------------
>
>                 Key: WFLY-12581
>                 URL: https://issues.jboss.org/browse/WFLY-12581
>             Project: WildFly
>          Issue Type: Enhancement
>          Components: Clustering
>    Affects Versions: 18.0.0.Beta1
>            Reporter: Paul Ferraro
>            Assignee: Paul Ferraro
>            Priority: Major
>         Attachments: Schedulers for distributed workloads.png, Schedulers for local workloads.png
>
>
> WFLY-12321 added a new expiration scheduler implementation for SFSBs specifically optimized for non-distributed environments.  The key features of this implementations are:
> * Uses a single scheduled task instead of a scheduled task per SFSB
> * Uses a double-linked list to track SFSBs to be expired
> Because most scheduled tasks will be canceled before they are executed, the performance of a given scheduler implementation is primarily limited by the cost of insertion and removal into the backing data structure.  The goal of this jira is to generalize the scheduler implementation introduced by WFLY-12321 such that it can be used for scheduling of both local and distributed web sessions and SFSBs.
> In the scheduler implemented as part of WFLY-12321, the use of a linked queue is based on the following assumptions:
> # All SFSB using a given scheduler use the same @StatefulTimeout
> # A given call to Scheduler.schedule(...) is always the last item to be scheduled
> Unfortunately, the second assumption is not valid for distributed SFSBs as a member may assume the responsibility of expiring a SFSB previously owned by another member.
> Additionally, the second assumption is not valid for local nor distributed web sessions, as a given web session can override the default session timeout of the application.
> This jira proposes the following:
> * Generalize the Scheduler interface for reuse between SFSBs and web sessions.
> * Generalize the new local scheduler implementation such that the same scheduler can support both local and distributed objects using different data structures for tracking scheduled items
> * Replace ExpirationTracker with a ConcurrentDirectDeque to support local case, which has O(1) add/remove characteristics
> ** ConcurrentDirectDeque outperforms ExpirationTracker under concurrent load (see attached graph)
> * Local web sessions and all distributed use cases will store scheduled entries within a ConcurrentSkipListSet, which has O(log N) add/remove characteristics



--
This message was sent by Atlassian Jira
(v7.13.8#713008)


More information about the jboss-jira mailing list