amazon-web-servicesflaskmemcachedamazon-elasticacheflask-cache

AWS Elasticache - increase memcached item size limit


Im using the memcached module on AWS Elasticache in my python Flask app (with Flask-Cache)

When i try to set a file that is less than 1MB i need to repeatedly access to the cache, i have no issues. But when the file size increases more than a MB (the file could be a text file/csv/xlsx etc), i get the following error

Error: error 37 from memcached_set: SUCCESS

Im guessing its because of the size limit on a memcached item which is capped at 1MB. How do i increase this item limit to say 5-6 MB in AWS Elasticache ?

Are there any issues in increasing this item size limit in memcached ?


Solution

  • This page lists the parameters that we can tinker with in memcached http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/CacheParameterGroups.Memcached.html

    If you do not specify a parameter group for your Memcached cluster, then a default parameter group (default.memcached1.4) will be used. You cannot change the values of any parameters in the default parameter group; however, you can always create a custom parameter group and assign it to your cluster at any time.

    Create a new Cache Parameter group either from the AWS Console or using the AWS CLI and set the max_item_size to the size that fits your needs. Reboot your cache cluster for this change to kickin.

    enter image description here

    On your local testing machine, if you have memcache installed, then you can increase the object size by adding this line at /etc/memcached.conf

    # Increase object size limit
    -I 128M
    

    Then reboot your memcache with sudo service memcached restart for the changes to settle in