reverse-proxy icon indicating copy to clipboard operation
reverse-proxy copied to clipboard

YARP has a higher cpu usage than Nginx

Open doddgu opened this issue 1 year ago • 28 comments

Sorry, I don't know if it is a bug.

Describe the bug

I deployed 3 nginx at HongKong, and deployed 3 YARP at HangZhou.

Client -> Nginx -> Yarp -> Service

Nginx forwards some services, and YARP forward one of them.

Nginx CPU image

YARP CPU image

YARP other metrics image

Htop (Cat.Service.dll is based on YARP) image

I tried to analyze the CPU on vs Top function image

Module View image

To Reproduce

No exception.

Further technical details

  • Include the version of the packages you are using 2.1.0
  • The platform (Linux/macOS/Windows) Linux

They're all 4c8g, YARP on ubuntu 22.04, nginx on centos. YARP 2.1.0 runs on .NET 8.

doddgu avatar Mar 04 '24 10:03 doddgu

How does the load / RPS compare?

Tratcher avatar Mar 04 '24 16:03 Tratcher

How does the load / RPS compare?

Every YARP is almost 4000 image

doddgu avatar Mar 05 '24 02:03 doddgu

I loaded pdb. I find that the Thread in WorkerThreadStart method. The Thread.CurrentThread.SetThreadPoolWorkerThreadName() takes up a lot of CPU resources.

I don't know why have to call WorkerThreadStart so many times.

image

image

image

doddgu avatar Mar 05 '24 03:03 doddgu

I used YARP source code analysis, I found that YARP itself does not have high cpu usage.

image

doddgu avatar Mar 06 '24 05:03 doddgu

Hi @MihaZupan , any news?

doddgu avatar Mar 08 '24 02:03 doddgu

Is it related to the https://github.com/dotnet/runtime/issues/70098 And I see there's pr to fix it

doddgu avatar Mar 11 '24 10:03 doddgu