0
0
Ruby on Railsframework~20 mins

Puma server configuration in Ruby on Rails - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Puma Configuration Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
Understanding Puma's thread pool behavior
Given this Puma configuration snippet, what is the maximum number of threads Puma will use concurrently?
Ruby on Rails
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
threads threads_count, threads_count
A1
B5
C10
D0
Attempts:
2 left
💡 Hint
Look at the minimum and maximum thread counts set by the threads method.
📝 Syntax
intermediate
2:00remaining
Correct syntax for binding Puma to a TCP port
Which option correctly binds Puma to listen on TCP port 3000 on all interfaces?
Abind 'tcp://0.0.0.0:3000'
Bbind tcp://0.0.0.0:3000
Cbind 'http://0.0.0.0:3000'
Dbind 'tcp:0.0.0.0:3000'
Attempts:
2 left
💡 Hint
The bind method expects a string with the protocol prefix.
🔧 Debug
advanced
2:00remaining
Identify the error in Puma worker configuration
What error will this Puma configuration cause when starting the server? workers ENV.fetch("WEB_CONCURRENCY") { 2 } preload_app! on_worker_boot do ActiveRecord::Base.establish_connection end
Ruby on Rails
workers ENV.fetch("WEB_CONCURRENCY") { 2 }
preload_app!
on_worker_boot do
  ActiveRecord::Base.establish_connection
end
ANo error, configuration is correct
BRuntimeError due to missing block in on_worker_boot
CSyntaxError because of missing colon after on_worker_boot
DNoMethodError because establish_connection is called without parentheses
Attempts:
2 left
💡 Hint
This is a standard Puma configuration for Rails applications using multiple workers.
state_output
advanced
2:00remaining
Effect of preload_app! on application state
What is the main effect of calling preload_app! in Puma configuration?
APreloads the app after workers start, increasing memory usage
BAutomatically reloads code on every request in development
CDisables worker forking and runs all requests in a single process
DLoads the application before workers fork, sharing memory and reducing startup time
Attempts:
2 left
💡 Hint
Think about how forking affects memory and startup speed.
🧠 Conceptual
expert
2:00remaining
Choosing Puma worker count for CPU cores
If a server has 8 CPU cores and you want to optimize Puma for concurrency and memory, which worker count is best practice?
A1 worker with 16 threads to maximize concurrency
B16 workers, double the CPU cores for more parallelism
C8 workers, matching the number of CPU cores
D4 workers with 2 threads each to balance load
Attempts:
2 left
💡 Hint
Consider how Puma uses workers and threads relative to CPU cores.