21700: Install Bundler system-wide in Rails postinst
[arvados.git] / doc / admin / spot-instances.html.textile.liquid
1 ---
2 layout: default
3 navsection: admin
4 title: Using Preemptible instances
5 ...
6
7 {% comment %}
8 Copyright (C) The Arvados Authors. All rights reserved.
9
10 SPDX-License-Identifier: CC-BY-SA-3.0
11 {% endcomment %}
12
13 This page describes how to enable preemptible instances.  Preemptible instances typically offer lower cost computation with a tradeoff of lower service guarantees.  If a compute node is preempted, Arvados will restart the computation on a new instance.
14
15 Currently Arvados supports preemptible instances using AWS and Azure spot instances.
16
17 h2. Configuration
18
19 First, configure some @InstanceTypes@ that have @Preemptible: true@. For a preemptible instance, @Price@ determines the maximum bid price; the actual price paid is dynamic and will likely be lower.
20
21 Typically you want to add both preemptible and non-preemptible entries for each cloud provider VM type. To do this automatically, use @PreemptiblePriceFactor@ to enable a preemptible version of each listed type, using the given factor to set the maximum bid price relative to the non-preemptible price. Alternatively, you can configure preemptible instance types explicitly. For example, the following two configurations are equivalent:
22
23 <pre>
24 Clusters:
25   ClusterID:
26     Containers:
27       PreemptiblePriceFactor: 0.8
28     InstanceTypes:
29       m4.large:
30         ProviderType: m4.large
31         VCPUs: 2
32         RAM: 8GiB
33         AddedScratch: 32GB
34         Price: 0.1
35 </pre>
36
37 <pre>
38 Clusters:
39   ClusterID:
40     InstanceTypes:
41       m4.large:
42         ProviderType: m4.large
43         VCPUs: 2
44         RAM: 8GiB
45         AddedScratch: 32GB
46         Price: 0.1
47       m4.large.preemptible:
48         Preemptible: true
49         ProviderType: m4.large
50         VCPUs: 2
51         RAM: 8GiB
52         AddedScratch: 32GB
53         Price: 0.08
54 </pre>
55
56 Next, you can choose to enable automatic use of preemptible instances:
57
58 <pre>
59 Clusters:
60   ClusterID:
61     Containers:
62       AlwaysUsePreemptibleInstances: true
63 </pre>
64
65 If @AlwaysUsePreemptibleInstances@ is "true", child containers (workflow steps) will always select preemptible instances, regardless of user option.
66
67 If @AlwaysUsePreemptibleInstances@ is "false" (the default) or unspecified, preemptible instance are "used when requested by the user.":{{site.baseurl}}/user/cwl/cwl-run-options.html#preemptible
68
69 Note that regardless of the value of @AlwaysUsePreemptibleInstances@, the top level workflow runner container always runs in a reserved (non-preemptible) instance, to avoid situations where the workflow runner is killed requiring the entire to be restarted.
70
71 No additional configuration is required, "arvados-dispatch-cloud":{{site.baseurl}}/install/crunch2-cloud/install-dispatch-cloud.html will now start preemptible instances where appropriate.
72
73 h3. Cost Tracking
74
75 Preemptible instances prices are declared at instance request time and defined by the maximum price that the user is willing to pay per hour. By default, this price is the same amount as the on-demand version of each instance type, and this setting is the one that @arvados-dispatch-cloud@ uses for now, as it doesn't include any pricing data to the spot instance request.
76
77 For AWS, the real price that a spot instance has at any point in time is discovered at the end of each usage hour, depending on instance demand. For this reason, AWS provides a data feed subscription to get hourly logs, as described on "Amazon's User Guide":https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-data-feeds.html.
78
79 h2. Preemptible instances on AWS
80
81 For general information, see "using Amazon EC2 spot instances":https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-spot-instances.html.
82
83 h3. Permissions
84
85 When requesting spot instances, Amazon's API may return an authorization error depending on how users and permissions are set on the account. If this is the case check logs for this error:
86
87 <pre>
88 BaseHTTPError: AuthFailure.ServiceLinkedRoleCreationNotPermitted: The provided credentials do not have permission to create the service-linked role for EC2 Spot Instances.
89 </pre>
90
91 The account needs to have a service linked role created. This can be done by logging into the AWS account, go to _IAM Management_ &rarr; _Roles_ and create the @AWSServiceRoleForEC2Spot@ role by clicking on the @Create@ button, selecting @EC2@ service and @EC2 - Spot Instances@ use case.
92
93 h3. Interruption notices
94
95 When running a container on a spot instance, Arvados monitors the EC2 metadata endpoint for interruption notices. When an interruption notice is received, it is reported in a log entry in the @crunch-run.txt@ file as well as @warning@ and @preemptionNotice@ keys in the @runtime_status@ field of the affected container.
96
97 Example excerpt from @crunch-run.txt@:
98
99 <pre>
100 2023-02-21T21:12:42.350719824Z Cloud provider scheduled instance stop at 2023-02-21T21:14:42Z
101 </pre>
102
103 Example @runtime_status@:
104
105 <pre>
106 {
107   "warning": "preemption notice",
108   "warningDetail": "Cloud provider scheduled instance stop at 2023-02-21T21:14:42Z",
109   "preemptionNotice": "Cloud provider scheduled instance stop at 2023-02-21T21:14:42Z"
110 }
111 </pre>
112
113 h2. Preemptible instances on Azure
114
115 For general information, see "Use Spot VMs in Azure":https://docs.microsoft.com/en-us/azure/virtual-machines/spot-vms.
116
117 When starting preemptible instances on Azure, Arvados configures the eviction policy to 'delete', with max price set to '-1'. This has the effect that preemptible VMs will not be evicted for pricing reasons. The price paid for the instance will be the current spot price for the VM type, up to a maximum of the price for a standard, non-spot VM of that type.
118
119 Please note that Azure provides no SLA for preemptible instances. Even in this configuration, preemptible instances can still be evicted for capacity reasons. If that happens and a container is aborted, Arvados will try to restart it, subject to the usual retry rules.
120
121 Spot pricing is not available on 'B-series' VMs, those should not be defined in the configuration file with the _Preemptible_ flag set to true. Spot instances have a separate quota pool, make sure you have sufficient quota available.