Server Tips: Beginner’s Guide To Using Putty To Find Memory Usage Problems

/ Misc / by Paul Robinson / 5 Comments
This post was published back on July 7, 2011 and may be outdated. Please use caution when following older tutorials or using older code. After reading be sure to check for newer procedures or updates to code.

Having a server is great, especially if it is a VPS or a one of the few good shared hosters that allow SSH (shell) access. It is awful though when you start having problems with your server, what do you do? Well contacting your hosts support is always the best thing, but there are a few things you can do to check if the problem can be fixed straight away.

N.B. I would always recommend contacting your hosts support anyway as they will always be able to help you with your problem.

What is Putty?

Putty, or more precisely PuTTY is a telnet/ssh client used to connect to your server via a secure tunnel (of sorts). This allows you to run commands on the server as if you were sitting at it. Cool, huh? As *nix (Unix/Linux) servers are normally solely a command line (terminal) affair you can think of it as a DOS prompt. Take a look below.

Comparison of PuTTY terminal & a Windows DOS prompt

See how similar they are? Now let’s get into the good stuff.

Accessing Your Server With PuTTY

First thing you need is to check you have SSH access to your server. The best way is to check your hosts website. If they have a Wiki or FAQ check those for any mention of SSH or Shell and where or what the login details would be. If that fails contact your host and ask if they allow Secure Shell Access to the server and what your login details are. If, however, you are impatient you could always try your SFTP login details as they are sometimes the same as your SSH login.

Next up fire up PuTTY. Place your website’s domain name, or if different, what your host has suggested, in the ‘Host Name’ field and hit ‘Open’. You’ll be asked to enter the user & password details that I mentioned earlier. Oh, and yes it is perfectly normal that you don’t see the password as you are entering it.

Once you’ve logged in you might be thinking: “Oh, crap. Now what do I do? This is all very scary.” Well I’m here to say, don’t panic (We all know the answer is 42!). Let’s take a look at what we can do to diagnose any server problems.

Using PuTTY to Diagnose Problems

One of the most common problems on VPS or shared servers (especially those with resource limits) is running out of memory. If this happens you will experience anything from pages not loading at all, to ‘500 Internal Server Error’ messages. In WordPress you can also get random ‘404 Not Found’ errors when running memory intensive tasks such as posting a comment or publishing a post.

To see if this is the problem you will need to run a command called top. This is a system monitor for *nix systems, think Windows Task Manager.

Comparison Between Windows Task Manager & PuTTY Top Command

Above is the familiar (to most people) sight of the Windows Task Manager.

Comparison Between Windows Task Manager & PuTTY Top Command

That is the not so familiar (again to most people) sight of the *nix system monitor. You can see, however, if you look carefully that it gives pretty much the same information as the Windows Task Manager.

The best way to use top is to run top -c then hit Shift+M to order the processes by memory usage, that way you can see what is using the most memory. Now leave the PuTTY window open & use your browser to try and trigger the error on your website, or even just look at ‘xxxxxxk used, xxxxxxk free’ to see if the amount free drops too low. If it does drop too low, it could just be that you are running out of memory on your server.

If you are running your site on a shared server that probably won’t work. If you are lucky enough to have a shared hoster that does allow you to run top -c it will probably show the amount of memory available on the entire server. This isn’t really much help. Instead you need to ask your host how much memory your user is allow to use and then guestimate (add up the totals under the RES column) your total from the running processes. The thing to remember is that the totals are in bytes, unless it has a ‘k’ (kilobytes) or ‘m’ (megabytes) next to it.

Fixing The Problem

Unfortunately memory limitations are quite hard to get around. If you are running WordPress or a similar app you could try using a caching plugin, preferably with Mod_Rewrite as this will stop PHP from being called & save you a lot of memory. If you are on a VPS you could try disabling some features you aren’t using, if your host allows, or if you are up for it you could install Nginx or lighttpd which are lightweight alternatives to Apache. Failing the ability to reduce your memory usage, the only solution is to increase the amount of memory you have to play with.

That’s it

Those are the basics of how you can use PuTTY to debug memory problems on your server. I wrote this tutorial because of quite a few requests I’ve had regarding how I found out that my server was using too much memory (hence the recent server move), I hope it has answered your questions. Please remember that there are lots of other commands you can run via PuTTY, for example it is a lot quicker to delete a large amount of files via PuTTY than it is via SFTP.

If you have any questions about anything in this tutorial please let me know via the comments below and I’ll do my best to answer them. Thank you for reading.


Author’s gravatar

I just wanted to say that this post was EXTREMELY helpful. I’m a novice when it comes to such things as PuTTY, memory usage, and the whole bit – and I was having problems with my own site in regards to memory usage. It turns out I might have to get a private server to increase the amount of memory I have to use (I’m currently on a shared server).

Anyway, thanks for the enlightening read! I’m sure it also helped many others out there like me. 🙂


Author’s gravatar author

Hi Christina,

I’m glad the post was so helpful. I recently had to upgrade from shared to VPS as I’d started to hit the memory limit even with caching.

If you need you have any questions or need any help with regards to VPS or diagnosing any memory problems feel free to email me. I know how difficult it is to figure things out sometimes & I’m always happy to help out. 🙂

Author’s gravatar

If I want connect to my mssql db server over ssh tunneling. Can i do that by puTTy? i want to write data to database.

Author’s gravatar author

I believe you can, but it all depends on what access your host gives you. I’ve never worked with mssql before, but my host gives me SSH access to my main file server which has direct access to the MySQL server by running mysql from the terminal.

Author’s gravatar

Informative post, I also recommend using the ‘htop’ command, an interactive process viewer. run yum install htop first.

Older Comments
Newer Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

I'll keep your WordPress site up-to-date and working to its best.

Find out more