0

I have a virtual machine host running Centos 6. It is serving an android application with apache/php/mysql. When online users gets high in number , the server responds very slowly. Even ssh connection to the server becomes slow.

So how can I find what is the bottleneck for this and how to fix it? Is it low RAM or a lot of hard disk write/read , high cpu usage , and which program is causing this?

This is the output of free -m in normal situations:

             total       used       free     shared    buffers     cached
Mem:          1877       1714        162          0         16        202
-/+ buffers/cache:       1495        381
Swap:         1023        231        792

Output of htop in normal situation: Output of htop

BlackBrain
  • 117
  • 4

3 Answers3

1

The output from free -h shows us that 80% of your memory is being used for things other than cache and buffers (1495 out of 1877). That is a quite high usage. Moreover only 202 is used for cache which is not a lot.

It's quite likely that under those circumstances you can expect anything depending on disk I/O to be slow. The question is whether your workload is I/O bound.

When we look at the htop output as well we see that the 2 CPUs are on average 50% loaded but load average is around 2.

From that we can conclude that the main contribution to load average isn't CPU so it has to be I/O. So you appear to have an I/O bound workload with only a tiny amount of memory available for caches.

Based on that I would say that insufficient RAM is the main reason for any slowness you are experiencing. You'd probably see a major improvement if you doubled the memory from 2GB to 4GB.

kasperd
  • 29,894
  • 16
  • 72
  • 122
0

So how can I find what is the bottleneck for this and how to fix it? Is it low RAM or a lot of hard disk write/read , high cpu usage , and which program is causing this?

It could be any, some combination, or all of the above. It may even be something completely different. Like you, without additional information we can't decide. You will need to install monitoring, gather information, analyse what you gather and make decisions based on what you find.

user9517
  • 114,104
  • 20
  • 206
  • 289
0

Make sure to host your app on a VPS that uses SSDs.

You can try to optimize Apache and MySQL services, and closely monitor your CPU and RAM usage when you have many online users.

RoseHosting
  • 189
  • 4