Guide · Amazon FSx for Lustre · High-Performance Storage
Amazon FSx for Lustre with MCP Servers — High-Performance ML Model Loading and S3 Data Repositories
Amazon FSx for Lustre is a managed parallel file system that delivers consistent sub-millisecond latency and throughput up to 1,000 MB/s per TiB of storage. For MCP servers that load large language model weights, ONNX inference graphs, or vector index files at startup, Lustre eliminates the cold-start penalty that comes from downloading multi-gigabyte files from S3 on every container launch. Lustre's S3 data repository association makes it a cache layer rather than a primary store: metadata is immediately visible across all clients, but data blocks are only fetched from S3 on the first read (lazy import). Subsequent reads — from any container on the shared file system — hit the Lustre cache and see the full provisioned throughput. This guide covers the three Lustre deployment types, S3 data repository integration, compression, security group setup, Node.js client patterns, and mounting in ECS Fargate task definitions.
TL;DR
Use Persistent-2 for any production MCP server that serves ML models or large binary assets. Set PerUnitStorageThroughput: 500 (500 MB/s per TiB) and DataCompressionType: LZ4. Associate the file system with an S3 bucket via a data repository association — Lustre will lazy-import objects on first access and optionally auto-import when S3 objects change. Create a security group that allows TCP/UDP 988 and TCP 1018–1023 inbound from itself (Lustre inter-node) and from your server SG. Use Scratch-2 only for ephemeral batch jobs where data loss on hardware failure is acceptable. Never use Persistent-1 for new deployments — Persistent-2 offers higher throughput at the same price.
Lustre deployment types
FSx for Lustre offers three deployment types with different durability, throughput, and cost characteristics:
| Type | Use Case | Data Replication | Max Throughput per TiB | Storage Price (us-east-1) | Min Capacity |
|---|---|---|---|---|---|
| Scratch-1 | Short-term temp storage (<1 day) | None | 200 MB/s/TiB | $0.073/GB-mo | 1.2 TiB |
| Scratch-2 | Short-term, higher throughput (<1 week) | None | 500 MB/s/TiB | $0.073/GB-mo | 1.2 TiB |
| Persistent-1 | Long-term (legacy, avoid for new) | Within AZ | 50–200 MB/s/TiB | $0.073–$0.145/GB-mo | 1.2 TiB |
| Persistent-2 | Long-term production | Within AZ | 125–1000 MB/s/TiB | $0.080–$0.145/GB-mo | 1.2 TiB |
Scratch file systems have no data replication within the AZ — a hardware failure will cause data loss. This is acceptable when the file system is backed by an S3 data repository (you can recreate it from S3 in minutes). Persistent file systems replicate data to multiple storage devices within the same AZ, giving ~99.9% durability, but they are not multi-AZ; an AZ failure makes the file system unavailable until AWS restores it.
For a 2.4 TiB Persistent-2 file system at 500 MB/s/TiB: total throughput = 1.2 TB/s, monthly cost = 2400 × $0.145 ≈ $348/month. Compare to EFS Elastic at $0.30/GB-month: 2.4 TB stored = $720/month — FSx Lustre is cheaper per GB at this scale, and faster by 10–100×.
Creating a Persistent-2 file system
Use @aws-sdk/client-fsx (Node.js) or the CLI. The key parameters are DeploymentType, PerUnitStorageThroughput, DataCompressionType, and StorageCapacity (must be a multiple of 2.4 TiB for Persistent-2 with SSD storage):
import { FSxClient, CreateFileSystemCommand, DescribeFileSystemsCommand } from "@aws-sdk/client-fsx";
const fsx = new FSxClient({ region: "us-east-1" });
const { FileSystem } = await fsx.send(new CreateFileSystemCommand({
FileSystemType: "LUSTRE",
StorageCapacity: 2400, // GiB; must be multiple of 2400 for Persistent-2 SSD
StorageType: "SSD",
SubnetIds: ["subnet-aaa111"], // single AZ; Lustre is always single-AZ
SecurityGroupIds: ["sg-fsx-lustre"],
LustreConfiguration: {
DeploymentType: "PERSISTENT_2",
PerUnitStorageThroughput: 500, // MB/s per TiB; options: 125, 250, 500, 1000
DataCompressionType: "LZ4", // transparent compression; reduces storage by ~40% for text/JSON data
},
Tags: [
{ Key: "Name", Value: "mcp-model-cache-prod" },
{ Key: "Service", Value: "mcp-server" },
],
ClientRequestToken: "mcp-model-cache-prod-v1", // idempotency key
}));
console.log("FileSystemId:", FileSystem?.FileSystemId); // fs-0abc123def456
console.log("Lifecycle:", FileSystem?.Lifecycle); // CREATING
Creation takes 5–15 minutes. Poll until Lifecycle === "AVAILABLE":
async function waitForLustre(fileSystemId: string): Promise<string> {
for (let i = 0; i < 40; i++) {
const { FileSystems } = await fsx.send(new DescribeFileSystemsCommand({
FileSystemIds: [fileSystemId],
}));
const fs = FileSystems?.[0];
if (fs?.Lifecycle === "AVAILABLE") {
return fs.DNSName!; // e.g., fs-0abc123def456.fsx.us-east-1.amazonaws.com
}
if (fs?.Lifecycle === "FAILED") throw new Error("FSx Lustre creation failed");
await new Promise(r => setTimeout(r, 15_000));
}
throw new Error("FSx Lustre not available after 10 minutes");
}
const dnsName = await waitForLustre("fs-0abc123def456");
The DNS name resolves to the file system's ENI IP within your VPC. Use it as the mount target hostname.
S3 data repository association
An S3 data repository association (DRA) links an FSx file system to an S3 bucket or prefix. With a DRA, Lustre uses hierarchical storage management (HSM): file metadata is immediately visible in the Lustre namespace, but data blocks are only fetched from S3 on the first read (lazy import). After the first read, the file is cached in Lustre and subsequent reads hit the cache at full throughput.
import { CreateDataRepositoryAssociationCommand } from "@aws-sdk/client-fsx";
await fsx.send(new CreateDataRepositoryAssociationCommand({
FileSystemId: "fs-0abc123def456",
FileSystemPath: "/models", // mount-point subdirectory in Lustre
DataRepositoryPath: "s3://my-models-bucket/prod/", // S3 prefix
BatchImportMetaDataOnCreate: true, // immediately populate metadata (file names + sizes) from S3
S3: {
AutoImportPolicy: {
Events: ["NEW", "CHANGED", "DELETED"], // keep Lustre in sync when S3 objects change
},
AutoExportPolicy: {
Events: [], // set to ["NEW","CHANGED","DELETED"] if Lustre should write back to S3
},
},
ClientRequestToken: "mcp-dra-models-v1",
}));
AutoImportPolicy events:
NEW— when an object is added to S3, its metadata appears in Lustre automaticallyCHANGED— when an S3 object is updated (new version), the Lustre metadata is updated and cached data is invalidatedDELETED— when an S3 object is deleted, the Lustre file is removed
When NOT to use AutoImportPolicy: if your S3 bucket receives frequent small writes (e.g., log files), the continuous metadata synchronization can generate excessive FSx API calls. For static model artifacts, NEW + CHANGED is safe and useful. For high-throughput write workloads, disable auto-import and use on-demand CreateDataRepositoryTask instead:
import { CreateDataRepositoryTaskCommand } from "@aws-sdk/client-fsx";
// On-demand import: explicitly bring S3 objects into the Lustre cache
await fsx.send(new CreateDataRepositoryTaskCommand({
Type: "IMPORT_METADATA_FROM_REPOSITORY",
FileSystemId: "fs-0abc123def456",
Paths: ["/models/llama-3-8b.gguf"], // import just this file
Report: {
Enabled: true,
Path: "s3://my-models-bucket/fsx-reports/",
Format: "REPORT_CSV_20191124",
Scope: "FAILED_FILES_ONLY",
},
}));
An IMPORT_METADATA_FROM_REPOSITORY task only imports file metadata. The actual data blocks are still fetched lazily on first read. Use EXPORT_TO_REPOSITORY to push Lustre data back to S3.
LZ4 compression
Enabling DataCompressionType: LZ4 instructs Lustre to transparently compress all new data written to the file system. LZ4 is a hardware-accelerated, lossless compression algorithm. For MCP server use cases:
- GGUF / ONNX model files (mostly binary float arrays): 5–15% size reduction. Minimal benefit because quantized weights are already entropy-dense.
- JSON tool schemas, OpenAPI specs, Markdown documents: 60–75% size reduction. Significant benefit.
- Mixed model + config bundles: 20–40% reduction on average.
LZ4 decompression is effectively free on modern CPUs (multi-GB/s) and adds no measurable latency to reads. Enable it unconditionally — there is no downside. Already-compressed data (JPEG, ZIP, most model formats) is stored as-is without attempting re-compression.
To check compression savings after files are written:
# On an EC2 instance with the Lustre client mounted
# lfs df shows logical (uncompressed) vs physical (compressed) blocks
lfs df -h /mnt/fsx
# Example output:
# UUID 1K-blocks Used Available Use% Mounted on
# fs-0abc..@tcp: 2516582912 1073741824 1442841088 43% /mnt/fsx
# Logical: 2516582912 1500000000 1016582912 60%
# (1.5 TB logical, 1.07 TB physical = ~28% compression ratio)
Security group setup
Lustre uses non-standard ports that differ from NFS. The FSx security group needs self-referencing rules (Lustre metadata and storage nodes communicate internally using the same ports):
# Create the FSx Lustre SG
FSX_SG=$(aws ec2 create-security-group \
--group-name fsx-lustre-sg \
--description "FSx for Lustre — MCP server model cache" \
--vpc-id vpc-12345678 \
--query GroupId --output text)
# 1. Self-referencing inbound rules (required for Lustre inter-node communication)
aws ec2 authorize-security-group-ingress \
--group-id $FSX_SG \
--ip-permissions "[
{\"IpProtocol\":\"tcp\",\"FromPort\":988,\"ToPort\":988,\"UserIdGroupPairs\":[{\"GroupId\":\"$FSX_SG\"}]},
{\"IpProtocol\":udp\",\"FromPort\":988,\"ToPort\":988,\"UserIdGroupPairs\":[{\"GroupId\":\"$FSX_SG\"}]},
{\"IpProtocol\":\"tcp\",\"FromPort\":1018,\"ToPort\":1023,\"UserIdGroupPairs\":[{\"GroupId\":\"$FSX_SG\"}]}
]"
# 2. Allow inbound from MCP server SG (clients)
aws ec2 authorize-security-group-ingress \
--group-id $FSX_SG \
--ip-permissions "[
{\"IpProtocol\":\"tcp\",\"FromPort\":988,\"ToPort\":988,\"UserIdGroupPairs\":[{\"GroupId\":\"sg-mcp-server\"}]},
{\"IpProtocol\":\"tcp\",\"FromPort\":1018,\"ToPort\":1023,\"UserIdGroupPairs\":[{\"GroupId\":\"sg-mcp-server\"}]}
]"
# 3. Allow outbound from MCP server SG to FSx SG (usually satisfied by default egress, but explicit is safer)
aws ec2 authorize-security-group-egress \
--group-id sg-mcp-server \
--ip-permissions "[
{\"IpProtocol\":\"tcp\",\"FromPort\":988,\"ToPort\":988,\"UserIdGroupPairs\":[{\"GroupId\":\"$FSX_SG\"}]},
{\"IpProtocol\":\"tcp\",\"FromPort\":1018,\"ToPort\":1023,\"UserIdGroupPairs\":[{\"GroupId\":\"$FSX_SG\"}]}
]"
Common mistake: forgetting the self-referencing rule. Without it, the Lustre metadata server and object storage targets cannot communicate, and the file system creation either fails or the file system transitions to MISCONFIGURED state. AWS shows a FILE_SYSTEM_MISCONFIGURED lifecycle event in this case — fix by adding the self-referencing rules and AWS will heal the state automatically within a few minutes.
Mounting on EC2 with the Lustre client
The Lustre kernel module (kmod-lustre) must match the running kernel version. Amazon Linux 2023 ships a compatible Lustre client package:
#!/bin/bash
# AL2023: install Lustre client
dnf install -y lustre-client
# Create mount point
mkdir -p /mnt/fsx/models
# Mount Lustre file system
# DNS name format: fs-0abc123def456.fsx.us-east-1.amazonaws.com
mount -t lustre -o relatime,flock \
fs-0abc123def456.fsx.us-east-1.amazonaws.com@tcp:/fsx \
/mnt/fsx/models
# Verify mount
lfs df -h /mnt/fsx/models
# Persist across reboots
echo "fs-0abc123def456.fsx.us-east-1.amazonaws.com@tcp:/fsx /mnt/fsx/models lustre relatime,flock,_netdev 0 0" \
>> /etc/fstab
The flock option enables POSIX file locking (required for some ML frameworks that use lock files for checkpoint coordination). relatime reduces metadata update overhead for atime on reads.
For Ubuntu 22.04 or later, install from the AWS-provided repository:
# Ubuntu 22.04: install Lustre client
wget -O /tmp/fsx-ubuntu-client.sh \
https://fsx-lustre-client-repo-public-keys.s3.amazonaws.com/fsx-ubuntu-client-setup.sh
bash /tmp/fsx-ubuntu-client.sh
# Install client packages
apt-get install -y lustre-client-modules-$(uname -r) lustre-utils
Mounting in ECS Fargate task definitions
ECS Fargate does not support Lustre mounts natively — Lustre requires a kernel module that Fargate's read-only container OS does not load. The workaround for Fargate is to use an EC2 launch type with the Lustre client installed at bootstrap, or use an EFS volume as the shared layer and copy hot models to EFS from a Lustre-mounted EC2 instance periodically.
If you need Lustre on containers, use ECS on EC2 with a custom AMI that has the Lustre client and the file system pre-mounted in the user data:
#!/bin/bash
# ECS EC2 container instance user data
# 1. Install Lustre client
dnf install -y lustre-client
# 2. Mount Lustre before ECS agent starts
mkdir -p /mnt/fsx/models
mount -t lustre -o relatime,flock \
fs-0abc123def456.fsx.us-east-1.amazonaws.com@tcp:/fsx \
/mnt/fsx/models
# 3. Bind-mount into ECS volumes so containers can access it
# (configure in ECS task definition as a 'bind' volume type below)
In the ECS task definition, use a bind-mount volume pointing to the host's pre-mounted Lustre path:
// ECS task definition: expose Lustre mount as a container bind volume
const taskDef = {
family: "mcp-server-task",
volumes: [
{
name: "lustre-models",
host: { sourcePath: "/mnt/fsx/models" }, // host path where Lustre is mounted
},
],
containerDefinitions: [
{
name: "mcp-server",
image: "123456789012.dkr.ecr.us-east-1.amazonaws.com/mcp-server:latest",
mountPoints: [
{
sourceVolume: "lustre-models",
containerPath: "/app/models", // path inside container
readOnly: true, // most containers only need read access
},
],
// ... rest of container config
},
],
};
Node.js: reading models from a Lustre mount
Once mounted, Lustre appears as a standard POSIX file system. Node.js reads files using the standard fs module. The key patterns for MCP servers:
import { createReadStream } from "node:fs";
import { stat } from "node:fs/promises";
import { join } from "node:path";
const LUSTRE_MOUNT = process.env.LUSTRE_MOUNT_PATH ?? "/mnt/fsx/models";
const MODEL_FILE = join(LUSTRE_MOUNT, "llama-3-8b-q4_k_m.gguf");
// Module-level cache: read the model once per process lifetime
// (Lustre caches data blocks after first read, so subsequent process starts
// hit the kernel page cache — but module-level keeps it in JS memory)
let modelBuffer: Buffer | null = null;
async function loadModel(): Promise<Buffer> {
if (modelBuffer) return modelBuffer;
// Check if the file is present (may need to wait for HSM lazy import)
try {
await stat(MODEL_FILE);
} catch {
throw new Error(`Model not found at ${MODEL_FILE} — trigger import or wait for auto-import`);
}
const start = Date.now();
modelBuffer = await readFileBuffered(MODEL_FILE);
console.log(`Model loaded in ${Date.now() - start}ms (${(modelBuffer.length / 1e9).toFixed(2)} GB)`);
return modelBuffer;
}
// Buffered read for large files: avoids single allocations for >2 GB files
async function readFileBuffered(path: string): Promise<Buffer> {
const { size } = await stat(path);
const chunks: Buffer[] = [];
for await (const chunk of createReadStream(path, { highWaterMark: 64 * 1024 * 1024 })) {
chunks.push(chunk as Buffer);
}
return Buffer.concat(chunks, size);
}
For very large models (>8 GB), consider memory-mapped access via the mmap npm package, which lets the ML runtime address the model file directly without loading it fully into Node.js heap memory. This is relevant for llama.cpp or onnxruntime bindings that accept a file path rather than a Buffer.
Triggering an HSM restore for a specific file
When using lazy import (HSM), a file's metadata exists in the Lustre namespace but its data blocks have not been fetched from S3 yet. The first read triggers the fetch. If you want to warm a file before a container needs it (to avoid cold-start latency), trigger the restore using lfs hsm_restore:
# On a Lustre-mounted EC2 instance
# Check whether a file is released (data in S3 only) or cached (data in Lustre)
lfs hsm_state /mnt/fsx/models/llama-3-8b-q4_k_m.gguf
# Output: /mnt/fsx/models/llama-3-8b-q4_k_m.gguf: (0x00000009) exists archived, released
# "released" = data not yet in Lustre; trigger restore
lfs hsm_restore /mnt/fsx/models/llama-3-8b-q4_k_m.gguf
# Poll until restore completes
watch -n 2 'lfs hsm_state /mnt/fsx/models/llama-3-8b-q4_k_m.gguf'
# Target state: (0x00000001) exists archived
# (no longer "released" = data is now cached in Lustre)
Automate pre-warming in a startup script or Lambda that runs before scaling events, so containers always see warm cache on mount.
Storage scaling and limitations
FSx for Lustre does not auto-scale storage — you provision a fixed capacity at creation time. Scratch file systems cannot be resized after creation. Persistent-1 and Persistent-2 file systems support online storage scaling upward only (you cannot shrink), with a 6-hour cooldown between scaling operations:
import { UpdateFileSystemCommand } from "@aws-sdk/client-fsx";
// Scale Persistent-2 file system from 2.4 TiB to 4.8 TiB
await fsx.send(new UpdateFileSystemCommand({
FileSystemId: "fs-0abc123def456",
StorageCapacity: 4800, // new capacity in GiB; must be > current; multiple of 2400 for Persistent-2 SSD
ClientRequestToken: "scale-to-4800-v1",
}));
Scaling a Persistent-2 file system takes 20–60 minutes and is non-disruptive — mounted clients continue to read and write normally during the operation. Monitor progress via AdministrativeActions in DescribeFileSystems output.
Alert before hitting the capacity ceiling with the FreeDataStorageCapacity CloudWatch metric. For a 2.4 TiB file system, alert at 500 GB free:
import { CloudWatchClient, PutMetricAlarmCommand } from "@aws-sdk/client-cloudwatch";
await new CloudWatchClient({ region: "us-east-1" }).send(new PutMetricAlarmCommand({
AlarmName: "fsx-lustre-low-free-storage",
Namespace: "AWS/FSx",
MetricName: "FreeDataStorageCapacity",
Dimensions: [{ Name: "FileSystemId", Value: "fs-0abc123def456" }],
Statistic: "Average",
Period: 300,
EvaluationPeriods: 2,
Threshold: 500 * 1024 * 1024 * 1024, // 500 GiB in bytes
ComparisonOperator: "LessThanOrEqualToThreshold",
AlarmActions: ["arn:aws:sns:us-east-1:123456789012:ops-alerts"],
TreatMissingData: "notBreaching",
}));
Cost optimization
The minimum Lustre file system is 1.2 TiB, which costs at least $88/month (Scratch) or $96–$174/month (Persistent-2 depending on throughput tier). If your model collection is under 1 TB, the cheapest option is a 1.2 TiB Scratch-2 file system backed by an S3 DRA. When not in use, delete the Lustre file system and recreate it from S3 — creation from an S3-backed DRA takes 10–15 minutes and the data is never lost because S3 is the durable store. This pattern works well for batch processing workflows that run a few hours per day.
For 24/7 production serving, Persistent-2 at 1.2 TiB (500 MB/s/TiB = 600 MB/s aggregate throughput) costs ~$174/month — competitive with EFS Elastic at that storage volume, and significantly faster for model-loading workloads where cold-start latency matters.
Common errors and fixes
| Error | Cause | Fix |
|---|---|---|
mount: can't read superblock from device | Lustre client version doesn't match server version, or kernel module not loaded | Install lustre-client matching running kernel; run modprobe lustre |
File system in MISCONFIGURED lifecycle | Missing self-referencing SG rule on the FSx security group | Add TCP+UDP 988 and TCP 1018–1023 inbound self-referencing rules; FSx auto-heals within minutes |
| Files show size but reads return zeros or hang | HSM lazy import in progress; data being fetched from S3 | Use lfs hsm_state to check; run lfs hsm_restore then wait for released flag to clear |
ClientRequestToken already in use | Duplicate creation call with the same idempotency token | If creation succeeded, describe the existing file system; if not, change the token |
| Throughput lower than expected | Reading many small files; Lustre is optimized for large sequential I/O | Merge small files into single archives (tar/zip) before writing to Lustre; use lfs setstripe -c -1 to stripe large files across all OSTs |
StorageCapacity must be multiple of 2400 | Wrong increments for Persistent-2 SSD | Round up to nearest multiple of 2400 GiB (2.4 TiB increments) |
Related guides
- Amazon FSx overview: choosing between Lustre, OpenZFS, ONTAP, and Windows File Server
- FSx for OpenZFS: POSIX snapshots and clones for MCP server dev/test isolation
- FSx for ONTAP: multi-protocol NFS+SMB and SnapMirror cross-region replication
- Amazon EFS for MCP Servers: simpler shared storage for most use cases
- EFS with ECS and Fargate: persistent volumes for stateful MCP server containers
- Running MCP servers on EC2: instance profiles, IMDSv2, security groups
- MCP server uptime monitoring