As we can limit the CPU resources for the containers on Docker (--cpus cmd) as well as Kubernetes (-cpulimit) platform.
Is there any way to limit the CPU for application running on PCF?
As we can limit the CPU resources for the containers on Docker (--cpus cmd) as well as Kubernetes (-cpulimit) platform.
Is there any way to limit the CPU for application running on PCF?
This happens automatically on Cloud Foundry.
Applications that run on Cloud Foundry are limited based on CPU shares (same as docker's --cpu-shares
option). The number of CPU shares assigned to an application is propotionate to the size of the memory limit given to the application. More memory means more CPU shares.
The exact number of shares doesn't really matter, its just the proportions that matter. If your app has a larger number of shares than other apps running on the Cell, it'll get more CPU time. If it has a smaller number of shares, it'll get less time. You can use the memory limits to gauge if an app is smaller, the same or larger than other apps running on the Cell.
The tricky part is that there's no easy way to tell what else is running on the Cell, short of being an operator and looking at the Cells. Hopefully, CPU share information and throttling metrics will be exposed through Loggregator in the future, as this would make it easier to understand how your app is utilizing the CPU time it gets.
If you want to see the exact formula used to determine CPU shares, you can check out this documentation link. It goes into more depth explaining how the platform makes these calculations.
https://docs.cloudfoundry.org/concepts/container-security.html#cpu
It's not currently possible to limit CPU usage based on the number of CPU cores, like Docker's --cpus
argument.