0
0
GraphQLquery~20 mins

Connection pooling in GraphQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Connection Pooling Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What is the main benefit of connection pooling in databases?
Connection pooling helps manage database connections efficiently. What is the primary advantage of using connection pooling?
AIt increases the size of the database storage automatically.
BIt encrypts all data sent between the client and the database.
CIt automatically backs up the database at regular intervals.
DIt reduces the time needed to establish a new connection by reusing existing ones.
Attempts:
2 left
💡 Hint
Think about what happens when you open and close connections repeatedly.
query_result
intermediate
2:00remaining
How many connections are active after these GraphQL queries?
Assume a GraphQL server uses a connection pool with a maximum of 5 connections. Three queries run simultaneously, each requiring a connection. How many connections are active during this time?
A5
B3
C1
D0
Attempts:
2 left
💡 Hint
Each query needs one connection from the pool.
📝 Syntax
advanced
2:00remaining
Identify the correct GraphQL connection pool configuration snippet
Which of the following snippets correctly sets a connection pool with a maximum of 10 connections in a GraphQL server using a typical Node.js setup?
Aconst pool = new Pool(max = 10);
Bconst pool = new Pool({ max_conn: 10 });
Cconst pool = new Pool({ max: 10 });
Dconst pool = new Pool({ maxConnections: 10 });
Attempts:
2 left
💡 Hint
Look for the standard property name for max connections in pool config.
optimization
advanced
2:00remaining
Optimizing connection pool size for a GraphQL API
If a GraphQL API experiences slow responses due to waiting for database connections, which adjustment to the connection pool is most likely to improve performance?
AIncrease the maximum number of connections in the pool.
BDecrease the maximum number of connections in the pool.
CDisable connection pooling to open new connections each time.
DSet the pool size to zero.
Attempts:
2 left
💡 Hint
More connections can handle more simultaneous requests.
🔧 Debug
expert
3:00remaining
Why does this GraphQL server crash with 'too many clients' error?
A GraphQL server uses a connection pool with max 5 connections. The server crashes with 'too many clients' error. Which is the most likely cause?
GraphQL
const pool = new Pool({ max: 5 });

async function resolver() {
  const client = await pool.connect();
  // forgot to release client
  // client.release();
  return await client.query('SELECT * FROM users');
}
AClients are not released back to the pool, exhausting available connections.
BThe query syntax is incorrect causing the crash.
CThe max pool size is too large causing overload.
DThe pool is not initialized properly.
Attempts:
2 left
💡 Hint
Check if connections are returned to the pool after use.