October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

How to Scale Your Mastodon Server: A Practical Guide to Web, Streaming, Sidekiq, PostgreSQL, Redis and Media

Scale Mastodon from measurements, not a users-per-server guess. Learn how to tune Puma, add streaming and Sidekiq capacity, protect PostgreSQL and Redis, share media storage, and operate multiple nodes safely.
Length13 min Posted Quest giverVGSources Team

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Scale Mastodon by finding the saturated tier first, then increasing only the capacity that relieves that bottleneck. Puma handles short HTTP requests, the streaming API handles long-lived connections, and Sidekiq performs delivery, email and other background jobs. Each tier has different CPU, memory, connection and failure characteristics.

There is no official “users per server” formula or universal hardware size. A reliable design comes from your own measurements: request latency, queue delay, PostgreSQL connections, Redis memory and latency, streaming channels, and media growth. The sequence below shows how to measure those signals, split services across nodes, protect shared databases, and move media to storage that every node can reach.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What scaling a Mastodon server actually involves

A Mastodon instance is not one process that becomes faster when you buy a larger machine. It is a group of independently tunable services. Mastodon’s own documentation describes three process types:

Tier Primary job Typical saturation signal First scaling action
Web (Puma) Short-lived HTTP requests such as timelines, account pages and API calls Rising request latency, busy workers or exhausted web CPU Adjust worker processes or add another web node
Streaming API Long-lived HTTP/WebSocket connections and live updates Too many channels, high event latency or an unhealthy streaming process Run additional streaming instances and load-balance them
Background processing (Sidekiq) Federation delivery, incoming activity handling, email and other asynchronous jobs Growing queue latency, failed jobs or delayed federation Increase queue-specific capacity while preserving priority

These tiers share PostgreSQL and Redis, so scaling one of them can move the bottleneck into a shared dependency. More Puma workers, Sidekiq threads or streaming instances can all increase database connection demand. A larger process count is therefore not automatically an improvement; it must fit the connection, CPU and memory budgets of the whole deployment.

Measure before changing the architecture

Record a baseline during normal traffic and during your busiest predictable periods. Change one class of capacity at a time, then compare the same measurements before and after. The load balancer can hide an individual node that is failing, so collect metrics from every web and streaming instance as well as from the aggregate service.

Web and Puma measurements

  • Request latency by endpoint or operation, not only an overall average.
  • Worker and thread saturation, including periods when requests wait for an available Puma slot.
  • CPU and memory per web process and per host.
  • Error rates and timeout counts during traffic spikes.

Consistently high latency with idle database capacity points toward Puma or host resources. Latency that rises alongside database waits suggests that adding web concurrency would only create more contention.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Sidekiq measurements

  • Queue depth and queue latency for each queue.
  • Job failure and retry rates.
  • Throughput for delivery, ingress and local work.
  • Sidekiq process CPU, memory and PostgreSQL connection use.

Track queues separately. A healthy default queue does not prove that remote delivery is keeping up, and a large push queue does not justify starving work that serves local users.

PostgreSQL measurements

  • Current and peak connections compared with the configured PostgreSQL limit.
  • Connection waits and transaction duration.
  • CPU, memory, disk latency and storage growth.
  • Replica lag if read replicas are enabled.

Mastodon’s scaling documentation cites 100 as PostgreSQL’s default connection limit. Treat that as a starting limit, not a target: leave room for administrative access and for processes that are not obvious from a single application host.

Redis measurements

  • Used memory and eviction activity.
  • Command latency and blocked clients.
  • Queue traffic, feed activity and streaming message volume.
  • Replication and Sentinel health when high availability is configured.

Streaming and media measurements

  • Connected channels on each streaming instance.
  • Messages sent and Redis messages received.
  • Streaming process CPU, memory and open connections.
  • Growth of local media disks and object-storage usage over time.

The official scaling guidance specifically calls out connected channels, messages sent and Redis messages received. A node-by-node view is essential: an aggregate dashboard can look normal while one streaming process is overloaded.

Split the three application tiers

On a small instance, Puma, streaming and Sidekiq may share a host. As traffic grows, separate them according to the metric that is limiting users. A common progression is:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Keep the current topology while collecting per-tier metrics.
  2. Move the tier with the clearest bottleneck to its own service or host.
  3. Add a second instance of that tier only after confirming that PostgreSQL, Redis and network capacity can support it.
  4. Place multiple instances behind health-checked load balancing.
  5. Re-evaluate shared dependencies after every concurrency change.

Separating tiers improves fault isolation. A burst of federation work can consume Sidekiq CPU without taking web requests down, while a streaming connection surge can be handled without reducing Puma capacity. It also makes rollback simpler because a tier can be changed independently.

Tune Puma web capacity carefully

Puma exposes two documented controls: WEB_CONCURRENCY sets worker processes and MAX_THREADS sets threads per process. The configuration documentation lists defaults of two workers and five threads per worker for those variables; defaults are version-sensitive, so verify them against the release you operate.

Choose processes versus threads

More worker processes generally improve throughput until memory or another shared resource becomes the limit. More threads can improve concurrency for suitable workloads, but the scaling guide warns that threads tend to exhaust CPU first, while processes tend to exhaust RAM first. Increase one dimension at a time and watch both resources.

  • If workers are continuously busy, latency rises and memory has headroom, test a process increase.
  • If CPU is already saturated, adding threads is likely to worsen response time.
  • If memory pressure or swapping appears, reduce process count or add RAM before increasing concurrency.
  • If PostgreSQL connections approach the limit, stop increasing Puma and address the connection budget.

Do not copy a worker number from another instance. The right value depends on request mix, database latency, Ruby workload, host size and the capacity reserved for Sidekiq and streaming.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Add streaming capacity horizontally

The current configuration documentation describes the streaming server as a single Node.js process per instance. The older STREAMING_CLUSTER_NUM setting has been removed; scaling now means running additional streaming instances and placing them behind a suitable proxy or load balancer.

Plan a streaming node

  1. Run the streaming service separately from Puma when long-lived connections compete with web requests.
  2. Start another streaming instance using the same application configuration and shared Redis access.
  3. Register both instances with the load balancer.
  4. Enable the streaming health check at /api/v1/streaming/health.
  5. Monitor connected channels and message rates on each instance, not only in aggregate.

Every additional streaming instance can consume PostgreSQL connections. Include its connection use in the same budget as Puma and Sidekiq before adding nodes. If one instance reports rising latency or fails its health check, remove it from rotation while existing connections drain or reconnect according to your proxy’s behavior.

Scale Sidekiq by queue and connection budget

Sidekiq concurrency determines how quickly asynchronous work is processed. Its threads handle tasks such as federation delivery and email, but each Sidekiq thread requires a PostgreSQL connection. The documented rule is that DB_POOL should be at least as large as the Sidekiq thread count.

Preserve queue priority

Mastodon’s queues have different user impact:

  • default affects work for local users.
  • push delivers activities to other servers.
  • ingress handles incoming remote activities and runs at lower priority than local-user work.

Increase capacity where latency is growing rather than raising every queue equally. Protect the default queue from a federation burst, and ensure that push capacity does not create a database connection storm. If retries grow after increasing concurrency, inspect database waits, remote delivery failures and Redis latency before adding more threads.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Set a safe Sidekiq change process

  1. Record queue latency, depth, failures and PostgreSQL connections.
  2. Increase concurrency for the affected queue or process group in a small step.
  3. Confirm that DB_POOL covers the resulting thread count.
  4. Watch PostgreSQL CPU, connection waits and Redis latency during the change.
  5. Roll back if local-user latency, connection pressure or failure rates deteriorate.

Protect PostgreSQL as concurrency grows

PostgreSQL is often the first shared limit because every application tier depends on it. Adding Puma workers, Sidekiq threads and streaming instances multiplies connection demand. When the combined demand approaches PostgreSQL’s limit, Mastodon documents PgBouncer transaction pooling as the next step.

Use PgBouncer for connection pressure

Transaction pooling allows many short-lived application sessions to share a smaller set of PostgreSQL server connections. The trade-off is that prepared statements must be disabled. Mastodon’s configuration documentation notes that the pooling benefit can outweigh prepared-statement advantages at scale.

Introduce PgBouncer only after measuring connection pressure. It does not make slow queries faster, add database CPU or solve insufficient storage performance. Validate transaction behavior, prepared-statement settings and failure recovery in a staging environment before switching production traffic.

Add read replicas when reads are the limit

Mastodon 4.2 and later include built-in read-replica support through REPLICA_DB_* settings or REPLICA_DATABASE_URL. The application pauses replica reads when lag exceeds a few seconds, so monitor lag and confirm that the primary can resume the workload when a replica falls behind.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read replicas are useful only when read workload is significant and replication keeps up. They do not replace a properly sized primary for writes, nor do they remove the need to budget connections for every application process.

Separate and harden Redis

Redis carries home feeds, list feeds, Sidekiq queues, streaming communication and cache workloads. These uses have different traffic patterns and failure consequences. If one Redis instance is overloaded, isolate roles instead of increasing application concurrency against the same bottleneck.

Split Redis roles

  • Configure a separate cache Redis with CACHE_REDIS_* when cache activity competes with operational data.
  • Use dedicated Sidekiq Redis settings, SIDEKIQ_REDIS_*, when queue traffic needs isolation.
  • Keep streaming communication on infrastructure with enough memory and low command latency.

Role separation makes alerts meaningful: a cache eviction event should not look like a Sidekiq outage, and queue latency should not be hidden by an aggregate Redis average.

Use Sentinel for failover

Redis Sentinel can monitor masters and direct clients to a new primary after failure. Configure and test timeout, quorum and failover behavior against your actual availability target. A failover mechanism that has never been exercised can leave clients pointed at an unavailable endpoint or produce a longer outage than a planned restart.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Move media to shared object storage

User-uploaded files can remain on a host filesystem, but Mastodon’s object-storage documentation says external storage can be required for scaling. Shared S3-compatible storage gives every web, streaming and background node access to the same media namespace and prevents one host’s disk from becoming the growth limit.

Why local media breaks multi-node designs

With local disks, an upload handled by one node may not exist on another node that receives the next request. Replicating files between hosts adds another system to operate and another failure mode. Object storage presents one shared location to all nodes, so adding or replacing an application host does not require copying the entire media library first.

Include object storage in backup planning

The backup guidance names Amazon S3, Google Cloud and Wasabi as examples where locally backing up uploaded files is unnecessary. That does not mean media needs no protection. Define retention, versioning or deletion recovery according to your storage provider and test restoring representative files and metadata. Keep database backups coordinated with media backups so account records do not point to missing objects.

Put web and streaming nodes behind health-checked load balancing

Multiple Puma or streaming nodes need a load balancer that can stop sending traffic to an unhealthy backend. Mastodon’s scaling guide names DigitalOcean, AWS and Hetzner as examples of providers offering virtual load balancing; the important property is health checking, not a particular vendor.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Backend Health-check path Expected response
Web/Puma /health HTTP 200 with OK
Streaming /api/v1/streaming/health HTTP 200 with OK

Use separate backend pools for web and streaming so a streaming failure does not remove healthy web capacity. Monitor health-check transitions, connection draining and reconnect storms. During maintenance, take one node out of rotation, verify that the remaining nodes absorb traffic, then update or reboot the drained node.

Control media-cache and archive growth

Media is not the only storage that expands. Mastodon administration settings include media-cache retention and user-archive retention. Cleanup runs through the background scheduler, so retention is a capacity decision rather than an emergency command performed after a disk is full.

Set a retention policy

  1. Estimate current media-cache and archive growth from disk or object-storage measurements.
  2. Choose retention periods that match user expectations, legal obligations and available storage.
  3. Confirm that the background scheduler is running reliably.
  4. Watch cleanup job latency and storage usage after changing the policy.
  5. Keep alerts below the point where cleanup itself cannot run because the disk is exhausted.

Shorter retention reduces storage growth but can cause older remote media to be fetched again. Longer retention improves availability of previously viewed media while increasing cost and backup scope.

Choose an architecture by bottleneck, not by user count

No official Mastodon document establishes a universal number of users, CPU cores, RAM, storage size or throughput for an instance. Compare architectures using the constraints you can measure.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Architecture Bottleneck addressed Benefits Trade-offs
Single host with all tiers Useful for low or predictable load Few moving parts and simple deployment One failure domain; tiers compete for CPU, memory and disk
Separate web, streaming and Sidekiq hosts Tier-specific CPU, memory or connection pressure Independent tuning and fault isolation More networking, monitoring and deployment coordination
Multiple web and streaming nodes behind a load balancer HTTP or connection volume and node failure Horizontal capacity and maintenance without a full outage Requires health checks, shared state and careful draining
PgBouncer with a primary database Application connection exhaustion More efficient transaction-level connection sharing Prepared statements must be disabled; another service must be operated
Read replica plus primary Read workload on the primary Read capacity and a path to isolate replica traffic Replication lag and additional database operations
Dedicated Redis roles with Sentinel Redis contention or single-primary failure Isolation and automated primary discovery More instances, failover testing and monitoring
Shared S3-compatible media storage Local-disk growth and multi-node file access Common media namespace and easier host replacement Ongoing storage, request and backup-policy costs

For each option, document six decisions: which bottleneck it addresses, how much queue and connection headroom it adds, what fails and how recovery works, the operational complexity, recurring cost, and the durability and portability of the data.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

A safe multi-server rollout

  1. Inventory dependencies. List PostgreSQL, Redis roles, media storage, DNS, certificates, background scheduling and outbound network requirements.
  2. Centralize media first when needed. Move uploads to shared object storage and verify that existing and newly uploaded files are readable from every application node.
  3. Separate one tier. Move the measured bottleneck, such as Sidekiq or streaming, without changing unrelated concurrency settings.
  4. Add health checks. Register the new node with the correct endpoint and confirm the expected HTTP 200 and OK response.
  5. Test failure. Remove the new node from rotation, stop it, and verify that users still receive web responses, streaming reconnects and background processing.
  6. Increase capacity gradually. Change worker, thread or queue settings in small steps while watching PostgreSQL and Redis.
  7. Record the working configuration. Keep versioned environment settings, connection budgets, health-check behavior and rollback steps with the deployment.

Troubleshooting common scaling failures

Latency worsened after adding Puma workers

Check PostgreSQL connections, CPU and lock or transaction waits. More workers may have exhausted the database or host CPU. Reduce concurrency, add PgBouncer when connection exhaustion is the measured limit, or improve the database constraint before trying another increase.

Federation remains delayed after increasing Sidekiq

Inspect the push queue, retry failures, remote delivery errors, Redis latency and PostgreSQL connections. Confirm that default-queue work still has priority for local users. Additional threads cannot overcome a remote endpoint outage or a saturated shared dependency.

One streaming node is unhealthy while the pool looks normal

Inspect that node’s connected channels, messages sent, Redis messages received, CPU and memory. Verify the streaming health endpoint directly and remove the node from rotation. Aggregate load-balancer metrics can conceal this failure.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Users see missing media after adding a second node

Check whether uploads still land on local disks. Multi-node application servers need a shared media namespace, normally provided by external S3-compatible storage. Verify credentials, bucket access and read-after-upload behavior from every node.

Redis failover causes a prolonged outage

Review Sentinel quorum, timeout settings and client discovery. Test a controlled primary failure, observe which clients reconnect, and document the time required to restore queue, cache and streaming functions.

Replica reads are stale

Measure replication lag and confirm the application’s lag protection is active. Mastodon pauses replica reads when lag reaches a few seconds; if lag remains high, route the workload to the primary while investigating replica CPU, storage and network performance.

Capacity-planning checklist

  • Web latency, Puma workers, threads, CPU and memory are recorded per node.
  • Streaming channels and message rates are recorded per streaming instance.
  • Sidekiq queue depth, latency, failures and retries are separated by queue.
  • Total PostgreSQL demand includes every Puma worker, Sidekiq thread and streaming instance.
  • DB_POOL is at least the Sidekiq thread count.
  • PgBouncer transaction-pooling implications, including disabled prepared statements, are documented if used.
  • Redis cache, Sidekiq and streaming workloads have enough memory and latency headroom.
  • Sentinel failover has been tested, not merely configured.
  • All application nodes can read and write the same media namespace.
  • Web and streaming health checks return HTTP 200 with OK.
  • Media-cache and archive retention jobs run through the scheduler and have storage alerts.
  • Backups cover PostgreSQL and object storage, with a tested restore path.

What a good scaling decision looks like

A sound change connects a measured symptom to one tier, one resource and one rollback. For example, rising push-queue latency with spare web capacity points to Sidekiq queue capacity, not more Puma workers. Near-limit PostgreSQL connections point to connection pooling or a reduced process budget, not blindly adding nodes. Growing local media disks point to shared object storage and retention policy, not a larger boot disk alone.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use the smallest architectural change that removes the observed constraint, then measure again. When the constraint moves from an application tier to PostgreSQL or Redis, stop increasing application concurrency and redesign the shared dependency. This feedback loop is more dependable than estimating capacity from a user-count headline.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.