Optimization of the Hive's IaaS Cloud host Quick Start
?? Use of Linux, do not use the desktop Technology (NO) (limited) Large (installed) take (X) cheese probably have experience, the computer's operating start time is very fast, often in a few seconds level of completion. But in the same non-desktop cloud host boot often give us is not such a feeling, especially in the first creation process, always found that the boot process needs to 10s+ time, so think, can also accelerate a, enjoy the second level of the cloud host start-up experience.
?? PS: At present, we use the Hive container is launched inside the virtual machine, the start speed of the cloud host is also an important part of the rapid start of the hive container.
1. First we analyze the startup process of the newly created cloud host
?? Here you only analyze some of the more critical steps, and some of the more time-consuming steps.
- The first step is to re-extend the partition table of the root partition and adapt the corresponding file system. We use a 2G size image when we create the image, but when we end up creating a cloud host with different specifications, we need to scale the partition to the size of the target specification and then use RESIZE2FS to extend the file system.
- Initializes network-related steps, including IP, routing, and other related parts of the network device.
- Cloud host initialization related work, where we use Cloud-init to do related initialization work, this part involves more work:
- Get meta data for a cloud host,
- Determine the life cycle of the cloud host and set up hostname based on meta data
- Generate Hostkey, inject the relevant login key,
- Launch related services such as openssh-server, the internal agent on-line indicates ready for container initialization service.
At this end, the start of the cloud host is basically complete, and the PAAs service takes over the baton and begins a further
?? below we have posted the original cloud host launch time chart
2. Next look at our means
?? As we can see in the figure, the cloud host startup took more than 10s plus time. The specific time and time of the analysis refer to the picture. We will explain the analysis results and optimization methods here.
- 1, cloud-init data source using 169.254 "EC2" data source is slow, switch to configdrive.
- 2, Cloud-init put multiple phases of the task in one phase, each phase of the task run will consume a relatively long time.
- 3, the switched network is obtained by DHCP to obtain the IP and route to be obtained by static IP injection.
- 4, the boot required mod are compiled in the kernel, remove the initrd part, and in the mirror when the system disk to achieve the target size (target default system disk 20G, all other data on the cloud drive)
In addition to 4th, the other parts we have released on-line, currently our online cloud host startup time is about 4.5s, if added 4th, over the completion of our goal-no more than 5 seconds of internal start-up time.
PS: Specific implementation process, if there is a problem or good advice, please contact [email protected]
3. Finally take a look at our results
?? Since we can see our demerit, is not very tempting, we have from the beginning of the 10s+ start time reduced to now more than 4 seconds. The 4th article above is not used again.
Optimization of the Hive's IaaS Cloud host Quick Start