From Local to Global: Making Rails apps resilient
Guillaume Briday
Lyon.rb - September 30, 2025
A little bit of context
Kamal: Why and how you should leave the cloud?
// Paris.rb at @algolia
Web performance myths busted
// Paris.rb at @LeWagon
guillaumebriday.fr/articles
How to scale a db?
How the big players do?
What the scalability told us about resilience?
The plan for today
Before starting
What makes an app resilient ?
How and why to deploy your app globally?
It's not a silver bullet
Before starting
Let's start with a few reminders
Scalability and resilience
They are two sides of the same coin
Scalability : The ability to handle increasing load
Resilience: The ability to recover and continue operating despite unexpected conditions
Different types of scaling
Different types of scaling
Complexity
Resilience
Vertical
😎
🥵
Horizontal
🥵
😎
Not all solutions are created equal
Stateless vs Stateful
Scaling multiple stateless services is easy
Scaling a single stateful service is really hard
Rails is not slow , your database is
Web performance is mostly about latency
Most web apps spend most of their life waiting
Web performance is mostly about latency
TCP/TLS/DNS/HTTP
Network
Concurrency (threads)
Database queries (n+1, round-trip, pooling)
API calls
Serialization
Multi-AZ
External storages (S3, EBS, SSD, Blocks, etc)
Client-side processing (SPA )
cache can remove most of these steps
Web performance is only about latency
The more (micro)-services you have, the more latency you have
What makes an app resilient ?
I spent 2 years living in NYC...
The latency was terrible ...
(Geo)-Load balancer , performance and resilience
An entirely different dimension of complexity
Replication and horizontal scaling is the only way
Vertical scaling
Simple Horizontal scaling
Not so simple Horizontal scaling
Global load balancer
Really hard to implement
Only few providers (AWS, Fly.io, GCP, Cloudflare, etc)
Could be simplified with subdomains (eu., us.)
95% of requests are GET/Read
A single point of failure
DB replication
DB replication
pg_basebackup
One Primary / Multiple Replica
Manual or Auto failover
Replays Write-Ahead Log (WAL)
Real-time streaming replication
Rails 6.0: multi-db
Rails multi-db
production:
primary:
url: <%= ENV['DATABASE_PRIMARY_URL'] %>
adapter: postgresql
primary_replica:
url: <%= ENV['DATABASE_REPLICA_URL'] %>
adapter: postgresql
replica: true
app/models/application_record.rb
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
connects_to database: { writing: :primary, reading: :primary_replica }
end
Global and resilient
Conclusion
Deploy apps globally is really complex
Optimize before going too far
Probably overkill most of the time
Replication is needed for resilience anyway
Hidden complexity (monitoring, credentials, costs, ROI, pooling management)
Best (only?) option for upgrades and migrations