<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/scaling-down-costs-not-performance-how-we-migrated-from-couchbase-to-postgresql-g6w06rund" -->

---
title: Scaling Down Costs, Not Performance: How We Migrated...
description: Trendyol's product content team details a phased, zero-downtime migration of five 'helper bucket' datasets (2.24 billion documents across two clusters) from...
canonical: https://daily.dev/posts/scaling-down-costs-not-performance-how-we-migrated-from-couchbase-to-postgresql-g6w06rund
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Scaling Down Costs, Not Performance: How We Migrated from Couchbase to PostgreSQL | daily.dev
og:description: Trendyol's product content team details a phased, zero-downtime migration of five 'helper bucket' datasets (2.24 billion documents across two clusters) from...
og:url: https://daily.dev/posts/scaling-down-costs-not-performance-how-we-migrated-from-couchbase-to-postgresql-g6w06rund
og:image: https://api.daily.dev/og/posts/g6w06rUnd.png
og:image:alt: Scaling Down Costs, Not Performance: How We Migrated from Couchbase to PostgreSQL
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Scaling Down Costs, Not Performance: How We Migrated from Couchbase to PostgreSQL

**[Trendyol Tech](https://daily.dev/sources/trendyoltech)** · 21 min read · 67 upvotes · 2 comments

## Summary

Trendyol's product content team details a phased, zero-downtime migration of five 'helper bucket' datasets (2.24 billion documents across two clusters) from Couchbase to PostgreSQL to cut infrastructure costs while preserving read performance. The strategy combined dual-writes via Kafka consumers, a custom CDC-based migrator tool for historical backfill, and feature-flagged cutover of read traffic. Key production challenges included a mysterious TPS spike traced to PgBouncer's server_reset_query_always setting, a connection-limit incident causing a primary node failover, and a hidden scaling issue where PgBouncer's own horizontal autoscaling multiplied backend connections beyond expectations (20 pods × 150 default_pool_size = 3000 potential connections). Final production benchmarks showed stable P50 latency and only a brief P99 spike (200ms to 400ms) under peak load, validating the migration.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://medium.com/trendyol-tech/scaling-down-costs-not-performance-how-we-migrated-from-couchbase-to-postgresql-43cae3e1b8f8>

## Questions this post answers

### What causes a TPS spike in PostgreSQL when using PgBouncer with transaction pooling mode?

Setting server_reset_query_always to 1 in PgBouncer causes it to run a DISCARD ALL query every time a connection returns to the pool, even for connections used briefly. In transaction pooling mode, connections change hands within milliseconds, so this generates massive extra transaction overhead and forces repeated query re-parsing. Setting the value to 0 resolved a 170,000 TPS spike that scaled to over 10 million RPM equivalent.

_Anyone tuning PgBouncer for high-throughput workloads can compare configuration pitfalls like this on daily.dev._

### Why did my PostgreSQL cluster hit its connection limit even though PgBouncer connection pooling was configured?

PgBouncer itself can horizontally auto-scale under heavy load, multiplying total backend connections beyond expectations. In one case, default_pool_size was left at 150 per PgBouncer pod, and Kubernetes scaled PgBouncer up to 20 pods during traffic peaks, yielding 3,000 potential connections against a 2,500 database limit. Lowering default_pool_size well below 150 kept total connections safely under the cluster limit even at maximum pod scale.

_Engineers debugging connection exhaustion under autoscaling can find similar production postmortems on daily.dev._

### How much can P99 latency increase when migrating a high-traffic read workload from Couchbase to PostgreSQL?

During a live production peak with roughly 70,000 transactions per second and nearly 2,000 database connections, P99 latency briefly spiked from 200 ms to 400 ms before quickly returning to baseline, while P50 latency remained flat. Memory usage stayed around 70% and CPU peaked at 80% without causing bottlenecks, confirming the switch preserved read performance at billions-of-document scale.

_Teams weighing a NoSQL-to-relational migration can track real-world benchmarks like this on daily.dev._

## Community discussion

Top comments from developers on daily.dev.

**@agustinbarrientos** · 0 upvotes

> Did you shrink the 150-connection pool before autoscaling came back? At 20 pods, that default gets scary fast.

## Similar posts on daily.dev

- [Switching from PostgreSQL to ClickHouse for Improved Performance and Scalability](https://daily.dev/posts/switching-from-postgresql-to-clickhouse-for-improved-performance-and-scalability-kjtwee69g) · InfoQ · 5 upvotes · 0 comments
- [Scaling PostgreSQL to power 800 million ChatGPT users](https://daily.dev/posts/scaling-postgresql-to-power-800-million-chatgpt-users-3mbfuagbd) · OpenAI · 297 upvotes · 11 comments
- [How we migrated Clera’s 500 GB production database to ClickHouse Managed Postgres overnight](https://daily.dev/posts/how-we-migrated-clera-s-500-gb-production-database-to-clickhouse-managed-postgres-overnight-vjiq1dqwf) · ClickHouse · 4 upvotes · 1 comments
- [Your Staff Engineer Interview Was Going Great. Then They Asked You to Migrate 2 Billion Rows](https://daily.dev/posts/your-staff-engineer-interview-was-going-great-then-they-asked-you-to-migrate-2-billion-rows-sheqrejea) · Medium · 10 upvotes · 1 comments

---

Tags: [#database](https://daily.dev/tags/database), [#postgresql](https://daily.dev/tags/postgresql), [#couchbase](https://daily.dev/tags/couchbase)

[View this post on daily.dev](https://daily.dev/posts/scaling-down-costs-not-performance-how-we-migrated-from-couchbase-to-postgresql-g6w06rund)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Scaling Down Costs, Not Performance: How We Migrated from Couchbase to PostgreSQL","url":"https://daily.dev/posts/scaling-down-costs-not-performance-how-we-migrated-from-couchbase-to-postgresql-g6w06rund","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/scaling-down-costs-not-performance-how-we-migrated-from-couchbase-to-postgresql-g6w06rund"},"datePublished":"2026-09-07T19:31:11.891Z","dateModified":"2026-09-14T06:20:36.621Z","description":"Trendyol's product content team details a phased, zero-downtime migration of five 'helper bucket' datasets (2.24 billion documents across two clusters) from...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/9149dd11b439ea4deb443bc5946f6498?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/9149dd11b439ea4deb443bc5946f6498?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Trendyol Tech","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Trendyol Tech","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/67480ca531174b03952be35abd6572a9","url":"https://daily.dev/sources/trendyoltech"},"commentCount":2,"discussionUrl":"https://daily.dev/posts/scaling-down-costs-not-performance-how-we-migrated-from-couchbase-to-postgresql-g6w06rund","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":67},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":2}],"keywords":"database,postgresql,couchbase","timeRequired":"PT21M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Trendyol Tech","item":"https://daily.dev/sources/trendyoltech"},{"@type":"ListItem","position":3,"name":"Scaling Down Costs, Not Performance: How We Migrated from Couchbase to PostgreSQL"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/scaling-down-costs-not-performance-how-we-migrated-from-couchbase-to-postgresql-g6w06rund","comment":[{"@type":"Comment","text":"Did you shrink the 150-connection pool before autoscaling came back? At 20 pods, that default gets scary fast.","datePublished":"2026-09-09T11:09:24.253Z","url":"https://daily.dev/posts/g6w06rUnd#c-lZwz6MfZW","author":{"@type":"Person","name":"Agustin Barrientos","url":"https://daily.dev/agustinbarrientos","image":"https://media.daily.dev/image/upload/s--5ayxQnqn--/f_auto/v1788281802/avatars/avatar_wQYYVe5Tbj0NJ7C7qPoa8?_a=BAMAMicg0"}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/scaling-down-costs-not-performance-how-we-migrated-from-couchbase-to-postgresql-g6w06rund#faq","mainEntity":[{"@type":"Question","name":"What causes a TPS spike in PostgreSQL when using PgBouncer with transaction pooling mode?","acceptedAnswer":{"@type":"Answer","text":"Setting server_reset_query_always to 1 in PgBouncer causes it to run a DISCARD ALL query every time a connection returns to the pool, even for connections used briefly. In transaction pooling mode, connections change hands within milliseconds, so this generates massive extra transaction overhead and forces repeated query re-parsing. Setting the value to 0 resolved a 170,000 TPS spike that scaled to over 10 million RPM equivalent. Anyone tuning PgBouncer for high-throughput workloads can compare configuration pitfalls like this on daily.dev."}},{"@type":"Question","name":"Why did my PostgreSQL cluster hit its connection limit even though PgBouncer connection pooling was configured?","acceptedAnswer":{"@type":"Answer","text":"PgBouncer itself can horizontally auto-scale under heavy load, multiplying total backend connections beyond expectations. In one case, default_pool_size was left at 150 per PgBouncer pod, and Kubernetes scaled PgBouncer up to 20 pods during traffic peaks, yielding 3,000 potential connections against a 2,500 database limit. Lowering default_pool_size well below 150 kept total connections safely under the cluster limit even at maximum pod scale. Engineers debugging connection exhaustion under autoscaling can find similar production postmortems on daily.dev."}},{"@type":"Question","name":"How much can P99 latency increase when migrating a high-traffic read workload from Couchbase to PostgreSQL?","acceptedAnswer":{"@type":"Answer","text":"During a live production peak with roughly 70,000 transactions per second and nearly 2,000 database connections, P99 latency briefly spiked from 200 ms to 400 ms before quickly returning to baseline, while P50 latency remained flat. Memory usage stayed around 70% and CPU peaked at 80% without causing bottlenecks, confirming the switch preserved read performance at billions-of-document scale. Teams weighing a NoSQL-to-relational migration can track real-world benchmarks like this on daily.dev."}}]}
```

