Skip to content
Advertisement

Nancy on Linux is using 100% CPU

My nancy web-apps are using up together 100% CPU without them actually being used.

They are running inside a docker container on mono. The only thing I could think about to cause this, would be the endless loop in my main function, something like

while(Console.ReadLine() != "quit") {}

but I thought, Console.ReadLine() would be blocking and therefore this loop would only execute, whenever there is some input, which there shouldn’t be ever. Amy I missing something? Are there other reasons for nancy to use up all the CPU in mono? – In Windows during development it seems to run fine.

Update:

The application in docker is simply started with mono NancyServer.exe. The memory usage is much lower than the previous XPS-base version (50-70MB instead of 160-180MB), but the XPS-based application uses less than 0.1% of CPU (also not really doing anything)

Advertisement

Answer

I can reproduce the non-blocking behaviour by starting a container in the foreground if none of the -t or -i options are used. In that particular case then Console.ReadLine() won’t block.

If either -i or -t is used, then Console.ReadLine blocks. Also if I run the container in the background (with the -d option), Console.ReadLine() is blocking.


Make sure to use either -t or -i if you run your container in the foreground.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement