Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG:Abnormal high CPU usage #23

Open
xczh opened this issue Feb 18, 2021 · 22 comments
Open

BUG:Abnormal high CPU usage #23

xczh opened this issue Feb 18, 2021 · 22 comments

Comments

@xczh
Copy link

xczh commented Feb 18, 2021

When I used it with dnsmasq for a while, I observed abnormal high CPU usage, as shown in the screenshot.

image

I use strace to try to track PID 13544, which shows that the program is blocking the waitid system call, and there is no other information. Through the top command, I learned that CPU time is basically spent in us state, not sys state.

This situation has been going on for 24 hours, and it doesn't seem to be a problem of 'dnsmasq'. What happened to 'webproc'?

@xczh
Copy link
Author

xczh commented Feb 18, 2021

@jpillora I need help, thanks :)

@jpillora
Copy link
Owner

jpillora commented Feb 18, 2021 via email

@xczh
Copy link
Author

xczh commented Feb 18, 2021

No, the log frequency is about 1 line/s.

And this phenomenon is only recently. Before, I used v0.3.0 version to run stably for nearly a year, and did not find this problem. I upgraded to version v0.4.0 the day before yesterday, and this problem occurred two days after running.

@xczh
Copy link
Author

xczh commented Feb 18, 2021

In order to eliminate the problem of dnsmasq, I rerun the program. I used mpstat 1 to print out the CPU utilization per second, and found a very interesting phenomenon.

# webproc -c /etc/dnsmasq.conf -p 80 --user test --pass 123456 -- mpstat 1

image

After the program runs for 2 minutes, the CPU utilization rate is still as high as 100%.

These are mpstat output:

⁣09:22:39     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
⁣09:22:40     all    0.00    0.00    0.00    0.00    0.25    0.25    0.00    0.00   99.50
⁣
⁣09:22:40     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
⁣09:22:41     all    0.00    0.00    0.25    0.00    0.00    0.00    0.00    0.00   99.75
⁣
⁣09:22:41     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
⁣09:22:42     all    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00

......

⁣09:24:24     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
⁣09:24:25     all    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00  100.00
⁣
⁣09:24:25     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
⁣09:24:26     all    0.00    0.00    0.00    0.00    0.00    0.25    0.00    0.00   99.75
⁣
⁣09:24:26     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
⁣09:24:27     all    0.00    0.00    0.25    0.00    0.00    0.00    0.00    0.00   99.75
⁣
⁣09:24:27     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
⁣09:24:28     all    4.52    0.00    0.50    0.00    0.25    0.00    0.00    0.00   94.72
⁣
⁣09:24:28     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
⁣09:24:29     all   16.08    0.00    1.51    0.00    0.50    0.50    0.00    0.00   81.41
⁣
⁣09:24:29     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
⁣09:24:30     all    0.25    0.00    0.00    0.00    0.25    0.00    0.00    0.00   99.50
⁣
⁣09:24:30     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
⁣09:24:31     all   18.30    0.00    3.51    0.00    0.50    0.00    0.00    0.00   77.69
⁣
⁣09:24:31     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
⁣09:24:32     all   17.97    0.00    0.51    0.00    0.51    0.00    0.00    0.00   81.01
⁣
⁣09:24:32     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
⁣09:24:33     all   17.88    0.00    0.76    0.00    0.76    0.25    0.00    0.00   80.35
⁣
⁣09:24:33     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
⁣09:24:34     all   18.18    0.00    0.76    0.00    0.51    0.00    0.00    0.00   80.56
⁣
⁣09:24:34     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
⁣09:24:35     all   19.10    0.00    0.50    0.00    0.75    0.00    0.00    0.00   79.65
⁣
⁣09:24:35     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
⁣09:24:36     all   19.24    0.00    0.76    0.00    0.51    0.00    0.00    0.00   79.49
⁣
⁣09:24:36     CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
⁣09:24:37     all   18.94    0.00    0.76    0.00    0.76    0.00    0.00    0.00   79.55

Since then, CPU usage has remained at this level.

@jpillora

@jpillora
Copy link
Owner

jpillora commented Feb 18, 2021 via email

@xczh
Copy link
Author

xczh commented Feb 18, 2021

I just executed this command:

webproc -c /etc/dnsmasq.conf -p 80 --user test --pass 123456 -- mpstat 1

and then open the browser to access: http://localhost.

mpstat 1 prints CPU usage every second.

@jpillora
Copy link
Owner

jpillora commented Feb 18, 2021 via email

@xczh
Copy link
Author

xczh commented Feb 18, 2021

Exactly. I find that if I don't open the browser, the CPU usage is always less than 0.5%. Once you open your browser, it's 100% in a flash. But why is that?

Will JavaScript scripts affect the CPU utilization of the server?

@jpillora
Copy link
Owner

jpillora commented Feb 18, 2021 via email

@xczh
Copy link
Author

xczh commented Feb 18, 2021

Fedora 33, amd64

@jpillora
Copy link
Owner

jpillora commented Feb 18, 2021 via email

@xczh
Copy link
Author

xczh commented Feb 18, 2021

In addition, I suggest adding the net/http/pprof HTTP endpoint to facilitate troubleshooting.

@xczh
Copy link
Author

xczh commented Feb 18, 2021

It seems that this problem does not exist in v0.3.0. Can I switch back to the old version? What are the disadvantages?

@jpillora
Copy link
Owner

jpillora commented Feb 18, 2021 via email

@xczh
Copy link
Author

xczh commented Feb 18, 2021

image

I was wrong. Just now, I spent more than an hour retesting the v0.3.0 version and found that the leak still exists. CPU usage is increasing at a very slow rate, but it does continue to increase. This can lead to problems that are hard to detect and I've ignored in the past year.

In the version of v0.4.0, the CPU consumption increases rapidly when using the browser to access the page, which leads to the problem being found quickly.

This problem looks SERIOUS and needs to be fixed. Before the problem is solved, I think I can only disable webproc.

Or are there any effective measures?

@jpillora
Copy link
Owner

jpillora commented Feb 18, 2021 via email

@Schwobaland
Copy link

I have the same problem. Setting the max-lines to 100 didn't help...

@jpillora
Copy link
Owner

jpillora commented Mar 9, 2021 via email

@Schwobaland
Copy link

Arm64. What helped, was disabling the logs for the webui - with the downside of missing logs in the webui.
-l proxy

By the way - thanks for creating webproc!!

@rinex20
Copy link
Contributor

rinex20 commented May 2, 2022

I had the same issue like above. @jpillora
ubuntu x86_64.

@rinex20
Copy link
Contributor

rinex20 commented May 2, 2022

I had the same issue like above. @jpillora ubuntu x86_64.

finally,
downgrade to 0.3.3 to fix this high cpu usage.

@ThorstenKunz
Copy link

ThorstenKunz commented Jul 25, 2022

Same issue with 0.4.0. I added "-l proxy" and that solved it. Running on
Linux raspberrypi 5.4.0-1066-raspi #76-Ubuntu SMP PREEMPT Mon Jun 27 11:02:52 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants