Closed sanchezpablo closed 3 years ago
When the server is idle (no requests) it should be taking up 0% CPU. Can you post some sample code for me to take a look at?
Hi @scottoffen I tried with the sample provided in the repository, but the same result, so I decided to left a comment, maybe it's something else... I've tried also with other embedded webserver (https://github.com/unosquare/embedio) and the CPU is 0% when the server is idle.
If you need more information, let me know.
How are you blocking the thread while the server is running? If you are just benchmarking, use this method:
server.Start();
Console.ReadLine();
I used the server.Run()
as in the sample, when I use server.Start()
the CPU gets down to 0% when idle. So the server.Run()
does something else in the background?
public static void Run(this IRestServer server)
{
server.Start();
while (server.IsListening) { }
}
Probably the while loop inside...
Thanks!
That while loop takes up a lot. I already changed it to poll the server at a predefined number of seconds, but that isn't in a release yet. I'll be changing it again soon to something more performant, so expect that to change.
Either way, when idle, the server takes up 0% cpu.
Is it normal that when server is running the CPU usage is 25% no matter what? there is no activity and the CPU usage is 25% continously.
Can we do anything to make it idle?