Ruby on Rails Research & Evidence-Based Practice 3 — Questions and Answers
Question 1: Which gem is the de facto standard for load testing Rails endpoints to gather quantitative throughput evidence?
- RSpec
- Siege or wrk (external tools) (Correct answer)
- Rack::Test
- Faker
Correct answer: Siege or wrk (external tools)
External tools like `siege` or `wrk` generate HTTP load against a Rails server and report requests/sec and error rates.
Question 2: In Rails, `ActiveSupport::Notifications` can be subscribed to for performance research. Which event reports SQL query timing?
- sql.active_record (Correct answer)
- query.active_record
- db.active_record
- execute.sql
Correct answer: sql.active_record
The `sql.active_record` event is published by ActiveRecord for every SQL execution and includes duration, allowing custom metrics collection.
Question 3: A developer wants peer-reviewed evidence before choosing between Redis and Memcached for Rails caching. What is the most rigorous evaluation approach?
- Trust Rails documentation preference
- Benchmark both with the app's actual access patterns and data sizes (Correct answer)
- Use whichever has more GitHub stars
- Pick the one with the newer release
Correct answer: Benchmark both with the app's actual access patterns and data sizes
Evidence-based decisions require benchmarks against the specific workload, not generic benchmarks or popularity metrics.
Question 4: Which Rails configuration setting must be enabled to collect Rack middleware timing data as evidence for response time analysis?
- config.middleware.use Rack::Runtime (Correct answer)
- config.log_level = :debug
- config.action_dispatch.show_exceptions = true
- config.cache_store = :memory_store
Correct answer: config.middleware.use Rack::Runtime
`Rack::Runtime` adds an `X-Runtime` header to responses containing the total request processing time in seconds.
Question 5: To establish whether a database index improves query performance, a developer should compare execution plans before and after. Which PostgreSQL keyword in Rails' `explain` output confirms an index is being used?
- Seq Scan
- Index Scan (Correct answer)
- Hash Join
- Nested Loop
Correct answer: Index Scan
`Index Scan` in a PostgreSQL EXPLAIN output confirms the query planner is using an index rather than a sequential scan.
Question 6: When using Rails' built-in `config.log_level`, which level produces the most granular evidence for debugging performance issues in development?
- :fatal
- :error
- :warn
- :debug (Correct answer)
Correct answer: :debug
`:debug` level logs all SQL queries, render times, and parameter data, providing the most complete picture for performance analysis.
Question 7: A Rails team documents that their API endpoint degrades above 500 concurrent users. What term describes this empirically established performance threshold?
- Breaking point
- Service level objective (SLO)
- Saturation point (Correct answer)
- Latency ceiling
Correct answer: Saturation point
The saturation point is where a system's resources are fully utilized and performance begins to degrade under additional load.
Which gem is the de facto standard for load testing Rails endpoints to gather quantitative throughput evidence?