このコンテンツは選択した言語では利用できません。
Chapter 18. Set Up Lock Striping
18.1. About Lock Striping
Lock Striping allocates locks from a shared collection of (fixed size) locks in the cache. Lock allocation is based on the hash code for each entry’s key. Lock Striping provides a highly scalable locking mechanism with fixed overhead. However, this comes at a cost of potentially unrelated entries being blocked by the same lock.
Lock Striping is disabled by default in Red Hat JBoss Data Grid. If lock striping remains disabled, a new lock is created for each entry. This alternative approach can provide greater concurrent throughput, but also results in additional memory usage, garbage collection churn, and other disadvantages.
18.2. Configure Lock Striping (Remote Client-Server Mode)
Lock striping in Red Hat JBoss Data Grid’s Remote Client-Server mode is enabled by setting the striping
element to true
.
Lock Striping (Remote Client-Server Mode)
<locking acquire-timeout="20000" concurrency-level="500" striping="true" />
The default isolation mode for the Remote Client-Server mode configuration is READ_COMMITTED
. If the isolation
attribute is included to explicitly specify an isolation mode, it is ignored, a warning is thrown, and the default value is used instead.
The locking
element uses the following attributes:
-
The
acquire-timeout
attribute specifies the maximum time to attempt a lock acquisition. The default value for this attribute is10000
milliseconds. -
The
concurrency-level
attribute specifies the concurrency level for lock containers. Adjust this value according to the number of concurrent threads interacting with JBoss Data Grid. The default value for this attribute is32
. -
The
striping
attribute specifies whether a shared pool of locks is maintained for all entries that require locking (true
). If set tofalse
, a lock is created for each entry. Lock striping controls the memory footprint but can reduce concurrency in the system. The default value for this attribute isfalse
.
18.3. Configure Lock Striping (Library Mode)
Lock striping is disabled by default in Red Hat JBoss Data Grid. Configure lock striping in JBoss Data Grid’s Library mode using the striping
parameter as demonstrated in the following procedure.
Configure Lock Striping (Library Mode)
<local-cache> <locking concurrency-level="${VALUE}" isolation="${LEVEL}" acquire-timeout="${TIME}" striping="${TRUE/FALSE}" write-skew="${TRUE/FALSE}" /> </local-cache>
-
The
concurrency-level
is used to specify the size of the shared lock collection use when lock striping is enabled. -
The
isolation
parameter specifies the cache’s isolation level. Valid isolation levels areREAD_COMMITTED
andREPEATABLE_READ
. -
The
acquire-timeout
parameter specifies time (in milliseconds) after which a lock acquisition attempt times out. -
The
striping
parameter specifies whether a pool of shared locks are maintained for all entries that require locks. If set toFALSE
, locks are created for each entry in the cache. If set toTRUE
, lock striping is enabled and shared locks are used as required from the pool. -
The
write-skew
check determines if a modification to the entry from a different transaction should roll back the transaction. Write skew set to true requiresisolation_level
set toREPEATABLE_READ
. The default value forwrite-skew
andisolation_level
areFALSE
andREAD_COMMITTED
respectively. Thewrite-skew
parameter can be only used withOPTIMISTIC
transactions and it requires entry versioning to be enabled, withSIMPLE
versioning scheme.