Does it make sense to run a c# worker service in docker?

后端 未结 2 1724
青春惊慌失措
青春惊慌失措 2021-01-07 09:41

I am developing a multi-container app in docker. One of the services is a long-running console application in C# which basically does some polling on a database and sending

2条回答
  •  难免孤独
    2021-01-07 10:10

    If you are always going to run in a container, then go with a console app. I see no inherent benefit of running as a service since containers, under proper orchestration such as Kubernetes, should be considered ephemeral. Also, you will have less friction in running your .NET Core 3.1.x application as a Linux or Windows container if you keep it simple i.e. console.

    Also, I would use the following line in your console to ensure it plays nice with the allocated CPU for the container:

    while(true)
    {
        Thread.Sleep(1 * 1000);
    }
    

提交回复
热议问题