Lesson
I paid for a full vCPU to fix a slow cold start. It changed nothing.
By Rick Wise
Our staging API on Lambda kept timing out on cold start. The import took 10 to 11 seconds against a 10 second init limit. My first guess was CPU, so I raised the function from 1024 MB to 1769 MB, which is one full vCPU. The import still took 10.8 to 11.2 seconds. Before it was 10.3 to 11.2. Nothing moved. So I added a small import profiler. Two modules stood out: stripe at 1.4 to 1.9 seconds and the PDF renderer at 0.4 to 0.5 seconds. Both loaded on every start, and most requests never use them. I changed them to load on first use. Cold starts dropped to 5.6 to 8.7 seconds, with 0 timeouts in the 11 cold starts since. The memory went back to 1024 MB. The lesson I keep relearning: more memory is the expensive guess. Measure what the time is spent on first. (I build CloudWise, and this was its staging API. Production uses SnapStart and never saw the problem.)
- Reactions
- 0
- Comments
- 0
- Shares
- 0