WebFaction
Community site: login faq

I've been using a script I found here on the WF support community to keep an eye on my memory management for a while. The command is ps -u username -o rss,command

When I run this, it shows me 8 Nginx worker processes, which is exactly the amount I've configured my private Nginx server to use. However when I run htop -u username it shows me over thirty Nginx worker processes. It also shows more mysqld processes than the ps command shows me, far more than I have configured to work with my private MySQL server. uWSGI shows the correct amount of worker processes in both ps and htop.

What would account for this discrepancy? Is there a way I should be fine-tuning htop to work correctly in a shared environment that I'm not doing? I'd like to use htop instead of ps for better real-time feedback as I tweak my servers to stay within memory allotments. I need to know it's giving me correct output though.

asked 08 Sep '13, 16:42

HittingSmoke
4822430
accept rate: 8%


Hello,

By default, the 'ps' command only displays processes. On the other hand, 'htop' shows threads. That's why 'htop' will always show more items than 'ps'.

If you want to view per-thread statistics with the 'ps' command, then use the '-L' flag, something like this:

ps -Lfu $USER

(Note, for memory counting purposes, you would never want to analyze the threads. You would only want to look at the process level, since threads share memory.)

Regards,

~Christopher S, WebFaction Support

permanent link

answered 08 Sep '13, 17:06

likebike
3366
accept rate: 28%

Interesting. According to the Nginx docs:

A worker process is a single-threaded process.

I understood uWSGI was not running multiple threads because I have it configured explicitly not to do so. Such an option doesn't exist in Nginx as I thought it was bound to a single thread per process.

This is probably going to raise more questions now about optimizing Nginx since it's not running the way I believed it was.

(08 Sep '13, 17:37) HittingSmoke
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×87
×10

question asked: 08 Sep '13, 16:42

question was seen: 3,208 times

last updated: 08 Sep '13, 17:37

                              
WEBFACTION
REACH US
SUPPORT
LEGAL
© COPYRIGHT 2003-2021 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM