Ruby on Rails Research & Evidence-Based Practice 5 — Questions and Answers
Question 1: Which metric from Rails' production logs provides the most direct evidence of a memory leak in a long-running process?
- Increasing response times over hours
- Monotonically growing RSS memory reported by `ps` or `top` (Correct answer)
- Increasing number of database connections
- Frequent garbage collection log entries
Correct answer: Monotonically growing RSS memory reported by `ps` or `top`
RSS (Resident Set Size) that grows without bound across requests over time is the canonical evidence of a memory leak.
Question 2: In test-driven Rails development, what constitutes 'evidence' that a new feature is complete?
- The feature is deployed to staging
- All acceptance tests written from requirements pass and no existing tests regress (Correct answer)
- A code review is approved
- The feature works manually in development
Correct answer: All acceptance tests written from requirements pass and no existing tests regress
Passing acceptance tests derived directly from requirements, with no regressions, provide objective evidence of feature completeness.
Question 3: A Rails team wants empirical evidence about which pages users exit most. Which integration provides this behavioral data?
- Rails request logs alone
- Google Analytics or similar with exit page tracking (Correct answer)
- ActiveRecord query logs
- RSpec feature specs
Correct answer: Google Analytics or similar with exit page tracking
Analytics platforms like Google Analytics track exit pages by instrumenting real user sessions, providing behavioral evidence for UX decisions.
Question 4: Which approach provides the strongest evidence when deciding whether to extract a Rails service object from a fat model?
- Following the single responsibility principle by instinct
- Measuring test execution time and cyclomatic complexity before and after (Correct answer)
- Checking if the model file exceeds 200 lines
- Asking the team for opinions
Correct answer: Measuring test execution time and cyclomatic complexity before and after
Measuring cyclomatic complexity and test suite speed before and after extraction provides objective evidence that the refactor improved maintainability.
Question 5: What is the purpose of a Rails `config/initializers/inflections.rb` research spike, and how should findings be documented?
- It is not research-worthy; inflections are trivial
- Document unexpected pluralization edge cases as failing tests before fixing them (Correct answer)
- Log inflection rules to the database for future reference
- Use it to benchmark string manipulation performance
Correct answer: Document unexpected pluralization edge cases as failing tests before fixing them
Documenting edge cases as failing tests before fixing them captures the discovered behavior as verifiable evidence for future developers.
Question 6: A team disputes whether PostgreSQL full-text search or Elasticsearch is faster for their Rails app. What constitutes valid comparative evidence?
- A blog post benchmark from a different use case
- Benchmarks run against their own dataset, query types, and concurrency levels (Correct answer)
- The number of production companies using each option
- Rails documentation recommendations
Correct answer: Benchmarks run against their own dataset, query types, and concurrency levels
Valid evidence requires benchmarks that mirror your specific dataset size, query patterns, and concurrency — not generic or third-party results.
Question 7: When evaluating the impact of adding a Redis cache layer to a Rails app, which before/after metric pair provides the clearest evidence of improvement?
- Lines of code added vs. removed
- p95 response time and database query count per request (Correct answer)
- Number of model associations and scopes
- Test suite execution time
Correct answer: p95 response time and database query count per request
p95 response time captures real-user latency and database query count per request shows if caching is reducing DB load — both directly measure the cache's value.
Which metric from Rails' production logs provides the most direct evidence of a memory leak in a long-running process?