mirror of
https://github.com/frappe/bench.git
synced 2025-01-10 09:02:10 +00:00
Merge pull request #345 from shreyasp/max-redis-mem
[Fix] Max memory given to redis cache should be dependent on virtual of the machine
This commit is contained in:
commit
2b6715594e
@ -29,7 +29,7 @@ def generate_config(bench_path):
|
|||||||
write_redis_config(
|
write_redis_config(
|
||||||
template_name='redis_cache.conf',
|
template_name='redis_cache.conf',
|
||||||
context={
|
context={
|
||||||
"maxmemory": config.get('cache_maxmemory', '50'),
|
"maxmemory": config.get('cache_maxmemory', get_max_redis_memory()),
|
||||||
"port": ports['redis_cache'],
|
"port": ports['redis_cache'],
|
||||||
"redis_version": get_redis_version(),
|
"redis_version": get_redis_version(),
|
||||||
},
|
},
|
||||||
@ -60,3 +60,14 @@ def get_redis_version():
|
|||||||
|
|
||||||
version = semantic_version.Version(version[0], partial=True)
|
version = semantic_version.Version(version[0], partial=True)
|
||||||
return float('{major}.{minor}'.format(major=version.major, minor=version.minor))
|
return float('{major}.{minor}'.format(major=version.major, minor=version.minor))
|
||||||
|
|
||||||
|
def get_max_redis_memory():
|
||||||
|
import psutil
|
||||||
|
|
||||||
|
total_virtual_mem = psutil.virtual_memory().total/(pow(1024, 2))
|
||||||
|
max_memory = int(total_virtual_mem * 0.05) # Max memory for redis is 5% of virtual memory
|
||||||
|
|
||||||
|
if max_memory < 50:
|
||||||
|
return 50
|
||||||
|
else:
|
||||||
|
return max_memory
|
||||||
|
Loading…
Reference in New Issue
Block a user