-
Notifications
You must be signed in to change notification settings - Fork 31
Add distributed local cache for StackExchange.Redis provider #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add distributed local cache for StackExchange.Redis provider #72
Conversation
I didn't see that the cache providers weren't disposed per test, which heavily impacted the above benchmarks. Now the cache providers are disposed per test for Redis provider and I've reran the tests and updated the benchmarks. |
The last commit contains also a fix for |
StackExchangeRedis/NHibernate.Caches.StackExchangeRedis/ConfigurationHelper.cs
Outdated
Show resolved
Hide resolved
StackExchangeRedis/NHibernate.Caches.StackExchangeRedis/RegionMemoryCacheBase.cs
Outdated
Show resolved
Hide resolved
|
||
namespace NHibernate.Caches.StackExchangeRedis.Tests | ||
{ | ||
public class CacheRegionStrategyFactory : DefaultCacheRegionStrategyFactory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking to include it in the default factory, I have now seen the reason, see #123.
This PR adds three strategies that use a local cache for faster readings, fixes #69.
DistributedLocalCacheRegionStrategy
: Uses only Redis pubsub mechanims to synchronize data between caches.TwoLayerCacheRegionStrategy
: UsesDefaultRegionStrategy
logic for updating the Redis cache and Redis pubsub mechanism to invalidate local caches.FastTwoLayerCacheRegionStrategy
: UsesFastRegionStrategy
logic for updating the Redis cache and Redis pubsub mechanism to invalidate local caches.All three strategies share the same drawbacks:
PutMany
operationAdditional drawbacks for
DistributedLocalCacheRegionStrategy
:All three strategies supports pipelining for write operations, but it is disabled by default as it requires more CPU and may cause a timeout due to the cpu or network bound.
The below tests were ran in .NET 4.6.1 on Intel i7-860 and Redis server was located on a different local machine.
StackExchange.Redis
version2.0.601
was used as it has some performance improvements. In the test environment the bottleneck was the cpu where the test were ran (Intel i7-860) and Redis server cpu when pipelining was used. When enabling pipelining, there were very high synchronization times and also timeouts due to bottlenecking cpu.With pipelining:
33285 op/s, 296ms sync time (*)
With pipelining:
31243 op/s, 4143ms sync time (*)
With pipelining:
1366 op/s, 25ms sync time (*)
With pipelining:
1170 op/s, 80ms sync time (*)
With pipelining:
6804 op/s, 10ms sync time (*)
With pipelining:
138007 op/s, 2075ms sync time (*)
With pipelining:
12648 op/s, 23ms sync time (*)
With pipelining:
24894 op/s, 4ms sync time (*)
With pipelining:
33861 op/s, 278ms sync time (*)
With pipelining:
32417 op/s, 4126ms sync time (*)
With pipelining:
6309 op/s, 10ms sync time (*)
With pipelining:
112632 op/s, 2ms sync time (*)
With pipelining:
7009 op/s, 12ms sync time (*)
With pipelining:
142914 op/s, 2074ms sync time (*)
(*) - Only 4 tasks were used in the test, due to the high CPU usage of the strategy.
For tests that do not have (*), 8 tasks were used.
I didn't realized that the cache providers weren't disposed per test, which heavily impacted the above benchmarks. I've rerun the tests and updated the values.