# Hot start

## Overview

Hot starting is creating a pool of sandbox instances that are instantly available when an end user starts your track. Without Hot Start, sandbox environments start on demand. This means end users have to wait for Instruqt to provision the sandbox environment before they can access them.&#x20;

{% hint style="warning" %}
**Billing**

You are billed for hot start sandboxes, even if end users are not using them.
{% endhint %}

## Manage hot start pools

### **Create an always hot pool**

Take the following steps to create an always hot pool:

{% tabs %}
{% tab title="🌐 Web UI" %}

1. Click **Settings -> Hot Start** to open the *Manage hot start* page.
2. Click **Create**.
3. Select the tracks or [sandbox presets ](https://docs.instruqt.com/sandboxes/manage/build-sandbox-presets)that you want to be preheated.
4. In the **Name** field, enter a name for the pool.
5. Use the **Region** dropdown to set where hosts are provisioned.
6. In the **Number of hot sandboxes per track/sandbox preset** field, enter your desired number.
7. For **Hot Start type**, select **Always hot**.
8. Click **Create**.
   {% endtab %}
   {% endtabs %}

{% hint style="info" %}
**Be cost-effective**

Start with a single instance in your hot start pool and increase the number if your end users experience delays. Since the pool refills automatically, you will rarely need more than four or five instances to ensure fast startup times for a steady flow of end users.
{% endhint %}

{% hint style="info" %}
💡 **Region Dropdown Not Visible?**

The ability to set the Region relies on the **Global Sandboxes** feature being enabled for your team.

\
If the **Region** dropdown is not visible on the **Create new Hot Start pool** page, please contact **support** to have the **Global Sandboxes** feature enabled for your team.
{% endhint %}

### Create a scheduled pool

Take the following steps to create a scheduled pool:

{% tabs %}
{% tab title="🌐 Web UI" %}

1. Click **Settings ->** **Hot start** to open the *Manage hot start* page.
2. Select **Create**.
3. Select the tracks or [sandbox presets](https://docs.instruqt.com/sandboxes/manage/build-sandbox-presets) that you want to be preheated.
4. In the **Name** field, enter a name for the pool.
5. Use the **Region** dropdown to set where hosts are provisioned.
6. In the **Number of hot sandboxes per track/sandbox preset** field, enter your desired number.
7. For **Hot Start type**, select **Scheduled**.
8. In the **Start provisioning on** field, select or enter the starting date when the pool should begin provisioning.
9. Select the **Starting time** when the pool should begin provisioning.
10. Select the **Time to live**.
11. Click **Create**.

{% hint style="info" %}
After the time to live expires for a scheduled hot start, Instruqt closes all **unclaimed** sandboxes.
{% endhint %}
{% endtab %}
{% endtabs %}

### Create hot starts from invites

You can link a Hot Start pool directly to a track invite. This ensures that the pre-provisioned sandboxes are reserved for learners using that specific invite link.

**Key behaviors:**

* **Automatic Sync:** The pool automatically inherits the tracks and expiration date from the linked invite.
* **Updates:** If you update the invite (e.g., change tracks or extend the expiration), the Hot Start pool updates automatically.
* **Dedicated Capacity:** The pool is used exclusively for the linked invite.

To create a linked pool:

{% tabs %}
{% tab title="🌐 Web UI" %}

1. Click **Share Content** to open the *Manage track invites* page.
2. Click the ••• of the track invite you want to create a hot start pool for.
3. Click **Create Hot Start pool** on the pop-up.\
   ↳ The *Create Hot Start* page opens, with the settings pre-filled and linked to the invite.
4. Check the settings and click **Create** to create the pool.
   {% endtab %}
   {% endtabs %}

### Duplicate hot start pools

Duplicate a hot start pool with the following steps:

{% tabs %}
{% tab title="🌐 Web UI" %}

1. Click **Settings -> Hot start** to open the *Hot start* page.
2. Click the ••• of the pool you want to duplicate.
3. Click **Duplicate** on the pop-up.\
   ↳ The *Create Hot Start* page opens, with the settings pre filled.
4. Check the settings and click **Create** to create the pool.
   {% endtab %}
   {% endtabs %}

### Delete hot start pools

Delete a hot start pool with the following steps:

{% tabs %}
{% tab title="🌐 Web UI" %}

1. Click **Settings -> Hot start** to open the *Hot start* page.
2. Click the ••• of the pool you want to delete.
3. Click **Delete** on the pop-up.\
   ↳ The *Delete Hot Start* confirmation opens.
4. Click **Confirm**.
   {% endtab %}
   {% endtabs %}

## Best practices

To ensure a smooth and efficient experience with the Hot Start feature, follow these best practices for setup, timing, and cost management.

### Use Track-Level Setup Scripts with Health Checks

The Hot Start feature relies on the successful completion of track-level setup scripts to determine if a sandbox environment is ready for a user.

* Track-level Setup Scripts: Ensure all tracks in your hot start pool use track-level setup scripts for all setup tasks. A successful setup script execution (exiting with a zero exit code) signals that the instance is ready.
* Challenge-level Setup Scripts: When you need to customize a sandbox environment for a specific user, you can leverage the setup script of the first challenge. This script will have user specific parameters injected as environment values. Keep in mind that this will add extra wait time for users, potentially rendering the Hot Start feature less useful.
* Implement Health Checks: Add health checks to the end of your setup scripts to verify the environment is fully functional. For example, you can try calling HTTP endpoints or check that all necessary containers are running.
* Automatic Retries: If a track setup fails (exits with a non-zero exit code), the instance will be terminated automatically, and a new one will be provisioned until the configured limit is reached. This mechanism ensures end users only access instances that provisioned correctly.

### Time Your Provisioning Strategically

Properly timing the provisioning of your hot start pool is crucial for having environments ready when your event starts.

* General Guideline: Start provisioning the hot start pool about one hour before your event begins.
* Adjust for Scale: You may need to start earlier if:
  * A single instance takes more than a few minutes to provision.
  * You are provisioning a very large pool of instances.
* Test Your Timing: It's a good practice to test your provisioning time to ensure everything is ready for your actual event.

### Terminate the Pool to Save Costs

Avoid unnecessary costs by terminating the hot start pool once most users have started their sessions.

* When to Terminate: A hot start pool typically doesn't need to run for more than 15 to 30 minutes after the session starts.
* Claimed vs. Unclaimed Instances: When a pool terminates, hot start instances claimed by users are not affected. Only unclaimed instances will be cleaned up.

### Aligning Region with End User Location for Optimal Performance

The **Region** setting is used to select the geographical location where the Hot Start sandboxes will be provisioned. Choosing a region is crucial for reducing the latency between the sandbox hosts and improving the overall end user experience. Select a region that is geographically closest to your target end users to ensure a faster, more responsive sandbox environment.

## FAQ

<details>

<summary>Why are my tracks taking awhile to load, even with hot start?</summary>

When you hot start a track, Instruqt pre-provisions sandboxes and runs all of the corresponding *Track* setup scripts. The initial *challenge's* setup script will not run until a user clicks **Launch** on your track. This means if the challenge setup script takes 3 minutes to complete, users will need to wait 3 minutes! You can mitigate this by placing as much configuration as possible in the initial Track setup script, and keeping the initial challenge setup script as simple as possible. \
\
**Note**: Certain user-related environment variables, such as `INSTRUQT_USER_ID`, will be empty if they are referenced within track setup scripts and hot started. In this case, you will need to leverage challenge setup scripts if you require those variables.&#x20;

</details>

<details>

<summary>How far in advance should I create my scheduled hot start pools?</summary>

The answer is, of course, it depends! Generally speaking, we recommend scheduling your hot start pools at least an hour ahead of when you'll need them. If you have very complex and long running setup scripts, consider adding more time.&#x20;

</details>

<details>

<summary>Why is my hot start pool filling so slowly?</summary>

Instruqt provisions hot start pools incrementally. At first, only a small batch of sandboxes (\~20) are provisioned. If all of the initial sandboxes deploy successfully, the amount of concurrent sandboxes provisioning increases. In the event errors are detected, Instruqt automatically reduces the number of concurrent sandboxes provisioning, preventing large of amounts of failures to occur.

</details>

## Video tutorial

You can also watch this video tutorial for an explanation of how hot start works:

{% embed url="<https://www.youtube.com/embed/KwCMkD6RFDc>" %}
