RailsConf 2024 - The Very Hungry Transaction by Daniel Colson

Maximize performance and reliability in your Ruby on Rails applications by understanding the best practices for transactions, from keeping them short to using cached results and external job queues.

Key takeaways
  • Transactions should be kept short to avoid contention and lock timeouts.
  • External calls within a transaction can cause slowness and errors.
  • Use a public cache to reduce the impact of slow external calls.
  • Avoid nested transactions and use separate transactions for each database.
  • Keep transactions atomic by using callbacks or deferring work until after the transaction commits.
  • Use a job queue adapter to offload slow tasks and improve performance.
  • Monitor transaction performance and identify slow queries to optimize.
  • Use a database connection pool to reduce the impact of slow queries.
  • Consider using a distributed transaction manager to manage transactions across multiple databases.
  • Avoid using a single database connection for multiple transactions.
  • Use a connection pool to manage database connections and reduce contention.
  • Keep transactions short and simple to avoid complexity and errors.
  • Use a transaction manager to manage transactions and ensure atomicity.
  • Monitor transaction performance and identify slow queries to optimize.
  • Use a caching layer to reduce the impact of slow queries.
  • Avoid using a single database connection for multiple transactions.
  • Use a connection pool to manage database connections and reduce contention.
  • Keep transactions short and simple to avoid complexity and errors.
  • Use a transaction manager to manage transactions and ensure atomicity.
  • Monitor transaction performance and identify slow queries to optimize.
  • Use a caching layer to reduce the impact of slow queries.