BF BotFoundry
BotFoundry / 8 Bot Blueprints / discord-sharded-music-bot
BOTFOUNDRY DISCORD RUNBOOK • JAVA 21 ZGC & CACHE SWEEPERS

BotFoundry Discord Sharded Bot & Lavalink v4 Java 21 ZGC Sizing Runbook

Crossing 2,500 Discord guilds mandates WebSocket Gateway sharding, while Lavalink v4 must pace 20 ms UDP Opus audio packets without stop-the-world JVM garbage collection hiccups. On BotFoundry, we pre-touch fixed -Xms/-Xmx heaps under Java 21 Generational ZGC and cap Discord.js guild caches.

Inspect Vultr Specs for DISCORD-ZGC via BotFoundry → Compare Hostinger Tiers via BotFoundry → Load Preset in BotFoundry RAM Sizer →

BotFoundry Deterministic vCPU, RAM & Guard Matrix (BP-06 // DISCORD-ZGC)

Public rates retrieved 2026-11-12 from official vendor pricing pages cited below; promotional & renewal prices may change — always verify exact specs, term length, and renewal rates on the vendor’s official checkout page.

Concurrency Scale vCPU DDR5 RAM OS / Runtime /dev/shm & Watchdog Guard Public Tier Match (2026-11-12)
1–2 Shards + 15 Audio Streams 2 vCPU KVM 4 GB DDR5 Ubuntu 24.04 + Java 21 ZGC -Xmx2G + RestartSec=3 Hostinger KVM 1 / Vultr HF 4GB
4–8 Shards + 60 Audio Streams 4 vCPU 3.5GHz+ HF 8 GB DDR5 Ubuntu 24.04 ZGC ZGC -Xmx4G + AlwaysPreTouch Vultr HF 8GB / Hostinger KVM 2
16–32 Shards + 200 Streams 6–8 Dedicated VDS 16 GB DDR5 Ubuntu 24.04 + Redis ZGC -Xmx8G + Swappiness=1 UltaHost VDS 16GB / Hostinger KVM 4
64+ Shards + Multi-Region Audio 12 Core Ryzen / VDS 32–64 GB DDR5 Clustered Lavalink Nodes IPv6 /64 Planner + VDS InterServer Ryzen / UltaHost VDS 32GB

BotFoundry Unattended Supervisor Snippet (BP-06 // DISCORD-ZGC)

BotFoundry systemd Restart=always supervisor and Java 21 Generational ZGC heap layout for Lavalink v4
BotFoundry systemd Restart=always supervisor and Java 21 Generational ZGC heap layout for Lavalink v4
systemd — BotFoundry Lavalink v4 Unit with Java 21 Generational ZGC & Pre-Touched Heap
[Service]
User=lavalink
WorkingDirectory=/opt/lavalink
ExecStart=/usr/bin/java \
  -Xms4G -Xmx4G \
  -XX:+UseZGC -XX:+ZGenerational \
  -XX:+AlwaysPreTouch \
  -Djdk.nio.maxCachedBufferSize=262144 \
  -jar Lavalink.jar
MemoryMax=5G
Restart=always
RestartSec=3
  1. 1. Eliminating Opus UDP Stutter with Java 21 Generational ZGC on BotFoundry

    Legacy G1GC stop-the-world pauses can spike past 25–40 ms when dozens of voice channels skip tracks simultaneously, interrupting 20 ms Opus frame pacing. Enabling -XX:+UseZGC -XX:+ZGenerational with matching -Xms4G -Xmx4G and -XX:+AlwaysPreTouch keeps GC pauses sub-millisecond.

  2. 2. Splitting US-East Gateway Shards from Regional Lavalink Nodes in BotFoundry Designs

    Because Discord’s primary Gateway API operates in US-East, placing your Shard Manager in New Jersey/New York ensures fast 3-second Slash Command acknowledgments, while optional regional Lavalink satellites in Singapore or Frankfurt serve local voice channels.

  3. 3. Pruning Discord.js MessageManager & Presence Caches Saves 70% V8 Heap on BotFoundry

    Storing unlimited member presences and message histories across 10,000 guilds leaks 10+ GB of Node.js heap; enforce Options.cacheWithLimits() and omit GUILD_PRESENCES unless strictly required.

BotFoundry Troubleshooting & Sizing FAQ (BP-06 // DISCORD-ZGC)

How many concurrent Lavalink v4 streams does BotFoundry budget per vCPU thread?

With direct Opus frame passthrough (no heavy real-time DSP equalization), 1 high-clock vCPU handles ~25–35 active streams; with real-time karaoke/timescale DSP filters active, budget 8–12 streams per vCPU.

How do BotFoundry setups mitigate HTTP 429 audio source rate limits on VPS IPs?

Attach a routed IPv6 /64 subnet (available on Vultr and InterServer) with Lavalink’s RotatingNanoIpRoutePlanner so outbound requests cycle cleanly across addresses.

Why does BotFoundry set MemoryMax=5G above -Xmx4G in the Lavalink systemd unit?

JVM processes consume native off-heap memory for thread stacks, Netty NIO direct buffers, and native Opus C libraries on top of the 4 GB Java heap — leaving a 1 GB off-heap margin prevents premature cgroup OOM kills.

Related BotFoundry Unattended Sizing Blueprints

Vultr (BP-06 BotFoundry) From $6.00/mo
Inspect Specs on BotFoundry →