@@ -4,7 +4,7 @@ Build and test all Java container optimization methods for the Unicorn Store Spr
44
55## Prerequisites
66
7- 1 . Run ` containerize.sh ` - creates ECR repo, builds baseline image with ` :latest ` and ` :02-multi-stage ` tags
7+ 1 . Run ` containerize.sh ` - creates ECR repo, builds baseline image with ` :latest ` tag
882 . Run ` eks.sh ` - deploys to EKS with deployment using ` :latest ` image
99
1010## Usage
@@ -14,41 +14,47 @@ Build and test all Java container optimization methods for the Unicorn Store Spr
1414./test-optimizations.sh --deploy # Build, push to ECR, deploy to EKS, measure startup
1515./test-optimizations.sh --only cds # Build single method
1616./test-optimizations.sh --only cds --deploy
17+ ./test-optimizations.sh --deploy --revert # Revert to :latest on exit
1718```
1819
1920## Options
2021
2122| Option | Description |
2223| --------| -------------|
2324| (none) | Build all images locally, output results to stdout |
24- | ` --deploy ` | Push to ECR, deploy to EKS, measure startup/restart times |
25+ | ` --deploy ` | Push to ECR, deploy to EKS, measure startup times |
2526| ` --only <method> ` | Build only specified method (partial match: ` cds ` , ` native ` , etc.) |
27+ | ` --revert ` | Revert deployment to ` :latest ` on exit (use with ` --deploy ` ) |
2628
2729## Methods
2830
29- | Tag | Method | Needs DB | Code Change | Special |
30- | -----| --------| ----------| -------------| ---------|
31- | 02-multi-stage | Optimized Dockerfile | No | No | Baseline |
32- | 03-jib | Google Jib Maven plugin | No | No | No Dockerfile |
33- | 04-custom-jre | Custom JRE with jlink | No | No | |
34- | 05-soci | Seekable OCI (lazy loading) | No | No | SOCI index after push |
35- | 06-cds | Class Data Sharing | Yes | No | Training run |
36- | 07-aot | Ahead-of-Time compilation | Yes | No | Training run |
37- | 08-native | GraalVM Native Image | No | No | Long build time |
38- | 09-crac | Coordinated Restore at Checkpoint | Yes | Yes | UnicornPublisher swap |
31+ | Tag | Method | Build | Needs DB | Code Change | Notes |
32+ | -----| --------| -------| ----------| -------------| -------|
33+ | 01-baseline-1cpu | Baseline with 1 CPU | No | No | No | Deploy-only, ~ 10-12s |
34+ | 01-baseline-2cpu | Baseline with 2 CPUs | No | No | No | Deploy-only, ~ 6s |
35+ | 01-pod-resize | In-place pod resize | No | No | No | Deploy-only, CPU boost controller |
36+ | 02-multi-stage | Optimized Dockerfile | Yes | No | No | Baseline build |
37+ | 03-jib | Google Jib Maven plugin | Yes | No | No | No Dockerfile |
38+ | 04-custom-jre | Custom JRE with jlink | Yes | No | No | Smaller image |
39+ | 05-soci | Seekable OCI (lazy loading) | Yes | No | No | SOCI index after push |
40+ | 06-cds | Class Data Sharing | Yes | Yes | No | Paketo Buildpacks |
41+ | 07-aot | Ahead-of-Time compilation | Yes | Yes | No | Java 25+ AOT cache |
42+ | 08-native | GraalVM Native Image | Yes | No | No | Long build time |
43+ | 09-crac | Coordinated Restore at Checkpoint | Yes | Yes | Yes | UnicornPublisher swap |
3944
4045## Flow
4146
4247### Build-only mode (default)
4348
4449```
4550For each method:
46- 1. Pre-build hooks (CRaC: swap UnicornPublisher.crac)
47- 2. Start PostgreSQL if needed (CDS, AOT, CRaC)
48- 3. Build image (docker build or mvn jib:dockerBuild)
49- 4. Stop PostgreSQL
50- 5. Post-build hooks (CRaC: restore UnicornPublisher.java)
51- 6. Output: Method | ✅/❌ | Size | Time
51+ 1. Skip if deploy-only (01-baseline-*, 01-pod-resize)
52+ 2. Pre-build hooks (CRaC: swap UnicornPublisher.crac)
53+ 3. Start PostgreSQL if needed (CDS, AOT, CRaC) - AWS RDS or local Docker
54+ 4. Build image (docker build, mvn jib:dockerBuild, or pack build)
55+ 5. Stop PostgreSQL
56+ 6. Post-build hooks (CRaC: restore UnicornPublisher.java)
57+ 7. Output: Method | ✅/❌ | Size | Time
5258```
5359
5460### Deploy mode (` --deploy ` )
@@ -60,19 +66,24 @@ For each method:
6066│ Start watcher ──────────────────► Initialize results file │
6167│ │
6268│ For each method: │
63- │ Build image │
64- │ Push to ECR (:tag) │
69+ │ Build image (skip for 01-*) │
70+ │ Push to ECR (skip for 01-*) │
6571│ Write to queue ───────────────► Read queue │
66- │ Continue immediately kubectl set image :tag │
72+ │ Continue immediately │
73+ │ Handle deploy-only methods: │
74+ │ 01-baseline-1cpu: set 1 CPU│
75+ │ 01-baseline-2cpu: set 2 CPU│
76+ │ 01-pod-resize: install │
77+ │ CPU boost controller │
78+ │ Or: kubectl set image :tag │
6779│ Wait for rollout │
6880│ Record startup time │
69- │ kubectl rollout restart │
70- │ Record restart time │
81+ │ Cleanup (pod-resize) │
7182│ Write to results file │
7283│ │
73- │ Write END marker ───────────────► kubectl set image :latest │
74- │ Wait for watcher (revert to baseline) │
75- │ Print final results Exit │
84+ │ Write END marker ───────────────► Exit │
85+ │ Wait for watcher │
86+ │ Print final results │
7687└─────────────────────────────────────────────────────────────────┘
7788```
7889
@@ -94,32 +105,63 @@ All output goes to `/tmp/test-optimizations/` (or `${SCRIPT_DIR}/.test-optimizat
94105```
95106Method | Build | Size Local | Time
96107---------------|-------|------------|------
108+ 01-baseline-1cpu | ✅ | N/A | 0s
9710902-multi-stage | ✅ | 598MB | 45s
98- 06-cds | ✅ | 1.34GB | 2m15s
110+ 06-cds | ✅ | 1.23GB | 2m23s
9911108-native | ❌ | N/A | 5m30s
100112```
101113
102114### Deploy mode results file
103115```
104- Method | Size Local | Size ECR | Build Time | Startup Time
105- ---------------|------------|----------|------------|-------------
106- 02-multi-stage | 598MB | 580MB | 45s | 8.234 seconds
107- 06-cds | 1.34GB | 1.2GB | 2m15s | 2.156 seconds
108- 09-crac | 1.1GB | 1.0GB | 3m20s | 0.087 seconds
116+ Method | Size Local | Size ECR | Build Time | Startup Time
117+ -----------------|------------|----------|------------|-------------
118+ 01-baseline-1cpu | N/A | N/A | 0s | 10.234 seconds
119+ 01-baseline-2cpu | N/A | N/A | 0s | 6.123 seconds
120+ 01-pod-resize | N/A | N/A | 0s | 5.987 seconds
121+ 02-multi-stage | 598MB | 580MB | 45s | 10.234 seconds
122+ 06-cds | 1.23GB | 578MB | 2m23s | 3.916 seconds
123+ 07-aot | 1.34GB | 428MB | 56s | 4.0 seconds
124+ 09-crac | 1.1GB | 1.0GB | 3m20s | 0.087 seconds
109125```
110126
127+ ## Database Configuration
128+
129+ The script automatically detects database configuration:
130+
131+ 1 . ** AWS RDS** (preferred): Tries to get credentials from SSM Parameter Store and Secrets Manager
132+ - ` workshop-db-connection-string ` - JDBC URL
133+ - ` workshop-db-secret ` - username/password
134+
135+ 2 . ** Local Docker** (fallback): Starts PostgreSQL container if AWS credentials not available
136+ - Uses ` host.docker.internal:5432 ` for Docker build access
137+
138+ ## Special Build Methods
139+
140+ ### CDS (06-cds)
141+ Uses Paketo Buildpacks instead of Dockerfile:
142+ - Installs ` pack ` CLI if not available
143+ - ` BP_JVM_CDS_ENABLED=true ` - creates CDS archive during build
144+ - ` BPL_JVM_CDS_ENABLED=true ` - uses CDS archive at runtime
145+
146+ ### Pod Resize (01-pod-resize)
147+ Installs Kube Startup CPU Boost controller:
148+ - Creates ` StartupCPUBoost ` resource with 100% CPU increase
149+ - Automatically removes boost when pod becomes ready
150+ - Cleans up controller after test
151+
111152## Environment
112153
113154Requires workshop environment (` /etc/profile.d/workshop.sh ` ) with:
114155- ` ACCOUNT_ID ` - AWS account ID
115156- ` AWS_REGION ` - AWS region
116- - ` SPRING_DATASOURCE_URL ` - Database connection string (for CDS/AOT/CRaC builds)
117- - ` SPRING_DATASOURCE_USERNAME ` / ` SPRING_DATASOURCE_PASSWORD `
157+
158+ Database credentials are fetched automatically from AWS or use local Docker fallback.
118159
119160## Notes
120161
121- - Build uses local PostgreSQL container for training (CDS, AOT, CRaC)
122- - Deploy uses real RDS database via Secrets Manager
162+ - Deploy-only methods (01- * ) don't build images, they modify deployment config
163+ - CDS uses Paketo Buildpacks (not Dockerfile) for proper CDS archive creation
123164- Native image may fail on ARM (macOS) - works on x86-64 Linux
124165- CRaC requires x86-64 for ` -XX:CPUFeatures=generic `
125166- SOCI requires ` soci ` CLI tool installed
167+ - Pod resize requires EKS 1.27+ with in-place pod resize support
0 commit comments