CFML in Lambda, Six Years On: Lucee 8, One Container and Optional SnapStart
Back in 2020 I wrote about running CFML in AWS Lambda using Fuseless. It worked, but it was fiddly. You compiled things, you packaged jars, and what ran in Lambda was not what ran on your laptop.
I wanted to see how far that has come, so I had another go with Lucee 8. The short version: you can now take the stock Lucee Docker image, add one file from AWS, and run it in Lambda. Same image locally and in AWS. No fork of Lucee, no recompile.
- Live demo: d15bsk1y2cq34t.cloudfront.net
- How it fits together: the architecture page
- Code: github.com/kukielp/lucee-snapstart
One thing up front, because the repo name gives the wrong idea. The demo is running without SnapStart. SnapStart works and I will show the numbers, but it costs money for a container image and I did not want to pay for it on a demo. It is one setting if you want it. More on that below.
What it is

lucee/lucee:8.0.0.304-lightas the base image, untouched.- The AWS Lambda Web Adapter copied in. It turns a Lambda event back into a normal HTTP request to Tomcat, so Lucee has no idea it is in Lambda.
- CloudFront in front, a Lambda Function URL behind it.
- S3 for images, DynamoDB for sessions, CloudWatch for logs.
- One SAM template and a
deploy.sh.
Locally it is docker compose up and you are looking at the same image on port 8888, with DynamoDB Local standing in for the session table.
The things that bit me
None of this was hard, but each one cost me some time, so here they are.
The disk is read-only. Lambda only lets you write to /tmp. Lucee and Tomcat both want to write next to themselves, so the start script copies Lucee’s server folder to /tmp and points everything there. I run the local container read-only as well, so anything that would break in Lambda breaks on my laptop first.
CloudFront signing broke form posts. The tidy way to lock a Function URL to CloudFront is Origin Access Control. It worked for GETs and failed on a plain HTML form POST, because the browser would have to send a hash of the body. I went back to the old trick: CloudFront adds a secret header and Application.cfc returns a 403 without it.
Sessions. Every Lambda environment has its own memory, and you can land on a different one for each request, so sessions have to live somewhere shared. Lucee has an official DynamoDB extension, but it would not load on Lucee 8 for me, and it only takes fixed access keys, which is no good with a Lambda role. I ended up writing one small Java class that implements Lucee’s cache interface on top of DynamoDB. Your CFML does not change:
this.sessionManagement = true;
this.sessionStorage = "sessions"; // a cache connection backed by DynamoDB
this.sessionCluster = true; // read the stored copy on every request
The tests then found something I would not have guessed. If you log out on one environment, another environment that still has your session in memory will happily bring it back. Lucee prefers its memory copy when the store has nothing. The fix is in Application.cfc and there is a test for it now.

I had CloudFront on the cheap price class. That one has no edge locations in Australia. Every page I loaded from Australia went to Los Angeles and back to Sydney, about 0.7 to 1 second a page. The site felt slow and Lucee was taking 3 ms. Switching to all edge locations got it down to 0.1 to 0.3 seconds.
So how fast is it?
Every page in the demo tells you what it cost at the top, including how long it spent talking to DynamoDB.

That screenshot is a first visit in a fresh environment, which is the slow case. Once it is warm, these are the medians from the request log, in Sydney on arm64 with 1024 MB:
| Page | Whole request | Of which DynamoDB |
|---|---|---|
| No session | 2 ms | none |
| Reads the session | 10 ms | 6 ms |
| Changes the session | 46 ms | 37 ms |
So a session costs you about 8 ms if the page only reads it and about 40 ms if it changes it. I was expecting worse.
Getting those numbers honest took some work. Tomcat’s access log reads the clock after the response has gone out, and Lambda freezes the environment at exactly that moment, so about a third of my request times included the idle gap until the next visitor. There is a small logging class in the repo that deals with it, and two CloudWatch dashboards built on top of the logs.
SnapStart, and why the demo has it off
Cold start is the old problem with Java in Lambda. Lucee takes a while to boot, and the first visitor after a quiet spell wears it.
SnapStart fixes that. Lambda boots your container once at deploy, takes a snapshot of the memory, and starts every new environment from the snapshot.

| SnapStart off | SnapStart on | |
|---|---|---|
| Cold start, as the visitor sees it | 6 to 8.5 s | 0.5 to 1 s |
| Warm pages | the same | the same |
| Cost with no traffic | a few cents a month | about US$4 a month |
It works with stock Lucee, with one catch that is worth knowing about. A snapshot copies memory, and that includes the state of the random number generators. Out of the box, two environments restored from the same snapshot gave me the same createUUID() values. Not something you want to find in production. The cause was a JVM flag in the Lucee image, plus rand() keeping its own generators. Both are fixed in the repo, and there is a page in the demo that requests eight values at once so you can check for yourself.
Now the cost. I assumed SnapStart was free, because it is free on Lambda’s managed Java runtime. For a container image it is not. AWS bills you for keeping the snapshot, for as long as the version exists, whether anyone visits or not. At 1024 MB that is about US$3.95 a month, and every old version you leave lying around costs the same again. I only found out by reading the bill.
Four dollars is nothing for a real site. For a demo that mostly sits idle I would rather pay nothing, so the default is off and the live demo runs that way. If you want it:
SNAPSTART=on ./deploy.sh # cold starts under a second, about US$3.95 a month
./deploy.sh # off: no fixed cost, a cold start boots Lucee
What it costs
With SnapStart off, an idle month is a few cents of storage. After that it is pay per use. At list prices in Sydney, a million requests a month comes to roughly US$7, and most of that is CloudFront data transfer, which the free allowance covers for a small site. The README has the full table and what I assumed.
Try it
git clone https://github.com/kukielp/lucee-snapstart
cd lucee-snapstart
docker compose up --build # http://localhost:8888
./deploy.sh # needs AWS credentials and the SAM CLI
There is a test suite as well. ./tests/run.sh starts four copies of the container locally, two of them sharing a session table the way two Lambda environments would, and ./tests/run.sh live runs against whatever you deployed.
A few things I have not done yet: a custom domain, a CDK version of the stack, and caching the stylesheet at CloudFront so it stops going through Lambda. If you run CFML and try this, I would like to hear how it goes.