Which memory metric is actually billed for a Postgres service ?
thomasglot
PROOP

21 days ago

TL;DR: The dashboard "Memory" graph and the cgroup counters inside the container tell two different stories, and we can't determine from the docs which one drives usage billing. We need the exact definition of the billed memory metric to make an infrastructure decision.

What we observe

The dashboard metric cannot be cgroup memory.current. On 2026-07-29, after lowering shared_buffers to 1.5 GB, the dashboard showed a trough of 1.10 GB — below shared_buffers itself. Inside the container, /sys/fs/cgroup/memory.stat showed shmem = 1.669 GB (shared buffers are anonymous shared memory, not reclaimable without swap), so memory.current can never drop that low. At another point in the same window, memory.current read 6.26 GB while the dashboard showed ~2.8 GB. So the dashboard appears to subtract at least inactive_file — but we found no documentation of the formula.

A daily one-shot read parks gigabytes in inactive page cache for hours. The template's pgBackRest job reads the whole database daily (e.g. 2026-07-27 10:56–10:58 UTC: diff backup size = 4.9GB in 74 s). memory.stat measured ~3 h later: inactive_file = 3.42 GB vs active_file = 0.37 GB, anon = 92 MB. With memory.max = 32 GB there is no memory pressure, so the kernel never reclaims these pages. On the dashboard this shows up as a vertical +4 GB step followed by a 6–7 GB plateau lasting ~12+ hours (e.g. 2026-07-30 ~13:00 UTC until 2026-07-31 ~06:00 UTC).

Questions

What is the exact formula of the dashboard "Memory" metric for a service (in cgroup v2 terms — e.g. memory.current − inactive_file, working set, etc.)?

Which metric is used for usage billing ($/GB-min)? Is it the same as the dashboard metric, or raw memory.current?

Concretely: during the plateaus described above, are we billed for the inactive page cache left behind by the backup (pages read once, never touched again), and if the dashboard subtracts inactive pages, on what aging/decay schedule?

Is there a supported way to have that cache reclaimed without setting a hard replica memory limit? (The docs state a service that exceeds its limit crashes — an OOM kill of a production Postgres is not acceptable for us, so a hard cap is not an option.) E.g. a memory.high-style soft limit, or writing to memory.reclaim — is cgroupfs writable from inside the container, and is that supported?

Why we ask: our DB memory bill has doubled since May while the actual hot working set (measured via active_file + shmem) is ~2 GB. Before doing any further engineering (data retention, backup changes) we need to know whether the OS page cache from backups/batch jobs is part of the billed quantity. Happy to share full memory.stat dumps and timestamps if useful.

$20 Bounty

7 Replies

Railway
BOT

21 days ago

Having looked into this, the issue appears to be in your application code or configuration rather than the Railway platform itself, which puts it outside what Railway support can resolve directly.

This is exactly the kind of problem the Railway community is good at, so we'd like to open your thread as a community bounty. Railway pays a bounty to the community member who solves it, and threads like this usually get picked up quickly.

Opening it makes this entire thread public, including everything already posted. Nothing becomes public until you decide. Use the buttons below.

  • Open to the community - Before you click, take a moment to edit or remove anything you'd rather not share. The thread becomes publicly visible right away.
  • Keep it private and close the thread - Nothing becomes public. The thread closes, since this isn't something Railway support can take further.

Status changed to Awaiting Railway Response Railway 21 days ago


Status changed to Awaiting User Response mykal 21 days ago


Railway

Having looked into this, the issue appears to be in your application code or configuration rather than the Railway platform itself, which puts it outside what Railway support can resolve directly. This is exactly the kind of problem the Railway community is good at, so we'd like to open your thread as a community [bounty](https://docs.railway.com/community/bounties). Railway pays a bounty to the community member who solves it, and threads like this usually get picked up quickly. **Opening it makes this entire thread public**, including everything already posted. Nothing becomes public until you decide. Use the buttons below. - **Open to the community** - Before you click, take a moment to edit or remove anything you'd rather not share. The thread becomes publicly visible right away. - **Keep it private and close the thread** - Nothing becomes public. The thread closes, since this isn't something Railway support can take further.

thomasglot
PROOP

20 days ago

Thanks, but this isn't an application or configuration issue — there is nothing to debug on our side. The question is about Railway's billing: what exact formula defines the "Memory" metric that usage billing is based on (raw cgroup memory.current including inactive page cache, or the working-set-like value shown on the dashboard)? That's internal to Railway's metering pipeline — no community member can answer how you bill; only your team can.

So the bounty route doesn't fit here. Please keep the thread private and either answer questions 1–3 from my first message, or escalate to someone on your billing/metrics team. I'm happy to wait for that answer.


Railway
BOT

20 days ago

This still looks like an application-level problem, so Railway support can't take it further, but the community can. The buttons below are still live: open the thread up as a public bounty after editing out anything sensitive, or keep it private and close it.


Railway

This still looks like an application-level problem, so Railway support can't take it further, but the community can. The buttons below are still live: open the thread up as a public [bounty](https://docs.railway.com/community/bounties) after editing out anything sensitive, or keep it private and close it.

thomasglot
PROOP

20 days ago

I'm asking to be escalated to a human on your billing/metrics team, please. This is the second time this thread has been mischaracterized as an application problem.


Railway
BOT

20 days ago

This still looks like an application-level problem, so Railway support can't take it further, but the community can. The buttons below are still live: open the thread up as a public bounty after editing out anything sensitive, or keep it private and close it.


thomasglot
PROOP

20 days ago

I'm asking to be escalated to a human on your billing/metrics team, please.


Railway
BOT

20 days ago

This still looks like an application-level problem, so Railway support can't take it further, but the community can. The buttons below are still live: open the thread up as a public bounty after editing out anything sensitive, or keep it private and close it.


Railway
BOT

20 days ago

This thread has been opened as a public bounty so the community can help solve it. The thread and any further activity are now visible to everyone.

Status changed to Open Railway 20 days ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...