increase item max size in memcached?
Asked Answered
A

4

15

i am using memcached on my centos server , my project is large and has objects more than 1MB which i need to save to memcached , well , i can't ! because the max_item_size is 1MB , anyway to edit that ?

Thank you

Arlie answered 25/1, 2011 at 15:45 Comment(4)
possible duplicate of Cache over 1mb memcache alternativesSalient
check out how to do this in Ruby on Rails: #37353053Jumbala
Also sometimes memcached client sets it's own max size limitation. For example, with Python's memcached this may be needed in addition to -I 15m: import memcache ; client=memcache.Client([('localhost',11211)], server_max_value_length=15 * 1024 * 1024)Lemures
Here is another answer on the same - https://mcmap.net/q/413132/-maximum-size-of-object-that-can-be-saved-in-memcached/6563567Burgage
C
22

You can change the limit quickly by edit the configuration file [/etc/memcached.conf] adding:

# Increase limit 
-I 128M

Or if you have trouble with SO config run it with command line directly

memcached -I 128M
Caption answered 24/3, 2015 at 7:58 Comment(1)
Is there a way to configure this size in Tomcat context.xml when configuring memcahed SessionManager?Chartier
M
5

If you are using Memcache >= 1.4.2, this is now configurable. Here is an example of how to set this in your init script for starting Memcache on CentOS: http://www.alphadevx.com/a/387-Changing-the-maximum-item-size-allowed-by-Memcache

Moya answered 21/2, 2013 at 14:23 Comment(0)
C
3

You can compile memcached and change the memory allocation setting to use POWER_BLOCK's, in the slabs.c file (or you can recompile and user malloc/free, but that is the greater of the evils).

http://code.google.com/p/memcached/wiki/FAQ#Why_are_items_limited_to_1_megabyte_in_size?

I would seriously consider what you are caching and how it can be more modular, > 1MB in active memory is large.

Contredanse answered 16/3, 2011 at 10:34 Comment(3)
i will be using 5 blocks of 2 MB each only ;) thants all what i need thanks :)Arlie
As of memcache 1.4.2, this is now a configurable parameter at startup. See "Configurable maximum item size" in code.google.com/p/memcached/wiki/ReleaseNotes142Wolfhound
Original link in solution is obsolete.Brickwork
H
2

Spent tons of time to figure this out: in /etc/sysconfig/memcached edit options

OPTIONS="-l 127.0.0.1 -I 3m"

then systemctl restart memcached to take effect.

Would recommend option -l 127.0.0.1 it secures to localhost usage only and -I 3m increases the limit as described above.

With Centos 7 I had no luck with these paths /etc/memcached.conf /etc/default/memcached

Hobard answered 14/6, 2021 at 19:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.