I tried Azure ephemeral OS Disk

目次

Japanese page is HERE

I tried Azure Ephemeral OS Disk on General Availability at July 1, 2019.

https://azure.microsoft.com/en-us/updates/azure-ephemeral-os-disk-now-generally-available/

A technology that mounts an OS disk on the cache area in the server where the virtual machine is hosted without using the Managed Disk or Storage Account vhd file for the OS disk of the IaaS virtual machine.

The OS disk is not persisted, but a managed disk can be used as an additional data disk.

How to use

It can be used with Azure portal, Azure CLI, and Azure Powershell. This time it tried using with Azure CLI.

https://docs.microsoft.com/en-us/azure/virtual-machines/windows/ephemeral-os-disks

Just add “–ephemeral-os-disk true –os-disk-caching ReadOnly” to the argument of “az vm create” command.

The created virtual machine does not have a managed disk, so you can save storage cost even if it is always running

img

Note that the virtual machine cannot be stopped while using the ephemeral OS disk (only deleted)

In addition, if the image size obtained from the Azure Marketplace is large, it cannot be deployed depending on the size of the virtual machine.

For example, in the case of Standard_DS1_v2, the cache size is 43GB, so it is possible to deploy a general Linux image, but in the case of Windows Server, it is usually a 127GB image, so it is necessary to select the Small Disk image (30GB) there is.

Standard_DS3_v2 has a cache size of 172GB, so it can be deployed even with an ordinary Windows Server image.

Details of this cache size can be confirmed in the list of each virtual machine in “Sizes for Windows virtual machines in Azure”.

Measure deployment time

Since I/O to the OS disk is faster, I thought that the load time of the application and the writing time of the temporary file would be faster, and the startup time of the OS would be faster.

This is the result of me measuring with a small number of times at an appropriate timing, so please look at the reference level

Measure the execution time of “az vm create” with Virtual Network, Public IP, and NIC created in advance.

I used “UbuntuLTS” for the Linux image and “MicrosoftWindowsServer:WindowsServer:2019-Datacenter-smalldisk:2019.0.20190603” for the Windows image.

Linux

Both ephemeral OS disks and managed disks have the same deployment time

I wonder if there is a difference in disk I/O in the OS boot sequence, but in the case of Linux, the OS boots up so fast that there is no difference in performance.

Windows

Is it because Windows reads a lot to the OS disk during the OS startup sequence?
On average, the ephemeral OS disk deployed faster than 30 seconds.

Consideration

Ephemeral OS disks are effective in creating a custom image with the necessary applications and services installed on both Linux and Windows and shortening the time required to use the required services.

It is also written in the official document

When using Virtual Machine Scale Set, a custom image is required, so in that case, you can save time by selecting an ephemeral OS disk.

I have written a script like the following and recently used it to use a Linux platform server cheaply only when necessary. For your information.

#!/bin/bash

# common
rgname=bastion-server-rg
location=japaneast

# vnet
vnet_name=bastion-vnet
vnet_cidr=192.168.0.0/24
vnet_subnet_name=default
vnet_subnet_cidr=192.168.0.0/24

# nsg
nsg_name=default-nsg

# vm
linuximage=UbuntuLTS
vmid=azureuser
vmpassword=*****(Your Password)
vmname=bastionvm
dnsname=xxxxxbastion
vmsize=Standard_DS1_v2

#
# create resource group
#
az group create --name $rgname --location $location

#
# create vnet
#
az network vnet create \
    --name $vnet_name \
    --resource-group $rgname \
    --location $location \
    --address-prefixes $vnet_cidr \
    --subnet-name $vnet_subnet_name \
    --subnet-prefixes $vnet_subnet_cidr

#
# create network
#
az network nsg create --name $nsg_name --resource-group $rgname --location $location
az network nsg rule create \
    --nsg-name $nsg_name \
    --resource-group $rgname \
    --name allow-ssh \
    --access allow \
    --protocol Tcp \
    --direction Inbound \
    --priority 1000 \
    --source-address-prefix Internet \
    --source-port-range "*" \
    --destination-address-prefix "*" \
    --destination-port-range 22

az network vnet subnet update \
    --resource-group $rgname \
    --vnet-name $vnet_name \
    --name $vnet_subnet_name \
    --network-security-group $nsg_name

az network public-ip create \
    --name ${vmname}-pip \
    --resource-group $rgname \
    --location $location \
    --allocation-method dynamic \
    --dns-name $dnsname

#
# create vm
#
az network nic create \
    --name ${vmname}-nic \
    --resource-group $rgname \
    --vnet-name $vnet_name \
    --subnet $vnet_subnet_name \
    --public-ip-address ${vmname}-pip

az vm create \
    --name $vmname \
    --resource-group $rgname \
    --location $location \
    --image $linuximage \
    --size $vmsize \
    --nics ${vmname}-nic \
    --admin-username $vmid \
    --admin-password $vmpassword \
    --ephemeral-os-disk true \
    --os-disk-caching ReadOnly