During the last week, we have seen an increasing number of people having issues with debugging in VS Code against a Docker Container running Business Central. At the same time, we had a LOT of people using VS Code and the debugger every day with absolutely no issue.
As always, when trying to find the root cause of things is to find the common denominator for the people who are having problems – and they were in all areas. Some were using Windows 10 1609, some 1809 or 1903. Some where using Windows Server 2019. Some process isolation, some hyperv isolation. Some Windows Authentication, some NavUserPassword – really not easy to find any common ground.
In the end, Torben Wind Mayhoff managed to find the common denominator – in all situations, the container had only one CPU core (2 logical processors) assigned and with this information he immediately turned his focus on the thread throttling feature.
In Business Central Spring 2019 release, a new feature called thread throttling is created to avoid noisy neighbors. It allows us to lower the priority on threads in order to allow other threads to complete. This feature should not be enabled when you run with only 2 logical processors and we will fix the platform to disable thread throttling if you have less than 4 logical processors available.
While waiting for the fix, you have a few options:
You need to set EnableThreadThrottling and EnablePrioritizedThreadThrottling to false in CustomSettings.config.
When using New-NavContainer, you can specify additional native Docker paramaters using additionalParameters. Using the –env docker parameter, you can transfer parameters like CustomNavSettings to the Business Central Container to set custom settings for the Service Tier:
-additionalParameters @("--env CustomNavSettings=EnableThreadThrottling=False,EnablePrioritizedThreadThrottling=False")
During startup of the Container, it should display:
Modifying Service Tier Config File with settings from environment variable
Creating EnableThreadThrottling and setting it to False
Creating EnablePrioritizedThreadThrottling and setting it to False
Starting Service Tier
The other way of fixing the issue is to allow the container to use more logical processors. This will of course only work if the host has 4 or more logical processors.
When using New-NavContainer, you can specify additional native Docker paramaters using additionalParameters. Using the –cpu-count you can set the number of logical processors available to the container:
-additionalParameters @('--cpu-count 4')
You will not see this during startup of the container, but if you want to see how many logical processors your container has available you can issue this command in the Cmd prompt:
C:\>docker exec <containername> wmic cpu get NumberOfLogicalProcessors
I am considering to help partners using NavContainerHelper to automatically disable Thread Throttling if you have less than 4 logical processors (this will be the behavior in next version anyway).