mediumMultiple Choice
Google ACE Practice Question: You notice that your Cloud SQL for PostgreSQL…
You notice that your Cloud SQL for PostgreSQL instance's `pg_stat_activity` shows many connections in `idle in transaction` state, and the connection count is near the max_connections limit. Application threads are blocking waiting for connections. What is the most effective solution to manage database connections for a GKE-hosted application?
⚠ Common exam trap
Google Cloud often tests the misconception that simply increasing `max_connections` is a safe scaling solution, when in fact it can lead to resource exhaustion and does not address the underlying idle connection problem.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Deploy PgBouncer as a sidecar or deployment to pool connections to Cloud SQL in transaction mode.
PgBouncer is a lightweight connection pooler that can be deployed as a sidecar or separate deployment in GKE to manage connections to Cloud SQL for PostgreSQL. By operating in transaction mode, it holds database connections only for the duration of a transaction, not for the entire client session, which drastically reduces the number of concurrent connections to the database. This directly addresses the `idle in transaction` connections and the near-max_connections issue without requiring application code changes.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Increase `max_connections` in the Cloud SQL PostgreSQL instance flags.
Why it's wrong here
Raising max_connections allocates more backend processes and memory per connection, but the idle-in-transaction sessions still hold their slots, so threads keep blocking. It is tempting because it directly lifts the ceiling; it would be correct when genuine concurrent demand exceeds the default limit without leaked transactions.
- ✓
Deploy PgBouncer as a sidecar or deployment to pool connections to Cloud SQL in transaction mode.
Why this is correct
PgBouncer in transaction mode multiplexes many client connections onto few server connections, releasing the backend between transactions. This clears idle-in-transaction sessions and keeps Cloud SQL below max_connections, resolving the thread blocking that a larger connection limit would not fix.
- ✗
Switch from Cloud SQL to Cloud Spanner, which has no connection limits.
Why it's wrong here
Spanner's schema, SQL dialect and transaction model differ from PostgreSQL, so migrating does not address the idle-in-transaction sessions blocking connections. It is tempting because Spanner removes max_connections limits entirely, making it the right answer when the requirement is horizontal scale beyond a single node.
- ✗
Restart the Cloud SQL instance to clear idle connections.
Why it's wrong here
Restarting terminates every session, including active ones, and the application immediately reconnects and re-enters idle-in-transaction, so the blockage returns. It is tempting as a quick unblock; it would be correct for clearing a stuck instance during a maintenance window, not for managing connection lifecycle.
Go deeper
Related to this question
Learn chapter
GCP Database Services
Key term
GKE
GKE is Google's managed Kubernetes service that automates deploying, scaling, and managing containerized applications in the cloud.
Key term
Cloud SQL
Cloud SQL is a fully managed relational database service that lets you set up, maintain, and scale SQL databases (like MySQL, PostgreSQL, and SQL Server) in the cloud without managing the underlying infrastructure.
About these practice questions
Courseiva writes every ACE question from scratch — 775 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This ACE practice question is part of Courseiva's free Google Cloud certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the ACE exam.