Skip to content
What is meant by “Speed up your Ruby on Rails Application”

What is meant by “Speed up your Ruby on Rails Application”

By Shubham Singh

Published:

Updated Date:

6 min read

Short on time? Send us your brief for a free proposal.Get a free proposal

A slow Rails app costs users, conversions and infrastructure money. The good news is that most Rails performance problems come from a short list of causes: inefficient database queries, missing caching, work done inside web requests, heavy assets and under-tuned servers. This guide walks through a practical, measure-first approach to speeding up a Ruby on Rails application. Reviewed October 2026.

The short answer: measure first, fix the database (N+1 queries, indexes), cache what’s expensive, move slow work to background jobs, ship lighter assets via a CDN, and tune the server and Ruby runtime. Need help? The Adroit’s Rails team does performance audits.

8areas covered, from database to deployment
4kinds of caching to consider
1rule: measure before you optimise
0guesses: profile real traffic

Step 0: Measure before you change anything

Optimising without data wastes time. Start with:

  • Application performance monitoring (APM): New Relic, Scout, Skylight, Datadog or open-source options show slow endpoints and queries in production.
  • Development profilers: rack-mini-profiler, bullet (finds N+1 queries and unused eager loading), and stackprof or ruby-prof for CPU hotspots.
  • Logs: Rails logs show view, ActiveRecord and total time per request.
  • Front-end: Lighthouse and Core Web Vitals for what users actually experience.

Pick the slowest, most-used endpoints first. A single fix there outweighs many micro-optimisations.

Where to look first

Area Typical problem Typical fix
Database queries N+1 queries, missing indexes, loading too many rows includes/preload, indexes, select/pluck, pagination
Caching Recomputing the same data every request Fragment, low-level and HTTP caching
Request work Emails, exports, API calls inside web requests Background jobs
Assets Large images, JS and CSS Compression, modern formats, lazy loading, CDN
Server setup Too few workers/threads, no reverse proxy Tune Puma, add Nginx/CDN, right-size
Ruby runtime Interpreter overhead Current Ruby and YJIT
Database server Connection exhaustion, slow queries Pool sizing, read replicas, query tuning
Memory Bloat and slow GC Avoid loading large collections, tune allocator

1. Database optimisation

  • Kill N+1 queries: loading associations in a loop fires one query per row. Use includes, preload or eager_load, and confirm with the Bullet gem.
  • Add the right indexes: index columns used in WHERE, JOIN, ORDER BY and foreign keys. Check query plans with EXPLAIN. Avoid over-indexing, which slows writes.
  • Fetch less data: use select or pluck for only the columns you need, and paginate large lists.
  • Use counter caches for frequent counts, and avoid expensive COUNT(*) on big tables in every request.
  • Batch heavy work: use find_each for large iterations.

2. Caching

  • Fragment caching: cache expensive view partials with cache keys that change when data changes (Russian-doll caching).
  • Low-level caching: Rails.cache.fetch for computed values and API responses.
  • HTTP caching: ETags and stale? let browsers and CDNs reuse responses.
  • Cache store: use a shared store appropriate for your setup (Redis, Memcached or the database-backed Solid Cache in recent Rails versions).

Always define how cached data is invalidated, since stale data is a bug.

3. Background jobs

Anything slow or non-essential to the response (sending email, generating PDFs, image processing, third-party API calls, webhooks) should run asynchronously through Active Job with a backend such as Sidekiq, GoodJob or Solid Queue. Return quickly, then process in the background with retries and monitoring.

4. Assets and front-end delivery

  • Compress and bundle JavaScript and CSS (modern Rails uses importmap, esbuild or Vite-style tooling; Propshaft or Sprockets for the pipeline).
  • Serve through a CDN such as Cloudflare or CloudFront, with long cache lifetimes for fingerprinted assets.
  • Optimise images: resize, compress and serve WebP/AVIF through Active Storage variants; lazy-load below-the-fold images.
  • Enable Brotli or Gzip compression at the web server or CDN.
  • Defer non-critical JavaScript and limit third-party scripts.

Front-end speed also affects SEO. See our technical SEO guide.

Not sure which one fits your brief?

Tell us what you need for Ruby on Rails development and we will point you to the right fit, including when that is not us.

5. Server and runtime configuration

  • Tune Puma: set workers and threads according to CPU and memory, and ensure your database pool is at least the number of threads.
  • Put a reverse proxy in front: Nginx, a load balancer or a CDN to handle static files and slow clients.
  • Use a recent Ruby and enable YJIT, which often gives a noticeable speed-up with no code changes.
  • Right-size infrastructure and scale horizontally when needed.

6. Database connection management

Match the connection pool to your threads and background workers, watch for connection exhaustion, and consider a pooler like PgBouncer for PostgreSQL at scale. Read replicas can offload reporting queries.

7. Code-level improvements

  • Avoid loading large collections into memory; stream or batch.
  • Remove unused callbacks and gems that add overhead.
  • Keep views simple and move logic into models, helpers or presenters.
  • Use serializers efficiently for APIs and paginate responses.

8. Keep Rails and gems updated

Newer Rails and Ruby versions bring performance improvements and security fixes. Plan regular upgrades, backed by a good test suite (see TDD with Rails).

A simple performance workflow

  1. Set a goal (for example, p95 response time under a target).
  2. Identify the slowest, most-used endpoints with APM.
  3. Profile one endpoint and find the biggest cost (usually queries).
  4. Fix it, add a test or benchmark, and deploy.
  5. Re-measure, then move to the next bottleneck.

Conclusion

Speeding up a Rails app is a loop of measure, fix and verify. Start with the database and caching, move slow work off the request, trim assets and tune the server and Ruby runtime. If you want an expert review, talk to The Adroit’s Ruby on Rails team or hire Rails developers.

Get a Rails performance audit

FAQs

Why is my Rails app slow?

Most often because of N+1 or unindexed queries, missing caching, heavy work inside requests, large assets or an under-tuned server.

What is an N+1 query?

Loading a list and then querying associated records one by one. Fix with includes or preload, and detect with the Bullet gem.

What tools profile Rails performance?

APM tools such as New Relic, Scout or Skylight, plus rack-mini-profiler, Bullet, stackprof and Rails logs.

What should run in background jobs?

Emails, exports, image/PDF processing, third-party API calls and anything slow that the user doesn’t need to wait for.

Does YJIT really help?

On recent Ruby versions YJIT often provides a meaningful speed-up for typical Rails apps with little effort. Test on your own workload.

Which caching should I start with?

Fragment caching for expensive views and low-level caching for computed data, with clear invalidation.

Do I need a CDN?

For public sites with global or heavy asset traffic, yes. A CDN reduces latency and server load.

Can The Adroit audit my Rails app?

Yes. The Adroit’s Rails team reviews performance, security and code quality and implements fixes.

Choosing a Ruby on Rails development partner?

Share your goals and budget range. We reply with a scoped plan and an honest view of fit, with no obligation.

SHARE ON

Author Shubham Singh

Shubham Singh is a dedicated Account manager,he plays a key role in following the established ground rules and is very passionate about his work and is known for his consistency. He is an aspirant manager who makes sure to master his skills and talents to manage his team.
Shubham is like a versatile masked actor in the office performing various roles most importantly catering to his clients and employees.
His friendly repertoire and admiration towards work and productivity builds his major rapport and serves as a strength booster.

Hello!

We'd love to show you how you can get more traffic and leads

WhatsApp us