-1

I'm just configuring some backend stuff and going through my aws.micro install.

Using htop I can see my memory is hovering around 530mb out of a total 590mb.

The colouring in htop still shows it being green so at first I wasn't worried, but is 60mb leeway enough to run my website?

Htop output

htop

free -m

free -m

UzumakiDev
  • 151
  • 1
  • 8
  • -> search: linux ate my ram – Zoredache Mar 11 '14 at 23:32
  • @Zoredache ahh, so it's being cached? – UzumakiDev Mar 11 '14 at 23:34
  • 1
    I don't know what is going on, on your server. You didn't provide enough details. The `free -m` output would have been a lot more useful. – Zoredache Mar 11 '14 at 23:35
  • @Zoredache ah yes, I just got to that in the article you linked. I've edited my question and included the free -m screenshot. It still says ~75 free so is that enough? – UzumakiDev Mar 11 '14 at 23:40
  • 1
    That shows 14MB free, not 75. That's a bit scary. What's the value of `vm/min_free-kbytes`? You have lots of free swap, so why are you concerned? Are you worried about running out of memory and refusing allocations? Are are you worried about thrashing due to swapping/paging? – David Schwartz Mar 11 '14 at 23:43
  • @DavidSchwartz yea, but isn't the one below 14, the 75, available ram that is cached? – UzumakiDev Mar 11 '14 at 23:47
  • 1
    Your swap usage is ~18%, your cache/buffers is a very low percentage of ram at ~10%, you have very little free space available. I think you should be looking at increasing the RAMs. – Zoredache Mar 11 '14 at 23:47
  • 1
    @UzumakiDev You need free RAM because you may need memory in a context in which you can't easily discard cached pages. In contexts where you can discard, you don't need free memory at all. You can make the memory free right at the instant you need it, so no need to worry about that. – David Schwartz Mar 11 '14 at 23:48
  • @DavidSchwartz Okay, I kind of understand what you're saying, basically, a context might arise where the available cached ram might not be available so I need actual free ram. So either I need to turn off some services using up ram or add some ram. – UzumakiDev Mar 11 '14 at 23:52
  • @Zoredache Okay, thank you for your help, I'll look into that. :) – UzumakiDev Mar 11 '14 at 23:53
  • 1
    @UzumakiDev Neither of those things will help. Turning off services that use RAM will just make the system use that RAM for something else. Adding more RAM will just cause the system to enlarge the cache. If your system is not maintaining enough free RAM, you have to change the vm tuning so it keeps more RAM free. This kind of sucks because using less RAM makes the system slower (just like removing the RAM would) but you need it to be stable. – David Schwartz Mar 11 '14 at 23:53
  • @DavidSchwartz Ahh. Okay, so I need to adjust some cache ratio settings? Where might I find those? – UzumakiDev Mar 11 '14 at 23:54
  • 1
    Well, you probably don't need to. You have around 14MB free and your system thinks it needs 3MB free. Unless you have some reason to think it's wrong about that, you shouldn't change it. – David Schwartz Mar 11 '14 at 23:55
  • @DavidSchwartz Aha, great, thanks for your help. I mean, I was worried htop was lulling me into a false sense of security, because it's mem gage was still green even though it seemingly had little ram left. I'll keep an eye on it anyway and I have a much better idea of what to look for now. Thanks again, much appreciated. – UzumakiDev Mar 12 '14 at 00:02
  • @Zoredache my system says it only needs 3mb of ram using the min_free_kbytes command below. Also, going by what Dave has said, do you still think I need more ram? Was my free_kbytes not correct because my server was not under much load at the time and infact I need more than 3mb of ram? – UzumakiDev Mar 12 '14 at 00:04

1 Answers1

2

Generally, 60MB is enough leeway. You can check with cat /proc/sys/vm/min_free_kbytes. That will tell you the amount of free RAM the server thinks it needs, and it's typically around 64MB. A bit less than that is fine -- unless you have some strange I/O storm, the amount of free RAM needed is extremely small.

If you use NFS heavily or have some kind of strange RAID controller that might require lots of free physical RAM during interrupt handling, you can raise this value. If you're having no symptoms, it's almost certainly sufficient.

David Schwartz
  • 31,449
  • 2
  • 55
  • 84
  • I haven't ran into any problems as of yet, but this website has only just gone live with hardly any traffic. I just don't want to be putting out fires within a week. I just checked free -m and it says I have buffers/cache free 59 and your command gave me 3mb, so I think im right to say I'm pretty safe? – UzumakiDev Mar 11 '14 at 23:46
  • Yeah. For some reason, your hardware/platform needs very little free memory. – David Schwartz Mar 11 '14 at 23:47