Skip to main content
When we deploy a service or job or any other application, we will need to define the resources that the application needs. This will ensure that Kubernetes can allot the correct set of resources and the application continues to run smoothly. There are a few key resources you will need to configure:

Setting Resources for your application

You can select the resources from the Resources section in the deployment form. The key things to fill up here are:
  1. Choose CPU or GPU along with its type.
  2. Fill up the CPU, Memory and Ephemeral Storage request and limit fields.
Requests should be set based on the minimum resources your application needs to function normally under load. Requests are guaranteed to be allocated to your application.Limits should be set to prevent the application from using more resources than is acceptable. Setting the limits higher than requests allows the application to burst if it requires more resources for a short duration. Limits define the maximum amount of resources a container is allowed to consume if there are extra resources available.If you are unsure about the limit, its usually a good idea to set it to twice the request. So if you are CPU request is 0.5, you can set the limit to 1. If you are requesting 1 GB RAM, you can set the limit to 2 GB.
  1. Select the capacity type - we have the following options here:
  • On-demand - This will deploy the application on on-demand instances.
  • Spot - This will deploy the application on spot instances.
  • Prefer Spot (with fallback on On-demand) - This will try to deploy the application on spot instances. If the spot instances are not available, it will bring up the application on on-demand instances. If a spot instance is preempted, we will try to replace it with another spot instance, failing which, it will be shifted to an on-demand instance.
Spot and on-demand instances are two types of instances offered by cloud providers like AWS, GCP, and Azure.On-demand instances are the standard, pay-as-you-go compute resources offered by cloud providers. You pay for the compute time you use, with no long-term commitments.Spot instances are spare compute capacity offered by cloud providers at a significantly discounted price (often up to 90% off the on-demand price). However, the catch is that the cloud provider can reclaim these instances with minimal notice (typically a 2-minute warning) if demand for that instance type increases. The spot prices also fluctuate based on demand and supply.Here’s an example of a snapshot of the spot vs on-demand prices of a few instance types in AWS, GCP and Azure:

Which capacity type option should I choose?

We usually recommend using the Prefer Spot (with fallback on On-demand) or Any(in Azure) option for all development workloads.For production services, if you are running more than 5 replicas of a service, we recommend using the Prefer Spot (with fallback on On-demand) option. Else, we recommend using the On-demand option. For jobs, we recommend using the On-demand option if your jobs are short (less than 3 hours). For long-running jobs, you can use the Prefer Spot (with fallback on On-demand) option only if you implement checkpointing and can resume from the last checkpoint where the earlier job was killed because of spot instance preemption.You almost never need to use the Spot option.
Spot instances are a good option for nodes when:
  • You are running multiple replicas of a service - hence the chances of all the spot machines going down at the same time is extremely low.
  • You are running a long running training job and saving checkpoints which allows you to resume the training from the last checkpoint in case the machine is taken away.
  • Your service can handle going down and restarting on a different node.
Truefoundry’s handling of the spot instances depends on the cloud provider. Here’s what happens in each of the cloud providers:
Truefoundry uses Karpenter to orchestrate spot and on-demand instance provisioning. Karpenter automatically monitors the availability of spot instances and can bring up another instance in case a spot instance is taken away. We configure Karpenter to prefer a balance between cost and availability - so that we don’t just prioritize the cheapest option always which might have a high rate of preemption. AWS also sends a signal 2 minutes before a spot instance is taken away. Truefoundry configures Karpenter to start bringing up a new instance the moment AWS sends this signal to reduce the node provisioning time to a few seconds.Because of this, the downtime of a pod to switch to another node is actually just a few seconds (depending on docker image download time) and hence spot instance based scheduling works quite well in AWS. We have also seen a average uptime of around 12 hours for spot instances - although this varies based on the region and the instance type.

Advanced Options

Selecting a specific instance type

We usually do not recommend selecting a specific instance type, unless you have a specific reason to do so - like improved performance on a specific instance type.
You can select an instance type by clicking on the Advanced Options button in Resources section and then selecting Instance Family option.

Selecting a Kubernetes nodepool

If you are using the nodepools in Kubernetes and want to specifically select a certain nodepool to deploy your application, you can do so by clicking on the Nodepool Selector option and then selecting the nodepool. We automatically parse the possible options from the available nodepools to show you the filtered set of nodepools - for e.g. if you select Spot, it will filter the set of nodepools that have spot instances.