I have an Docker-built app that runs fine locally, but on fly.io the libsodium crypto calls I make fail (specifically crypto_pwhash_str, but I imagine other calls fail, too).
I even downloaded the image with fly auth docker and docker pull ... and the image works fine locally, but not on fly.io. So it’s not a difference in how the image is built. Something about the way fly.io runs it is different. What’s the difference?
I did check errno and it returns 12, which is an out of memory error. But my app is using about 24MB memory out of 221MB available, so maybe a red herring?
EDIT: adding this memory usage chart for the past 12 hours if it’s helpful
I’ve learned now that fly runs things in Firecracker VMs, not Docker containers. So that’s the reason it’s different. Now I need to figure out what about the Firecracker VM doesn’t like my libsodium calls.
Hi, @iffy! A 12-hour memory-usage plot is low resolution. You might need really high resolution to catch a spike in memory usage that crashes an app. So I still find that out-of-memory error intriguing. You could try upping the RAM on your VM, or adding swap.
I don’t think crypto_pwhash_str needs to allocate 200MB of memory. The app is doing nothing (except responding to health checks), sitting at 24MB. No one is using it. It immediately fails on a fresh start.
Anyway, I upped it to 512MB and it worked. But if I need 512MB just to run crypto_pwhash_str, I think fly isn’t up to what I want to do with it. For contrast, running it locally with docker, I see an initial memory-usage spike of ~100MiB (that also seems excessive), which then settles down to 420KiB.