Determining RAM Usage on Shared Hosting

From OCS Support Wiki

Jump to: navigation, search

Contents

[edit] Introduction

We limit the amount of RAM available to you in our shared hosting environment to improve the quality of service by ensuring that resources are available for all users in the same amount. It can be difficult sometimes to determine how much memory you are using, so the goal of this article is to show you how to obtain your current memory usage.

[edit] The memory_usage Script - Recommended

The easiest way to see how much RAM you're using is via the memory_usage script. Simply run (via SSH):

memory_usage

and the total memory usage will be displayed to you.

[edit] Using the ps Command

The best way to determine memory usage is to make an SSH connection to your account and run:

ps ux

This command will produce a display similar to this:

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
example  13315  0.0  0.0   7872  1840 ?        S    13:46   0:05 sshd: example@pts/0
example  17943  0.0  0.0   5584  3216 pts/6    Ss+  14:10   0:00 -bash
example  23470  0.1  0.8  48380 35864 ?        Sl   19:00   0:02 ruby mongrel_rails
example    725  0.0  0.0   2472   984 pts/7    R+   19:30   0:00 ps ux

The command column has been truncated in this example to allow it to fit on the page. In this example, one Mongrel process is running, serving a Rails application to Apache. You can also see your current SSH session and bash shell. The ps command is running too, although it only ran to produce this report and is not considered a running process.

To determine the RAM usage of your account, add the values in the "RSS" (which stands for resident set size) column. This is the active RAM you are using on the server. In the above case, this is 40920 KiB, or 39 MiB (divide the kilobytes by 1024 to obtain the megabytes used). For the purposes of this calculation, I have excluded the memory consumed by the ps command.

[edit] Soft Limits

The memory limits we impose are soft, not hard, so if you temporarily go over the limit your applications will not terminate or your site will not be shut down. If we do notice you going over the limit consistently, we will let you know. In extreme cases of memory leaks, we may restart your application to resolve the problem. While we do reserve the right to terminate an application causing disruption or excessive memory usage over plan allotment, we only do this in the most extreme circumstances, and if at all possible contact you first to both notify you and assist you with either brining the memory usage down or adjusting your plan's limits.