Architecture
This site is one Docker image running stock Lucee 8 on AWS Lambda, in Sydney. Nothing in Lucee was patched. Click a diagram to open it full size. The code is on GitHub.
What runs in AWS
Everything here is created by one SAM template. CloudFront is the only public address. Behind it are a Lambda function that runs the container, an S3 bucket for images and a DynamoDB table for sessions. Logs go to one CloudWatch log group.
There are no servers to patch, no load balancer and no VPC. When nobody visits, the bill is a few cents of storage.
The path of a request
Your browser talks to CloudFront. CloudFront adds a secret header and calls the function's own URL. Inside the container, the Lambda Web Adapter turns the Lambda event back into a plain HTTP request to Tomcat on port 8888, so Lucee sees an ordinary request and needs no Lambda code.
Application.cfc refuses any request without the secret header. That is why the function URL answers 403 if you call it directly.
Where each address goes
CloudFront decides first. /images/public/* comes straight from S3. Anything else under /images/ also comes from S3, but only with a signed link. Every other address goes to Lucee.
Inside the container, Tomcat's rewrite rules give the clean addresses: /form is served by form.cfm, and an address with no file behind it gets the site's own 404 page.
The snapshot
SnapStart is optional, and this stack has it off, because AWS charges about US$3.95 a month to keep the snapshot of a container image. SNAPSTART=on ./deploy.sh turns it on.
Booting Lucee takes 10 to 15 seconds, which is a long wait for the first visitor after a quiet spell. With SnapStart, Lambda boots the container once when a version is published, calls a warm-up page, and saves a snapshot of the memory. Every new environment starts from that snapshot in 0.5 to 0.75 seconds.
Two things had to change to make that safe. Random number generators are reseeded after each restore, because otherwise two environments restored from the same snapshot hand out the same UUIDs. And everything Lucee writes goes to /tmp, because the rest of the disk is read-only.
One image, two places
The image on Lambda is the image you get from docker compose up. The Web Adapter does nothing outside Lambda, so locally you talk to Tomcat directly. DynamoDB Local stands in for the session table and a folder stands in for the bucket.
The local container runs with the same limits as Lambda: read-only disk, a writable /tmp and no root user. What breaks on Lambda breaks on your laptop first.
Sessions
Each Lambda environment has its own memory, and a visitor can land on a different one for every request. So sessions live in DynamoDB. Lucee reads the session at the start of a request and saves it at the end, before the response goes out. Your CFML uses the normal session scope.
A page that only reads the session spends about 6 ms in DynamoDB. A page that changes it spends about 40 ms. The line at the top of every page shows the real figures for that page; try it on the session page.
Private images
Files under /images/ are private. Lucee signs a link with a private key. CloudFront checks the signature against the matching public key and serves the file from S3 until the link expires. Lambda takes no part in sending the image.
The images page shows one open image and one signed one.