Share via

Mutithreading in Azure Container Apps & Container CPU Cores

Martin Kaiser 16 Reputation points
2023-12-09T18:28:38.12+00:00

Hello,

I'm getting an application ready for a production release in Azure Container Apps and I'm trying to do some multithreading optimization but I've been a bit confused as to how many CPU cores a single container instance/replica has access to. I've been setting my Azure Container Apps scale core limit per instance between 1-2 cores, then doing some load testing on the API and monitoring top in one or more instance. The odd thing I've found is that top and lscpu seem to list the cores available as 4 most of the time, but sometimes it will list 8 cores available. I can't seem to figure out what determines the count between 4 and 8. Scaling doesn't seem to be the factor, it almost seems random.

Does anyone know how the cores work inside the container itself, and how best to optimize for mutlithreading? My application can use as many cores as it's given, but I'd like to make sure I'm putting a limit on that to get the fastest response time and have consistency across all the replicas, especially since we can scale the app horizontally anyways.

I've thought about trying to set --cpus in the Docker image to see what happens but figured it was worth asking the community before I spend the time and money re-running the load tests.

Thanks

Azure Container Apps
Azure Container Apps

An Azure service that provides a general-purpose, serverless container platform.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.