Redis "volatile-lru" cache#407
Conversation
|
Why not just do this through the Django cache framework, which is the default for |
We're currently using the Django cache, but in production when a user tries to visualize the boston orthoimagery layer for our example use cases, the web service with Django runs out of memory: |
|
I see that after #404, the Django cache is being used, but it was never actually configured properly. Per my suggestion, #404 needed to add something like: LARGE_IMAGE_CACHE_NAME = "tiles"
CACHES = {
"tiles": {
"BACKEND": "django.core.cache.backends.redis.RedisCache",
"LOCATION": env.url("DJANGO_REDIS_URL").geturl(),
"OPTIONS": {
# Use database /2 for the tile cache,
# in case other services use /0 in the future
"db": "2",
},
# An arbitrarily long time
"TIMEOUT": int(datetime.timedelta(weeks=4).total_seconds()),
}
}If we need to balance other cache considerations in the future, the configuration is well-documented by Django and we have all the local knobs (including the actual |
|
|
||
| # Large image cache with Redis | ||
| LARGE_IMAGE_CACHE_BACKEND = "redis" | ||
| LARGE_IMAGE_CACHE_REDIS_URL = env.url("DJANGO_REDIS_URL").geturl() |
There was a problem hiding this comment.
Where do we control the Redis database number here?
We're using Redis for other things, so I think we should have local control of this.
|
@brianhelba I tried the above suggestion locally and ran into some problems. First, if I set But the next problem is more prohibitive. After that change, it appeared to work properly, but when I performed minimal load testing, I got consistent crashes. I was watching the logs from the redis container as I loaded our aerial imagery layer on the map. It appeared to be working at first; tile fetching after the first load was snappy and the redis logs reflected the cache hits. But after a few refreshes loading the same tiles on the map, I noticed the following behavior:
|
|
Just to ensure the problem is truly with the |
|
When I run geodatalytics not in a devcontainer (classic Changing the "default" cache to a If I increase the My expectation was that redis would handle reaching its memory limit gracefully by evicting old keys for tiles (for which we've set a default TTL). I don't know why it would be raising an error like this when the One additional thing to note is that when the redis container first starts, it takes about 30-60 seconds printing out a bunch of logs that all say |
|
I tested |
This PR bumps the version of
large-imagewe use so that we can leverage the latest changes to its Redis cache. Since the cache entries will now have a TTL, we can use the "volatile-lru" max memory policy and expect that our redis cache can evict large-image tiles without evicting websocket connections.See x and x. Resolves #398.