Memcached 块限制

发布于 2024-07-04 02:33:49 字数 149 浏览 8 评论 0原文

为什么 memcached 中有硬编码块限制(压缩后 0.5 meg)? 有人重新编译过它吗? 我知道我不应该发送这样的大块,但这些额外的重块时常发生在我身上并造成严重破坏。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

客…行舟 2024-07-11 02:33:49

这个问题曾经出现在官方常见问题解答

我可能会遇到哪些 memcached 限制? (时光机)

引用:

您可能会在 memcache 中看到的简单限制是关键
物品尺寸限制。 键的长度限制为 250 个字符。 存储数据
大小不能超过 1 MB,因为这是最大的典型值
板尺寸。”

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

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

密钥的最大长度为 250 个字符。 请注意该值将是
如果您使用客户端“前缀”或类似功能,则更少,因为
前缀被添加到原始密钥的前面。 较短的按键是
通常更好,因为它们节省内存并使用更少的带宽。

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

啊,这是一个热门问题!

简短的回答:因为内存分配器的算法是如何工作的。

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

假设最小值为 400 字节,最大值为 1
兆字节,阶乘为 1.20:

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

板越大,它与板之间的间隙就越大。
前一块板。 所以最大值越大,效率越低
内存存储是。 Memcached 还必须预先分配一些内存
每个存在的板,因此设置一个较小的阶乘和一个较大的
最大值将需要更多的开销。

还有其他原因让你不想这样做......如果我们
谈论网页并且您正在尝试存储/加载值
这么大,你可能做错了什么。 在那个尺寸下它会
花费大量时间来加载和解压数据结构
进入内存,您的网站可能不会表现得很好。

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

This question used to be in the official FAQ

What are some limits in memcached I might hit? (Wayback Machine)

To quote:

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:

What is the maxiumum key length? (250 bytes)

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.

Why are items limited to 1 megabyte in size?

Ahh, this is a popular question!

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

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.

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

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

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.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文