OOM for Shared CPU PostgreSQL App

I created an app with a PostgreSQL database following these instructions. Unfortunately, the database gets OOM errors and is shut down if I attempt to perform writes to it. Documentation elsewhere appears to show that it’s possible to create shared CPU databases with 2GB memory, but the CLI only allows creation of shared CPU databases with 256MB.

  • Am I doing something wrong that the 256MB database app is immediately being OOMed?
  • Is there a way to create 2GB shared CPU databases?

There may not be a flag on the create command to set RAM size, but you can change it after:

fly scale vm shared-cpu-1x --memory 2048 --app <dbname>

It’s slightly weird for a 256MB database to OOM from just writes. Are you writing something large, or just reasonably normal inserts?

I’m just setting up a standard Phoenix 1.6 application and the database immediately is using about 214MB of memory. I just remembered, however, that I have the ecto_psql_extras Hex package installed, as well as the pg_stat_statements PostgreSQL extension enabled, so perhaps it’s one of those driving up memory usage over what the tutorial expects.

I’m writing a single row with an email and a password, so these are very low-cost queries. It OOMed on the first write I sent.

I am curious if it works without the ecto_psql_extras enabled. 256MB is really too little for real DBs but should be just fine for development.

I’m watching your DB logs if you want to give it another go.