Accelerate container startup time on Amazon EKS with SOCI parallel mode

Container images pull performance has become a bottleneck as container images grow larger, compared to when typical images were just a few hundred megabytes. While SOCI snapshotter is known for its lazy loading capabilities that dramatically reduce container startup times, v0.11.0 introduced a powerful new feature that addresses a different approach: parallel pull/unpack mode. This mode represents a shift from on-demand lazy loading to high-performance upfront image loading through concurrent operations.

This article is now out dated, SOCI parallel mode is now officially built into AL2023 and Bottlerocket latest AMIs, For more information:

Introduction

 SOCI  (Seekable OCI), pronounced "so-CHEE" is an open-source containerd snapshotter plugin developed by AWS that enables standard OCI images to be optimally pulled without requiring image modification. Traditional container pull process follows a sequential process where the entire container image must be downloaded and extracted before the container can start. SOCI disrupts this model by providing two distinct optimization approaches:
  • Lazy Loading Mode: Downloads only necessary file chunks on-demand using FUSE filesystem mounts
  • Parallel Pull/Unpack Mode: Introduced in v0.11.0, accelerates traditional upfront pulling through concurrent downloading and unpacking.
This article explores SOCI's parallel pull/unpack mode for users that prefer a more consistent startup time that requires complete image availability and explains how this mode significantly improve the performance of the upfront traditional container image pull process.

Understanding Parallel Pull/Unpack Mode

The parallel pull/unpack mode implements several key optimizations:
  • Chunked Layer Downloads: Large container layers are divided into smaller chunks that can be downloaded concurrently, similar to the  multi-part fetch  feature introduced in containerd 2.1.
  • Temporary File Buffering: Instead of using in-memory buffers, downloaded data is written to a temporary file on disk.
  • Parallel Decompression: As each layer finishes downloading, it begins unpacking the layer - allowing smaller layers to decompress and extract while larger layers are still being downloaded. the unpack operation is being done in parallel and multiple layers are decompressed and extracted concurrently.

Performance Benefits

This combined parallelization approach result in significantly faster image pulls, particularly on more powerful hardware configurations. The performance gains are most pronounced when:
  • Working with large container images with multiple substantial layers
  • Running on systems with high CPU core counts and fast storage
  • Operating in environments where network bandwidth allows for concurrent downloads
  • Using container registries that support efficient range requests such as  Amazon ECR .

Considerations

When implementing parallel pull/unpack mode, consider the following:
Hardware Requirements: Ensure your infrastructure can support concurrent operations. The parallel mode benefits most from:
  • Multi-core processors for parallel decompression
  • Fast storage systems (SSD/NVMe) for efficient I/O operations
  • Sufficient network bandwidth for concurrent downloads
Registry Compatibility: Verify that your container registry supports efficient range requests and can handle concurrent chunk downloads without throttling.
Monitoring and Optimization To maximize the benefits of parallel pull/unpack mode:
  • Monitor Resource Utilization: Track CPU, memory, and I/O usage during image pulls to ensure optimal parallelization without resource contention.
  • Measure Pull Performance: Compare pull times before and after enabling parallel mode to quantify improvements for your specific workloads.
  • Tune Concurrency Settings: Adjust the level of parallelization based on your hardware capabilities and registry performance characteristics.

Configuration

The parallel-pull-unpack mode configuration is controlled by several key settings. While the default values align with containerd's standard configuration to ensure stability and safety, you can adjust these parameters to optimize performance based on your specific needs:
  •  max_concurrent_downloads : Sets the maximum number of concurrent downloads allowed across all images. Default is -1 (unlimited).
  •  max_concurrent_downloads_per_image : Limits the maximum concurrent downloads per individual image. Default is 3.
  •  concurrent_download_chunk_size : Specifies the size of each download chunk when pulling image layers in parallel. Default is empty (size of layer), for Amazon ECR, the recommended chunk size is "16mb".
  •  max_concurrent_unpacks : Sets the maximum number of concurrent layer unpacking operations system-wide. Default is -1 (unlimited).
  •  max_concurrent_unpacks_per_image : Sets the limit for concurrent unpacking of layers per image. Default is 1.
  •  discard_unpacked_layers : Controls whether to retain layer blobs after unpacking. Enabling this can reduce disk space usage and speed up pull times. Default is false.
  •  decompress_streams : Allows customizing the decompressor executable used for layer extraction. Default is "unpigz".
  •  root path : where downloaded data is stored and extracted, this path should be backed by an high performance storage subsystem. Default is "/var/lib/soci-snapshotter-grpc" This configuration can only be set when running the soci-snapshotter-grpc daemon.

Setup

The following describe the process to download, install and configure SOCI on Amazon EKS.
  1. Download and Install the SOCI snapshotter binary daemon:  soci-snapshotter-grpc 
  1. Configure the SOCI snapshotter by creating a  config.toml  file.
  1. Setup SOCI snapshotter service by configuring a SOCI snapshotter  systemd  file.
  1. Configure  containerd 
  1. include the SOCI snapshotter plugin
  1. Configure default runtime to use SOCI snapshotter
  1. Set  disable_snapshot_annotations  to  false 
  1. Configure  kubelet  to use SOCI's imageService proxy to pass registry credentials.
To simplify steps 1 to 3, We have created an  installation script  that download, install and configure the SOCI snapshotter.

Amazon EKS AL2023 example

The following is a userData example for Amazon Linux 2023 EKS Optimized AMI on using the  installation script  to setup SOCI.
It utilize  nodeadm  via NodeConfig userData to run the script and configure both containerd and kubelet. (steps 4,5)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="//"

--//
Content-Type: text/x-shellscript; charset="us-ascii"

#!/bin/bash
export max_concurrent_downloads_per_image=10
export max_concurrent_unpacks_per_image=10
curl -sSL https://raw.githubusercontent.com/awslabs/soci-snapshotter/45def2dcf87781de75634f5e2744b73fdb2dd8aa/scripts/parallel-mode-install.sh | bash

--//
Content-Type: application/node.eks.aws

apiVersion: node.eks.aws/v1alpha1
kind: NodeConfig
spec:
kubelet:
config:
imageServiceEndpoint: unix:///run/soci-snapshotter-grpc/soci-snapshotter-grpc.sock
containerd:
config: |
[proxy_plugins.soci]
type = "snapshot"
address = "/run/soci-snapshotter-grpc/soci-snapshotter-grpc.sock"
[proxy_plugins.soci.exports]
root = "/var/lib/soci-snapshotter-grpc"
[plugins."io.containerd.grpc.v1.cri".containerd]
snapshotter = "soci"
disable_snapshot_annotations = false
--//

Karpenter

To use SOCI snapshotter's parallel pull/unpack mode on Karpenter provisioned nodes, you can use the following  EC2NodeClass  example as a reference.
  1. Configures root volume EBS  spec.blockDeviceMappings : 100GB, IOPs: 16,000, Throughput: 1000MB/s This is configured to prevent I/O bottlenecks when downloading and unpacking the image layers.
  1. If Adding  spec.instanceStorePolicy: RAID0  - Karpenter will setup instance store NVMe disks (stripe, format, and mount), this will also make containerd root dir ( /var/lib/containerd ) on the instance store disks. If using the  EC2NodeClass  only for instances that has instance store, omitting  spec.blockDeviceMappings  and adding  spec.instanceStorePolicy: RAID0  can reduce cost and improve performance as SOCI is configured below to use the containerd root dir to store data.
  1. Configure  max_concurrent_downloads_per_image=10  and  max_concurrent_unpacks_per_image=10  For large instances (>8xlarge), configuring  max_concurrent_downloads_per_image=32  and  max_concurrent_unpacks_per_image=12  will yield better performance
apiVersion: karpenter.k8s.aws/v1
kind: EC2NodeClass
metadata:
name: soci-snapshotter
spec:
role: "KarpenterNodeRole"
blockDeviceMappings:
- deviceName: /dev/xvda
ebs:
volumeSize: 100Gi
volumeType: gp3
iops: 16000
throughput: 1000
subnetSelectorTerms:
- tags:
karpenter.sh/discovery: "demo-cluster"
securityGroupSelectorTerms:
- tags:
kubernetes.io/cluster/demo-cluster: owned
amiSelectorTerms:
- alias: al2023@latest
userData: |
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="//"

--//
Content-Type: text/x-shellscript; charset="us-ascii"

#!/bin/bash
export max_concurrent_downloads_per_image=10
export max_concurrent_unpacks_per_image=10
export soci_root_dir=/var/lib/containerd/io.containerd.snapshotter.v1.soci
curl -sSL https://raw.githubusercontent.com/awslabs/soci-snapshotter/45def2dcf87781de75634f5e2744b73fdb2dd8aa/scripts/parallel-mode-install.sh | bash

--//
Content-Type: application/node.eks.aws

apiVersion: node.eks.aws/v1alpha1
kind: NodeConfig
spec:
kubelet:
config:
imageServiceEndpoint: unix:///run/soci-snapshotter-grpc/soci-snapshotter-grpc.sock
containerd:
config: |
[proxy_plugins.soci]
type = "snapshot"
address = "/run/soci-snapshotter-grpc/soci-snapshotter-grpc.sock"
[proxy_plugins.soci.exports]
root = "/var/lib/containerd/io.containerd.snapshotter.v1.soci"
[plugins."io.containerd.grpc.v1.cri".containerd]
snapshotter = "soci"
disable_snapshot_annotations = false
--//
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article