Memcached块限制 [英] Memcached chunk limit

查看:80
本文介绍了Memcached块限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么 memcached 中存在硬编码的块限制(压缩后为0.5兆)?有没有人重新编译他们的书呢?我知道我不应该发送像这样的大块,但是这些额外的大块不时发生在我身上,造成了严重破坏.

Why is there a hardcoded chunk limit (.5 meg after compression) in memcached? Has anyone recompiled theirs to up it? I know I should not be sending big chunks like that around, but these extra heavy chunks happen for me from time to time and wreak havoc.

推荐答案

该问题曾经出现在 有哪些内容我可能会遇到的memcached限制? (Wayback机器)

引用:

您可能会发现使用Memcache的简单限制是关键, 项目大小限制.键限制为250个字符.储存资料 大小不能超过1兆字节,因为这是最大的典型值 平板尺寸."

The simple limits you will probably see with memcache are the key and item size limits. Keys are restricted to 250 characters. Stored data cannot exceed 1 megabyte in size, since that is the largest typical slab size."

常见问题解答现已修订,现在有两个单独的问题涉及此问题:

The FAQ has now been revised and there are now two separate questions covering this:

最大密钥长度是多少? (250个字节)

键的最大大小为250个字符.请注意,此值将是 如果您使用的是客户端前缀"或类似功能,则数量要少一些,因为 前缀被添加到原始密钥的前面.较短的键是 通常会更好,因为它们可以节省内存并使用更少的带宽.

The maximum size of a key is 250 characters. Note this value will be less if you are using client "prefixes" or similar features, since the prefix is tacked onto the front of the original key. Shorter keys are generally better since they save memory and use less bandwidth.

为什么项目的大小限制为1 MB?

啊,这是一个受欢迎的问题!

Ahh, this is a popular question!

简短的回答:由于内存分配器算法的工作原理.

Short answer: Because of how the memory allocator's algorithm works.

长答案:Memcached的内存存储引擎(将是 可插拔/将来调整...),使用平板方式存储 管理.内存被分成大小不同的平板块, 从最小数开始,然后以阶乘递增,直到 可能的最大值.

Long answer: Memcached's memory storage engine (which will be pluggable/adjusted in the future...), uses a slabs approach to memory management. Memory is broken up into slabs chunks of varying sizes, starting at a minimum number and ascending by a factorial up to the largest possible value.

说最小值是400字节,最大值是1 兆字节,阶乘为1.20:

Say the minimum value is 400 bytes, and the maximum value is 1 megabyte, and the factorial is 1.20:

slab 1-400字节slab 2-480字节slab 3-576字节...等...

slab 1 - 400 bytes slab 2 - 480 bytes slab 3 - 576 bytes ... etc.

平板越大,与平板之间的间隙越大. 以前的平板.因此,最大值越大,效率越低 内存存储是. Memcached还必须为 存在的每个平板,因此将较小的阶乘设置为较大 最大值将需要更多的开销.

The larger the slab, the more of a gap there is between it and the previous slab. So the larger the maximum value the less efficient the memory storage is. Memcached also has to pre-allocate some memory for every slab that exists, so setting a smaller factorial with a larger max value will require even more overhead.

还有其他原因使您不想这样做...如果我们 谈论网页,您正在尝试存储/加载值 这么大,您可能做错了什么.这么大的尺寸 花费大量时间来加载和解压缩数据结构 进入内存,您的网站可能会无法很好地运行.

There're other reason why you wouldn't want to do that... If we're talking about a web page and you're attempting to store/load values that large, you're probably doing something wrong. At that size it'll take a noticeable amount of time to load and unpack the data structure into memory, and your site will likely not perform very well.

如果您确实要存储大于1MB的项目,则可以 用已编辑的slabs.c:POWER_BLOCK值重新编译内存缓存,或使用 低效率的malloc/free后端.其他建议包括 数据库,MogileFS等.

If you really do want to store items larger than 1MB, you can recompile memcached with an edited slabs.c:POWER_BLOCK value, or use the inefficient malloc/free backend. Other suggestions include a database, MogileFS, etc.

这篇关于Memcached块限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆