---
title: "1 Year of Autoscaling Postgres: How it’s going, and what’s next"
description: "Neon autoscales Postgres by running each instance as a VM in Kubernetes (NeonVM), with a per-node autoscaler-agent, a modified scheduler, and an in-VM vm-monitor that resizes the Local File Cache."
url: "https://swe.quest/articles/1-year-of-autoscaling-postgres-how-it-s-going-and-what-s-next-a75ce75d92118903"
canonical: "https://neon.com/blog/1-year-of-autoscaling-postgres-at-neon"
source: "Neon"
published: "2024-04-15"
difficulty: "hard"
kind: "Case study"
reading_minutes: 8
tags: ["postgres","virtualization","capacity-planning","memory-management","kubernetes"]
---

# 1 Year of Autoscaling Postgres: How it’s going, and what’s next

A post on [Neon](https://swe.quest/sources/neon.md), published 2024-04-15, 8 min read, Case study. Original: [https://neon.com/blog/1-year-of-autoscaling-postgres-at-neon](https://neon.com/blog/1-year-of-autoscaling-postgres-at-neon)

## Summary

Neon autoscales Postgres by running each instance as a VM in Kubernetes (NeonVM), with a per-node autoscaler-agent, a modified scheduler, and an in-VM vm-monitor that resizes the Local File Cache. Over the past year the team replaced cgroup memory.high event triggers with 100ms polling of memory usage for stability, and traced a 0-TPS stall to a kernel bug in ACPI memory hotplug that was fixed by upgrading the kernel. Next steps include sizing compute with a HyperLogLog estimate of working set from LFC page accesses, since a slightly larger cache can yield 10x gains. They are also adding swap, set up via mkswap/swapon on pre-created VMs, and disabling overcommit so up-front allocations like pgvector 0.6's parallel HNSW builds don't OOM.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Virtualization](https://swe.quest/tags/virtualization.md) (Infrastructure)
- [Capacity planning](https://swe.quest/tags/capacity-planning.md) (Reliability & operations)
- [Memory management](https://swe.quest/tags/memory-management.md) (Compilers & runtimes)
- [Kubernetes](https://swe.quest/tags/kubernetes.md) (Infrastructure)

## Prerequisites

- Kubernetes custom resources ([easy posts on Kubernetes](https://swe.quest/tags/kubernetes.md?difficulty=easy))
- Linux cgroups ([easy posts on Linux](https://swe.quest/tags/linux.md?difficulty=easy))
- Postgres shared buffers ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- virtual machine memory hotplug ([easy posts on Runtimes & VMs](https://swe.quest/tags/runtimes.md?difficulty=easy))

## Keywords

Neon, NeonVM, autoscaler-agent, vm-monitor, Local File Cache, HyperLogLog, pgvector, ACPI memory hotplug

## Related posts

- [Scaling serverless Postgres: How we implement autoscaling](https://swe.quest/articles/scaling-serverless-postgres-how-we-implement-autoscaling-6cecd10b4a114371.md): Neon · 2023-03-29 · Medium · 9 min read · PostgreSQL, Serverless, Kubernetes, Virtualization, Capacity planning
  Neon autoscales serverless Postgres by running each compute endpoint in a QEMU/KVM VM on Kubernetes (via its NeonVM controller) and hot-adding or removing CPU and memory based on load average.
- [Neon Autoscaling is Generally Available](https://swe.quest/articles/neon-autoscaling-is-generally-available-f402e1eef903aa23.md): Neon · 2024-08-26 · Easy · 6 min read · PostgreSQL, Serverless, Capacity planning, Kubernetes, Virtualization
  Neon's Postgres autoscaling is now generally available on all plans, including Free (up to 2 CPU, 8 GB RAM), adjusting CPU and memory to load between user-set minimum and maximum limits, with scale-to-zero.
- [Autoscaling Lakebase Postgres](https://swe.quest/articles/autoscaling-lakebase-postgres-63257ef0753db067.md): Neon · 2026-08-31 · Hard · 12 min read · PostgreSQL, Capacity planning, Virtualization, Algorithms, Kubernetes
  Neon's Lakebase Postgres resizes compute in place about once every 81 seconds by taking the maximum of three target sizes: CPU load (one-minute average kept under 90%), memory (polled every 100 ms by an in-VM monitor and kept under 75%), and the working set of the compute cache.
- [Dynamically estimating and scaling Postgres’ working set size](https://swe.quest/articles/dynamically-estimating-and-scaling-postgres-working-set-size-9625ea29ef0bf2ef.md): Neon · 2024-09-05 · Medium · 12 min read · PostgreSQL, Algorithms, Capacity planning, Caching, Serverless
  Neon autoscales Postgres compute to keep the workload's working set in memory, using a modified HyperLogLog whose register bits are replaced with timestamps so the number of distinct pages accessed can be estimated for any lookback window.
- [RAG With Autoscaling: Better Performance With Lower Costs For pgvector](https://swe.quest/articles/rag-with-autoscaling-better-performance-with-lower-costs-for-pgvector-52ce2e1857682b4f.md): Neon · 2024-08-27 · Medium · 4 min read · Vector search, PostgreSQL, Capacity planning, RAG & retrieval, Cost optimization
  Neon's autoscaling lets a Postgres instance scale up temporarily for the heavy memory and CPU demands of pgvector HNSW index builds, then scale back down, instead of being permanently overprovisioned.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
