title: How can I replay web requests on a production clone to control a release candidate?
body: <p>I have a critical Rails app running in production with a fairly standard setup: Rails 5 API, Puma, PostgreSQL, Sidekiq, Heroku. I also have a branch that involves risky database migrations and application code changes.</p>
  
  <p>I'd like to clone the production setup and data to a dedicated staging environment and, for a few busy hours, run all production web requests on both environments to control the effect of this change on the data.</p>
  
  <p>Things I thought about so far:</p>
  
  <ul>
  <li>this can't be only about replaying database logs, as changes happen at the application level</li>
  <li>some API requests schedule some Sidekiq jobs 1 minute in the future, so ideally this also triggers jobs real-time</li>
  <li>it'd be great if this was done at the Heroku router or application level instead of higher up the chain (DNS, load balancer etc.): I could see a Rake middleware in the main application that mirrors all requests to this production clone, or an <code>after_action</code> filter in select Rails controllers</li>
  </ul>
  
  <p>A way for me to control these changes would be to look at errors raised by the production clone (application errors and database rollbacks).</p>