Skip to content

Enable SOCI lazy loading by default on ECS service modules - #124

Open
mabadir wants to merge 4 commits into
mainfrom
mabadir/soci-enabled
Open

Enable SOCI lazy loading by default on ECS service modules#124
mabadir wants to merge 4 commits into
mainfrom
mabadir/soci-enabled

Conversation

@mabadir

@mabadir mabadir commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a soci_enabled input to the ECS service modules and turns it on by default, so Fargate can lazily load images and start tasks before the full image finishes downloading.

Bumps rvn-ecs-web, rvn-ecs-worker, and rvn-ecs-nlb to v1.2.0.

Scope

The input is declared in partials/inputs/ecs-service-builder-ecr-misc-inputs.yml, which is included only by the three ECS service definitions. rvn-ec2-service, rvn-lambda, and rvn-aws-static never receive it, so they continue to build with zstd compression. (Those modules share partials/templates/builder-infrastructure-inputs.yml, which the SOCI partial consumes — the sharing is one-directional, so nothing leaks outward.)

Tradeoff

  • Cost: SOCI cannot index zstd layers, so enabled builds use gzip with force-compression=true. Every layer is re-encoded each build, making builds slower and images ~20% larger.
  • Benefit: faster task starts on every deploy and every scale-out event, since Fargate keeps no layer cache between tasks.

Measured on a 168 MiB test service (ravion-test-swr, us-east-2):

image pull task created → started
before (zstd) 9.42s 46.97s
after (SOCI) 2.21s 24.48s

Verified the deployed image carries application/vnd.amazon.soci.index.v2+json in its ECR manifest on Fargate platform 1.4.0. The SOCI image is larger yet pulls 4x faster, which only happens if lazy loading is active.

Turning it off

The description tells users to disable it for small images or EC2 capacity. Note that ECS services using an EC2 capacity provider still get the default, but their container instances have no soci-snapshotter — so they pay the gzip build cost without the startup benefit and should opt out.

Related

Requires the build-side support in ravionhq/flightcontrol#7075 (compression profile, soci convert step, digest reporting).

Note: this branch is currently 7 commits behind main (vpc endpoints, module categories) — those touch different files, but worth rebasing before merge.

Greptile Summary

Adds a default-enabled SOCI image-building option to the three ECS service modules and releases each module as v1.2.0.

  • Declares the shared soci_enabled boolean input for source-built ECS images.
  • Passes the setting into web, worker, and NLB build contracts.
  • Documents the new module versions in the generated repository README.

Confidence Score: 5/5

The PR appears safe to merge with no concrete correctness or security failures identified in the changed repository contracts.

The new input is declared for all three affected ECS modules, each module preserves the shared build object through a valid merge, and each consistently forwards the new setting.

Important Files Changed

Filename Overview
partials/inputs/ecs-service-builder-ecr-misc-inputs.yml Adds the shared, default-enabled SOCI input with source-build visibility and user-facing tradeoff guidance.
compute/ecs_service/rvn-ecs-web-definition.yml Bumps the web service module to v1.2.0 and merges the SOCI setting into its existing image-build contract.
compute/ecs_service/rvn-ecs-worker-definition.yml Bumps the worker module to v1.2.0 and passes the SOCI setting through its build definition.
compute/ecs_service/rvn-ecs-nlb-definition.yml Bumps the network service module to v1.2.0 and passes the SOCI setting through its build definition.
README.md Updates the published versions of all three ECS service modules to v1.2.0.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    Input[soci_enabled input<br/>default: true] --> Web[rvn-ecs-web build]
    Input --> Worker[rvn-ecs-worker build]
    Input --> NLB[rvn-ecs-nlb build]
    Web --> Build[Shared ECS image build]
    Worker --> Build
    NLB --> Build
    Build --> ECR[SOCI-enabled image in ECR]
    ECR --> Fargate[Fargate lazy loading]
Loading

Reviews (1): Last reviewed commit: "introduce soci" | Re-trigger Greptile

Context used (4)

Measured on a 168 MiB service, well under the 250 MiB figure AWS
suggests as a rule of thumb: image pull dropped 9.42s to 2.21s and
task start 46.97s to 24.48s. Small images benefit too, so telling
users to turn SOCI off for them was wrong. EC2 capacity remains the
real reason to disable it, since those instances have no
soci-snapshotter to lazily load with.
@mabadir
mabadir requested a review from flybayer August 27, 2026 22:10
# Conflicts:
#	README.md
#	compute/ecs_service/rvn-ecs-nlb-definition.yml
@github-actions

Copy link
Copy Markdown

Ravion Module Publish Plan

Dry run only. No Ravion API mutations were made.

Module Current Version New Version Description
rvn-ecs-nlb 1.1.1 1.2.0 Enable SOCI lazy loading by default so Fargate starts tasks before the full image finishes downloading, cutting task startup time. The larger the image the more it saves. Turn it off for EC2 capacity.
rvn-ecs-web 1.1.0 1.2.0 Enable SOCI lazy loading by default so Fargate starts tasks before the full image finishes downloading, cutting task startup time. The larger the image the more it saves. Turn it off for EC2 capacity.
rvn-ecs-worker 1.1.0 1.2.0 Enable SOCI lazy loading by default so Fargate starts tasks before the full image finishes downloading, cutting task startup time. The larger the image the more it saves. Turn it off for EC2 capacity.

Diffs

rvn-ecs-nlb 1.1.1 -> 1.2.0

--- remote
+++ compiled
       label: Git ref (commit or tag)
       required: false
       type: string
+  soci_enabled: << module.input.soci_enabled >>
   source:
     base_path: << module.input.source_base_path || "." >>
     branch: << build.input.branch >>
@@
         - railpack
         - nixpacks
     type: string_array
+  - collapsible: true
+    default: true
+    description: Build a SOCI-enabled image so Fargate can lazily load it, starting tasks before the full image is downloaded. On by default, and the larger the image the more it saves. Turn it off for EC2 capacity, where the gzip layer compression SOCI requires makes builds slower without speeding up task startup. Lazy loading also changes how long tasks take to report healthy, so services behind a load balancer may need a longer health check grace period.
+    id: soci_enabled
+    label: SOCI lazy loading
+    show_when:
+      build_source:
+        - dockerfile
+        - railpack
+        - nixpacks
+    type: boolean
   - id: section_ecr
     label: Image registry lifecycle
     show_when:
@@
 
   The module is intentionally focused on Layer 4 services behind a Network Load Balancer. Use ECS Web Service for HTTP host and path routing through an Application Load Balancer.
 
-  Terraform source: [ravionhq/modules/compute/ecs_service](https://github.com/ravionhq/modules/tree/rvn-ecs-nlb@1.1.1/compute/ecs_service)
+  Terraform source: [ravionhq/modules/compute/ecs_service](https://github.com/ravionhq/modules/tree/rvn-ecs-nlb@1.2.0/compute/ecs_service)
 
   ## Use cases
 
@@
         base_path: compute/ecs_service
         branch: main
         execution_environment_id: << module.input.execution_environment_id >>
-        ref: rvn-ecs-nlb@1.1.1
+        ref: rvn-ecs-nlb@1.2.0
         repo: https://github.com/ravionhq/modules
         stack_id: <<stack.id>>
         terraform_variables:

rvn-ecs-web 1.1.0 -> 1.2.0

--- remote
+++ compiled
       label: Git ref (commit or tag)
       required: false
       type: string
+  soci_enabled: << module.input.soci_enabled >>
   source:
     base_path: << module.input.source_base_path || "." >>
     branch: << build.input.branch >>
@@
         - railpack
         - nixpacks
     type: string_array
+  - collapsible: true
+    default: true
+    description: Build a SOCI-enabled image so Fargate can lazily load it, starting tasks before the full image is downloaded. On by default, and the larger the image the more it saves. Turn it off for EC2 capacity, where the gzip layer compression SOCI requires makes builds slower without speeding up task startup. Lazy loading also changes how long tasks take to report healthy, so services behind a load balancer may need a longer health check grace period.
+    id: soci_enabled
+    label: SOCI lazy loading
+    show_when:
+      build_source:
+        - dockerfile
+        - railpack
+        - nixpacks
+    type: boolean
   - id: section_ecr
     label: Image registry lifecycle
     show_when:
@@
 
   The module is intentionally focused on web services behind an Application Load Balancer. It uses the selected ECS cluster to inherit AWS account, region, VPC, subnets, capacity providers, load balancer listeners, and load balancer security groups.
 
-  Terraform source: [ravionhq/modules/compute/ecs_service](https://github.com/ravionhq/modules/tree/rvn-ecs-web@1.1.0/compute/ecs_service)
+  Terraform source: [ravionhq/modules/compute/ecs_service](https://github.com/ravionhq/modules/tree/rvn-ecs-web@1.2.0/compute/ecs_service)
 
   ## Use cases
 
@@
         base_path: compute/ecs_service
         branch: main
         execution_environment_id: << module.input.execution_environment_id >>
-        ref: rvn-ecs-web@1.1.0
+        ref: rvn-ecs-web@1.2.0
         repo: https://github.com/ravionhq/modules
         stack_id: <<stack.id>>
         terraform_variables:

rvn-ecs-worker 1.1.0 -> 1.2.0

--- remote
+++ compiled
       label: Git ref (commit or tag)
       required: false
       type: string
+  soci_enabled: << module.input.soci_enabled >>
   source:
     base_path: << module.input.source_base_path || "." >>
     branch: << build.input.branch >>
@@
         - railpack
         - nixpacks
     type: string_array
+  - collapsible: true
+    default: true
+    description: Build a SOCI-enabled image so Fargate can lazily load it, starting tasks before the full image is downloaded. On by default, and the larger the image the more it saves. Turn it off for EC2 capacity, where the gzip layer compression SOCI requires makes builds slower without speeding up task startup. Lazy loading also changes how long tasks take to report healthy, so services behind a load balancer may need a longer health check grace period.
+    id: soci_enabled
+    label: SOCI lazy loading
+    show_when:
+      build_source:
+        - dockerfile
+        - railpack
+        - nixpacks
+    type: boolean
   - id: section_ecr
     label: Image registry lifecycle
     show_when:
@@
 
   The ECS Worker module creates an ECS service for background jobs, queue consumers, event processors, and other private workloads in an existing Ravion ECS cluster. It uses the same ECS service Terraform module as ECS Web Server, but does not create or attach a load balancer target group and does not expose a primary container port.
 
-  Terraform source: [ravionhq/modules/compute/ecs_service](https://github.com/ravionhq/modules/tree/rvn-ecs-worker@1.1.0/compute/ecs_service)
+  Terraform source: [ravionhq/modules/compute/ecs_service](https://github.com/ravionhq/modules/tree/rvn-ecs-worker@1.2.0/compute/ecs_service)
 
   ## Use cases
 
@@
         base_path: compute/ecs_service
         branch: main
         execution_environment_id: << module.input.execution_environment_id >>
-        ref: rvn-ecs-worker@1.1.0
+        ref: rvn-ecs-worker@1.2.0
         repo: https://github.com/ravionhq/modules
         stack_id: <<stack.id>>
         terraform_variables:

Comment on lines +9 to +19
- id: soci_enabled
label: SOCI lazy loading
type: boolean
description: Build a SOCI-enabled image so Fargate can lazily load it, starting tasks before the full image is downloaded. On by default, and the larger the image the more it saves. Turn it off for EC2 capacity, where the gzip layer compression SOCI requires makes builds slower without speeding up task startup. Lazy loading also changes how long tasks take to report healthy, so services behind a load balancer may need a longer health check grace period.
collapsible: true
show_when:
build_source:
- dockerfile
- railpack
- nixpacks
default: true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not expose this control and just enabled for fargate, disable for ec2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants