SettingService.getOrCreateSetting can become a bottle neck during periods of high database contention due to it being synchronized. Using double checked locking to bypass synchronization if the Setting already exists would prevent this method becoming a bottleneck in most cases, thereby preventing requests that already hold an active transaction or database connection to complete and return the database connection to the pool.
SettingService.getOrCreateSetting
can become a bottle neck during periods of high database contention due to it beingsynchronized
. Using double checked locking to bypass synchronization if the Setting already exists would prevent this method becoming a bottleneck in most cases, thereby preventing requests that already hold an active transaction or database connection to complete and return the database connection to the pool.