Tips & tricks
Fit your app into small memory limits (and why it matters)
Services get a fixed memory budget. Practical ways to keep a Node, PHP or Go service lean enough for a small plan without constant restarts.
· 2 min read
In short
- Each service has a memory limit, and going over it gets the process killed
- Cap Node's heap, trim dependencies and use fewer replicas
- Measure first: a restart right after start usually means the limit is too tight
On a small plan every service has a fixed memory budget. That is good for predictability and bad for apps that assume a whole server. Here is how to stay comfortably inside it.
1. Cap the Node heap
Node does not know it is in a small container unless you tell it. Leave room for the rest of the process:
ENV NODE_OPTIONS=--max-old-space-size=256
2. Do less at startup
Large JSON loads, eager caches and many database connections all spike memory right when the service starts. Load lazily and keep the connection pool small.
3. Trim what you ship
Heavy dependencies cost memory at runtime. Install only production dependencies in the final image (see the multi-stage Dockerfile tips).
4. Fewer replicas, not more
Each replica uses its own memory and counts against your plan. Scale out only when you need availability or throughput, as covered in prongo.yaml tips.
5. Watch for the signature
A service that runs fine, grows slowly and then disappears is leaking. One that dies seconds after starting simply needs more room than its limit, or less work at startup.
If you hit the ceiling for real, that is what the planned larger plans are for. Until then, lean services are cheaper to run anywhere.
Frequently asked questions
What are the memory limits on the free plan?
During the beta each service gets 384 MB of memory and 0.5 vCPU, with up to 3 services per project. See the pricing page for the current numbers, which can change.
Why does my app restart after a few minutes?
Often memory growth: the process crosses its limit and is killed. Cap the heap, look for leaks, and check what runs on startup.