Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kinshara's avatar

VPS Ram 2 GB almost run out memory

I have my website hosted in Digital Ocean wtih 2 GB Memory, 2 Core Processors. and currently only 1 website inside.

top - 02:16:59 up 27 days, 20:22,  1 user,  load average: 0.08, 0.16, 0.15
Tasks:  94 total,   2 running,  92 sleeping,   0 stopped,   0 zombie
%Cpu(s):  3.0 us,  1.3 sy,  0.0 ni, 95.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem:   2049936 total,  1714208 used,   335728 free,   136520 buffers
KiB Swap:        0 total,        0 used,        0 free.  1193200 cached Mem

I used Ubuntu + Lamp. my website currently using laravel 5.0 and I set nohup queue:listen inside.

is my server status normal? my ram 1,7 Gb used. and my free memory only 300Mb++.. what will happend if the memory run out?

0 likes
7 replies
ejdelmonico's avatar

First of all, you should investigate why your site is using so much memory. That is a real problem for you in the long term. Now, search DO for swap file and follow the instructions on how to increase the size...it should be twice the size of your memory. That will help you for now.

kinshara's avatar

@ejdelmonico my friend told me because I use apache instead of nginx. and as I saw there is more than 5 apache task when I check by using "top". is this true?

and does using swap memory make load slower?

             total       used       free     shared    buffers     cached
Mem:       2049936    1686924     363012      29232     142976    1176860
-/+ buffers/cache:     367088    1682848
Swap:            0          0          0

is my server's status showing good condition?

@davidfaux thanks for the link, does that free in buffer/cache row is available for application? can it be use only for "apache" things?

but now, which one x_x.. I do confuse, which one is better and why? sorry if I asked too much. thank you for your time and for the answers.

ohffs's avatar

You're fine - you're only using 367mb of ram :

-/+ buffers/cache:     367088    1682848

The rest of your memory is being used by Linux to try and cache things to save hitting disk etc. It'll return it to your application if it needs it.

ejdelmonico's avatar

@kinshara Your stats look fine. However, please understand that if you do run out of memory while running a DB query, mysql will crash hard. It is a good idea to have a swap file of adequate size to handle out of memory issues. The swap file will only be accessed if you run out of memory. I have to strongly disagree with your source about having an adequate swap file. The normal amount of swap file is usually twice the size of your memory. I would add that 4GB is probably a max because anything that requires more memory than that is probably something that should have the server go down. Digital Ocean does not recommend a swap file because of the use of SSD's. However, that main issue still exists....you either upgrade your droplet to have more memory or let let your server fail hard if mysql runs out of memory. For me, if I couldn't increase the memory size for the droplet and I knew that there were no rogue processes using up memory, I would rather add a swap file than have the server randomly fail due to mysql running out of memory. So, it comes down to a tough decision on your part.

jekinney's avatar

What most people who don't use Linux at some point as a desktop os is Linuxs memory management. Linux will throw a lot of "stuff" in memory to store (allocated, cache) but as process spoil up it clears space for the processes that require memory.

So it's not uncommon to see a Linux server like the op stated but the actual used memory is significantly smaller.

Windows implemented the same thing but people freaked out. So they just hide it now and show actual memory use versus cached use.

Please or to participate in this conversation.