First of all, you need to reconsider, whether your app really needs to "phone home" every 15 minutes! This puts burdon not only onto your server, but also on the mobile network, on people's phones and on their data bills. In particular, if this is a location update, the app might be programmed to not send an update of the location, if the change in GPS coordinates from the last transferred update is small.
Secondly, you have to debug, what drives up the load on your web server. Use top
to show load details. The line of particular interest looks like this one:
Cpu(s): 3.0%us, 6.0%sy, 1.6%ni, 85.9%id, 0.4%wa, 0.0%hi, 3.0%si, 0.0%st
This is from a lightly loaded server, that is 86% idle - so everything fine in my example. In your case, it might look like the following:
Cpu(s): 3.0%us, 6.0%sy, 1.6%ni, 4.9%id, 81.4%wa, 0.0%hi, 3.0%si, 0.0%st
The exzessive "wait" means, that your jobs are waiting for the disk to finish reading or writing data. If you have that problem, then try to reduce on unnecessary writes to disk (google for noatime
to learn more about that) and try to lower write security levels on your database, where it is safe to do so. For example, if a location update is not written to disk properly in case of a power failure, the consequences to your service are likely minimal, as at the time, that power is restored after repairing the failed component, the locations will be outdated anyway. On the other hand, if new users sign up, you want to keep those writes to the main account data as synchronous, so that you don't loose accounts due to a power or server failure.
If even after those changes, wait time is high, think about faster disks: RAID 1 with two or even three disks or an SSD, before you even think about load balancing.
If your load line looks like the following:
Cpu(s): 43.0%us, 42.0%sy, 1.6%ni, 4.9%id, 5.4%wa, 0.0%hi, 3.0%si, 0.0%st
with almost all CPU time spent in userland (us) and system mode (us), then your CPU is overloaded. Check the lines below the heading in the top output to find out, which services (like apache2, tomcat, MySQL) have high cpu load. Then optimize your web application to reduce on cpu usage. If that doesn't help out, add more cpu cores to your server.
Last, but not least, check your memory with free
. If a large percentage of your memory is used, or swap is used more than a few kilobytes, add more memory.