DEV Community

Mahesh
Mahesh

Posted on

Manage vps RAM usage by docker containers

I recently had an issue where I couldn't connect to my VPS server. I thought it was an internet connection issue, but it turned out to be high RAM usage on my server.

I tried to find a monitoring tool to help me figure out what was going on, but the information I found was too lengthy and didn't seem relevant to my specific issue.

In the end, I figured out a quick way to fix the problem myself. Here's what I did:

  1. get list of docker containers according to their RAM/Memory-Usage using docker stats
docker stats --no-stream --format "table {{.Name}}\t{{.MemUsage}}" | sort -k 2 -hr
# --no-steam: by default docker stats is streams information, which sometimes hangs 
#    command line --no-stream ask stats one time instead of streaming
# sort -k 2: sort list considering 2nd column which is MemUsage here
# sort -hr: h represents human-redable number, r represents reverse (descending order)
Enter fullscreen mode Exit fullscreen mode
  1. shut down or delete unnecessory containers using docker stop

And that's it, you can check again the reduced RAM usage on vps server by running htop

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more →

Top comments (0)

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more →