TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

The MySQL “swap insanity” problem and the effects of the NUMA architecture

92 点作者 admiun大约 13 年前

11 条评论

guard-of-terra大约 13 年前
One behavior I've noticed with linux that if you read files sequentially from disk (for example, doing scp), then linux would fill all the memory with those files' contents and then it would swap out everything but the (obviously useless) disk caches. So you'll have all the memory filled with data you would never need again and trying to do anything would cause a large and painful unswapping (had side effect of halting my qemu).<p>This is true insanity. Surely you can disable swap or tune swappiness, but what's the reason for crazy default behavior?
评论 #3813711 未加载
评论 #3813639 未加载
评论 #3813644 未加载
评论 #3813642 未加载
评论 #3813742 未加载
andreasvc大约 13 年前
I still don't comprehend why one needs swap at all. All the explanations I have come across talk about not having enough memory. Given that one has at least 8 GB of memory, or maybe even &#62;100GB, why on earth would you need swap? Sure some process might allocate even more than that, but maybe it's better to refuse such a request than to slow down the whole system due to thrashing.<p>I get the idea that the reason might be that a lot of programs allocate memory which they don't actually need regularly, which is then very convenient to swap out. Rather than enabling this bad habit using slow disk storage it would be much better to expect programs to be more frugal, or at least signify whether something should be kept in memory or not.
评论 #3817757 未加载
评论 #3814383 未加载
评论 #3813977 未加载
评论 #3829591 未加载
评论 #3814064 未加载
xxjaba大约 13 年前
I am very impressed with how well written this article is. A brief description of the problem, links to relevant discusions for less informed readers to come up to speed, and clear examples of how key pieces of information were gathered. I learned more from this article about the topic at hand than I have from a Blog post in recent memory.
评论 #3814298 未加载
sciurus大约 13 年前
Anther good article is <a href="https://kevinclosson.wordpress.com/2009/05/14/you-buy-a-numa-system-oracle-says-disable-numa-what-gives-part-ii/" rel="nofollow">https://kevinclosson.wordpress.com/2009/05/14/you-buy-a-numa...</a><p>On commodity servers, unless you have specific reasons to do otherwise just switch from NUMA to SUMA. There are two things yo should do<p>* Change a BIOS setting. The term for this will vary by manufacturer. For Dell, it means enabling node interleaving.<p>* Pass numa=off to the linux kernel (e.g. edit grub.cfg)
larsberg大约 13 年前
Yes, NUMA effects will really kill you, though how much depends on the particular quad-proc topology. I have some measurments for the interested in a small workshop paper I put together (I gathered the numbers in the context of tuning our garbage collector anyway):<p><a href="http://dl.dropbox.com/u/1620890/website/writings/mspc12-stream.pdf" rel="nofollow">http://dl.dropbox.com/u/1620890/website/writings/mspc12-stre...</a>
WALoeIII大约 13 年前
Will this optimization help on virtualized machines like Xen? Or does all memory appear to be the same?<p>On an EC2 m1.xlarge:<p>$ numactl --hardware available: 1 nodes (0) libnuma: Warning: /sys not mounted or invalid. Assuming one node: No such file or directory node 0 cpus: node 0 size: &#60;not available&#62; node 0 free: &#60;not available&#62; libnuma: Warning: Cannot parse distance information in sysfs: No such file or directory
jakejake大约 13 年前
For those of us mere mortals, would it be safe to assume that adding the suggested line to mysql_safe would be ok to do?<p>cmd="/usr/bin/numactl --interleave all $cmd"
corford大约 13 年前
Interesting read. Does anyone know if things have improved/changed significantly since the article was posted (Sep 2010)?
评论 #3814296 未加载
lawnchair_larry大约 13 年前
The title is inaccurate. It should say, "the linux swap insanity problem" because this is entirely related to the linux kernel. It just happens to affect MySQL and similar workloads, but it is not MySQL's fault. It doesn't behave that way on other platforms either.
评论 #3815935 未加载
评论 #3829671 未加载
defen大约 13 年前
Are the lessons here applicable to other commonly used databases (mongo, postgres, redis, etc)?
评论 #3815129 未加载
评论 #3815928 未加载
j2labs大约 13 年前
tl;dr - If you're running a database, or generally memory intensive system, while also using multiple CPUs you should run this command: echo 0 &#62; /proc/sys/vm/zone_reclaim_mode<p>But the article is great. You should definitely read it.
评论 #3814402 未加载