Tyler
Tyler

Reputation: 2386

max memory redis heroku django

I am trying to add a video upload to a task using django and celery + redis. The videos will be a maximum of 3mb but It seems passing the video in memory is problematic and reaches the limit for redis.

How can I find what the max memory limit is for redis?

This is what the video upload looks like:

@csrf_exempt
def tag_location(request):
    if request.FILES.__contains__('file'):
        image = request.FILES['file'].read()
    else:
        image = None

    if request.FILES.__contains__('video-file'):
        video = request.FILES['video-file'].read()
    else:
        video = None

    tasks.tag_location.delay(image,video)

    return JsonResponse({'response': 1})

The task is 100% working just sometimes the files are too large. Is there a way to just pass a file path for the video/image to redis rather than reading through the file and passing it through memory?

Upvotes: 0

Views: 1191

Answers (1)

Rahul Gupta
Rahul Gupta

Reputation: 47846

The maxmemory configuration directive is used to configure the Redis to use a specified amount of memory for the data set.

Finding the maximum memory limit:

To find out the maximum memory limit of a running Redis server, you need to use the CONFIG GET command. The CONFIG GET command is generally used to read the configuration parameters of a running Redis server. It takes a single argument and returns all the configuration parameters matching this parameter as a list of key-value pairs.

Example:

redis 127.0.0.1:6379> CONFIG GET maxmemory # gets maximum memory limit of redis server

64 bit systems have default value of maxmemory as 0 (zero) resulting into no memory limits.
32 bit systems use an implicit memory limit of 3GB.

redis 127.0.0.1:6379> CONFIG GET maxmemory # output on my 64 bit system
1) "maxmemory"
2) "0"

Modifying the maximum memory limit:

To modify the maximum memory limit of the redis server, you can set the maxmemory configuration directive using the redis.conf file, or by using the CONFIG SET command at runtime.

For example in order to configure a memory limit of 500 megabytes, the following directive can be used inside the redis.conf file.

maxmemory 500mb

Upvotes: 2

Related Questions