# simple phoenix app with shared-cpu-1x is failing with OOM

**URL:** <https://community.fly.io/t/simple-phoenix-app-with-shared-cpu-1x-is-failing-with-oom/21164>\
**Category:** Phoenix\
**Tags:** elixir, troubleshooting, login-only\
**Created:** [August 6, 2024, 9:17pm UTC](https://community.fly.io/t/simple-phoenix-app-with-shared-cpu-1x-is-failing-with-oom/21164 "2024-08-06T21:17:45Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![vrnithinkumar](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/vrnithinkumar/32/40342_2.png) [@vrnithinkumar](https://community.fly.io/u/vrnithinkumar)\
**Post date:** [August 6, 2024, 9:17pm UTC](https://community.fly.io/t/simple-phoenix-app-with-shared-cpu-1x-is-failing-with-oom/21164/1 "2024-08-06T21:17:45Z")

</div>

I was making a simple HTML change to my Phoenix (1.7.11) app and it is now failing due to OOM. I tried reverting my changes and it is still happening the same. My Phoenix app is very simple and it has 0 users. I am in the hobby plan and so using `shared-cpu-1x`

Below is the error and even the total VM memory used 1789260kB is below the 256mb limit.  
So basically I am clueless

```auto
ams [info] [4.536562] Out of memory: Killed process 318 (beam.smp) total-vm:1789260kB, anon-rss:83092kB, file-rss:0kB, shmem-rss:71476kB, UID:65534 pgtables:472kB oom_score_adj:0
ams [info] INFO Main child exited with signal (with signal 'SIGKILL', core dumped? false)
ams [info] INFO Process appears to have been OOM killed!

```

---

<div class="post-metadata">

**Author:** ![vrnithinkumar](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/vrnithinkumar/32/40342_2.png) [@vrnithinkumar](https://community.fly.io/u/vrnithinkumar)\
**Post date:** [August 6, 2024, 9:19pm UTC](https://community.fly.io/t/simple-phoenix-app-with-shared-cpu-1x-is-failing-with-oom/21164/2 "2024-08-06T21:19:04Z")

</div>

From #General to #Phoenix

---

<div class="post-metadata">

**Author:** ![vrnithinkumar](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/vrnithinkumar/32/40342_2.png) [@vrnithinkumar](https://community.fly.io/u/vrnithinkumar)\
**Post date:** [August 6, 2024, 9:19pm UTC](https://community.fly.io/t/simple-phoenix-app-with-shared-cpu-1x-is-failing-with-oom/21164/3 "2024-08-06T21:19:04Z")

</div>

Added #elixir, #troubleshooting

---

<div class="post-metadata">

**Author:** ![roadmr](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/roadmr/32/14140_2.png) [@roadmr](https://community.fly.io/u/roadmr)\
**Post date:** [August 6, 2024, 11:11pm UTC](https://community.fly.io/t/simple-phoenix-app-with-shared-cpu-1x-is-failing-with-oom/21164/4 "2024-08-06T23:11:46Z")

</div>

> [@vrnithinkumar](#):
>
> the total VM memory used 1789260kB is below the 256mb limit.

It is not.

1789260kiB = 1747.32MiB \> 256 MiB (these are kibibytes/mebibytes, not kilobytes/megabytes).

You definitely need to add more memory - OOMs don’t lie 🙂

- Daniel

---

<div class="post-metadata">

**Author:** ![ikhan](https://avatars.discourse-cdn.com/v4/letter/i/91b2a8/32.png) [@ikhan](https://community.fly.io/u/ikhan)\
**Post date:** [August 7, 2024, 2:11am UTC](https://community.fly.io/t/simple-phoenix-app-with-shared-cpu-1x-is-failing-with-oom/21164/5 "2024-08-07T02:11:36Z")

</div>

My Phoenix app had started going into OOM loop at deployment just now too. Tbf, mine veers dangerously close to 256mb limit anyway (but has been deploying fine) so any new code added was my first suspect, specially as it still works fine under 512mb.

However I rolled back release to last known healthy image that was working fine earlier (deployed 2.5 days ago), but even that one is getting OOM killed now.

---

<div class="post-metadata">

**Author:** ![khuezy](https://avatars.discourse-cdn.com/v4/letter/k/4da419/32.png) [@khuezy](https://community.fly.io/u/khuezy)\
**Post date:** [August 7, 2024, 2:53am UTC](https://community.fly.io/t/simple-phoenix-app-with-shared-cpu-1x-is-failing-with-oom/21164/6 "2024-08-07T02:53:54Z")

</div>

Speaking off, I noticed my nextjs app suddenly has about +60MB of usage in the last couple days, nothing changed that I can think of. Did something on Fly’s end cause this upshoot in memory usage or the 3 of us just coincidence?

---

<div class="post-metadata">

**Author:** ![kentare](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/kentare/32/37254_2.png) [@kentare](https://community.fly.io/u/kentare)\
**Post date:** [August 7, 2024, 6:40am UTC](https://community.fly.io/t/simple-phoenix-app-with-shared-cpu-1x-is-failing-with-oom/21164/7 "2024-08-07T06:40:28Z")

</div>

I have the exact problem with a simple phoenix app. Have been running fine for a year now, but started getting OOM when restarting today.

```auto
arn [info] [4.898602] Out of memory: Killed process 318 (beam.smp) total-vm:1767996kB, anon-rss:79500kB, file-rss:0kB, shmem-rss:77600kB, UID:65534 pgtables:468kB oom_score_adj:0
arn [info] INFO Main child exited with signal (with signal 'SIGKILL', core dumped? false)
arn [info] INFO Process appears to have been OOM killed!

```

The total VM memory used is similar to OP. Works fine when scaling to 512mb, but when I am scaling down to 256mb again I get the same problem.

---

<div class="post-metadata">

**Author:** ![vrnithinkumar](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/vrnithinkumar/32/40342_2.png) [@vrnithinkumar](https://community.fly.io/u/vrnithinkumar)\
**Post date:** [August 7, 2024, 8:45am UTC](https://community.fly.io/t/simple-phoenix-app-with-shared-cpu-1x-is-failing-with-oom/21164/8 "2024-08-07T08:45:09Z")

</div>

@roadmr Thank you for the reply.  
I misinterpreted it since my usual memory usage was around the range of 180MiB.  
I am still struggling to figure out what changed from yesterday. I tried to revert to the old version and had no luck. And the traffic has not changed at all it is always very low almost 0.  
Is 512 MiB memory required to run a simple basic Phoenix app now?

---

<div class="post-metadata">

**Author:** ![kurt](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/kurt/32/43757_2.png) [@kurt](https://community.fly.io/u/kurt)\
**Post date:** [August 7, 2024, 12:25pm UTC](https://community.fly.io/t/simple-phoenix-app-with-shared-cpu-1x-is-failing-with-oom/21164/9 "2024-08-07T12:25:50Z")

</div>

We have started suggesting a minimum of 1gb RAM for full stack apps. It’s actually kinda hard to run stuff in under 256mb.

For side projects it’s far better to let machines auto stop / scale to zero for money saving purposes.

> [@khuezy](#):
>
> Did something on Fly’s end cause this upshoot in memory usage or the 3 of us just coincidence?

We’re seeing normal numbers of OOMs across all customers.

If you’re curious, February 28th of this year was our busiest OOM day ever.

---

<div class="post-metadata">

**Author:** ![khuezy](https://avatars.discourse-cdn.com/v4/letter/k/4da419/32.png) [@khuezy](https://community.fly.io/u/khuezy)\
**Post date:** [August 7, 2024, 1:03pm UTC](https://community.fly.io/t/simple-phoenix-app-with-shared-cpu-1x-is-failing-with-oom/21164/10 "2024-08-07T13:03:20Z")

</div>

> [@kurt](#):
>
> We’re seeing normal numbers of OOMs across all customers.

Is this across ALL memory permutations, or just the 256MB configuration? Did you notice any difference in 256MB =\> 512MB changes in the last few days? I’ve bumped my app 1 tier up to avoid the weird memory crawl, I wonder if that has any affect on your observation of normal OOM errors..

---

<div class="post-metadata">

**Author:** ![khuezy](https://avatars.discourse-cdn.com/v4/letter/k/4da419/32.png) [@khuezy](https://community.fly.io/u/khuezy)\
**Post date:** [August 7, 2024, 1:10pm UTC](https://community.fly.io/t/simple-phoenix-app-with-shared-cpu-1x-is-failing-with-oom/21164/11 "2024-08-07T13:10:59Z")

</div>

@kurt I believe there is something funky going on on Fly’s infra

 ![image](https://global.discourse-cdn.com/fly1/original/3X/b/8/b8e72380d3cb1ed2e1c319f7ffe5bcfa45445a29.png)

I have a typescript temporal worker running on 256MB, it flatlines at about 174MB for the last while. Then literally a few minutes ago, I scale the worker to 0 and rescaled it back to 1 (no code or config changes) and the baseline memory shot up to about 200MB.

I’m a little confused.

What’s also odd is the previous stats shows 217MB of total, now the total is 213MB, something on Fly is consuming 4 more MB.

---

<div class="post-metadata">

**Author:** ![vrnithinkumar](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/vrnithinkumar/32/40342_2.png) [@vrnithinkumar](https://community.fly.io/u/vrnithinkumar)\
**Post date:** [August 7, 2024, 3:09pm UTC](https://community.fly.io/t/simple-phoenix-app-with-shared-cpu-1x-is-failing-with-oom/21164/12 "2024-08-07T15:09:56Z")

</div>

For me adding the `swap_size_mb` at `fly.toml` fixed the OOM issue.  
But I can see a jump in memory usage from 180 MB to 200 MB without any code or traffic change.  
Also, I am seeing the OOM with my Postgres now. ☹

```auto
swap_size_mb = 512

```

---

<div class="post-metadata">

**Author:** ![winston-ce](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/winston-ce/32/37262_2.png) [@winston-ce](https://community.fly.io/u/winston-ce)\
**Post date:** [August 7, 2024, 3:54pm UTC](https://community.fly.io/t/simple-phoenix-app-with-shared-cpu-1x-is-failing-with-oom/21164/13 "2024-08-07T15:54:51Z")

</div>

With no change in application code, we’re also seeing new deploys fail. I’ve tested locally, constraining memory to 128MB for the app process (node) and separately constraining via docker. I have to limit memory to 64MB in order to trigger an OOM. There definitely appears to be something the matter with the 256MB VMs, our first deploy failed yesterday. I’ve also destroyed an existing machine and deployed to a new with the same results. According to Fly’s Grafana, a fly instance (machine/vm) for this app (when running) never uses more than 145MB.

Updated data point: to be clear, you can replicate a deploy exactly (by checking out and deployed a prior release that deployed stably) and see that the machine no longer boots.

---

<div class="post-metadata">

**Author:** ![winston-ce](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/winston-ce/32/37262_2.png) [@winston-ce](https://community.fly.io/u/winston-ce)\
**Post date:** [August 7, 2024, 4:15pm UTC](https://community.fly.io/t/simple-phoenix-app-with-shared-cpu-1x-is-failing-with-oom/21164/14 "2024-08-07T16:15:29Z")

</div>

For now, the app is deployed and running on 256MB, but I had to add a tiny swap partition. That’s `swap_size_mb = 128` as a top level option in fly.toml

---

<div class="post-metadata">

**Author:** ![khuezy](https://avatars.discourse-cdn.com/v4/letter/k/4da419/32.png) [@khuezy](https://community.fly.io/u/khuezy)\
**Post date:** [August 7, 2024, 4:20pm UTC](https://community.fly.io/t/simple-phoenix-app-with-shared-cpu-1x-is-failing-with-oom/21164/15 "2024-08-07T16:20:36Z")

</div>

I wouldn’t recommend using `swap_size_mb` as a workaround, since `suspend` doesn’t support it. We have to wait to see if this change was intentional or not. If it is, I guess they are kicking the 256MB bums (like myself) off the bus bench.

---

<div class="post-metadata">

**Author:** ![winston-ce](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/winston-ce/32/37262_2.png) [@winston-ce](https://community.fly.io/u/winston-ce)\
**Post date:** [August 8, 2024, 1:43pm UTC](https://community.fly.io/t/simple-phoenix-app-with-shared-cpu-1x-is-failing-with-oom/21164/16 "2024-08-08T13:43:52Z")

</div>

Where is the incompatibility you mention documented? I couldn’t find anything that mentions it.

---

<div class="post-metadata">

**Author:** ![khuezy](https://avatars.discourse-cdn.com/v4/letter/k/4da419/32.png) [@khuezy](https://community.fly.io/u/khuezy)\
**Post date:** [August 8, 2024, 2:39pm UTC](https://community.fly.io/t/simple-phoenix-app-with-shared-cpu-1x-is-failing-with-oom/21164/17 "2024-08-08T14:39:54Z")

</div>

It’s not documented in the official docs, but it’s mentioned in a post: [New feature in preview: suspend/resume for Machines](https://community.fly.io/t/new-feature-in-preview-suspend-resume-for-machines/20672)

Any updates from Fly on this?

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/fly1/original/3X/6/e/6e8955d00cb218e186ebbe3a6ab06fefdce15290.svg) [@system](https://community.fly.io/u/system)\
**Post date:** [August 15, 2024, 2:40pm UTC](https://community.fly.io/t/simple-phoenix-app-with-shared-cpu-1x-is-failing-with-oom/21164/18 "2024-08-15T14:40:53Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
