Skip to main content

Failover and High Availability

Gate provides comprehensive failover mechanisms at multiple levels to ensure your Minecraft network remains available even during infrastructure failures, maintenance, or unexpected issues.

Failover Architecture

Gate implements failover at three distinct layers:

Layer 1: Frontend Gate Instance Failover

Ensure continuous proxy availability when individual Gate instances fail.

Method 1: Multiple Gate Instances with Connect

The simplest approach uses Gate Connect’s built-in redundancy:
config.yml (All instances)
Setup:
1

Deploy First Gate Instance

Configure and start the first Gate instance with Connect enabled.
2

Copy Connect Token

Copy the generated connect.json file to your other instances.
3

Deploy Additional Instances

Start additional Gate instances with the same endpoint name and token.
4

Verify Registration

Check logs to confirm all instances successfully registered:
Failover Behavior:
  • Automatic health checking by Connect network
  • Failed instances removed from rotation instantly
  • No player-facing downtime
  • Automatic recovery when instance comes back online
Benefits:
  • Zero configuration failover
  • No external load balancer required
  • Works anywhere (home servers, cloud, containers)
  • Built-in health monitoring

Method 2: Kubernetes with Replica Sets

For cloud-native deployments, leverage Kubernetes’ self-healing:
gate-deployment.yaml
Key Features:

Replica Sets

replicas: 3 ensures three instances always running. Kubernetes automatically recreates failed pods.

Health Probes

Liveness and readiness probes detect unhealthy instances and remove them from service.

Rolling Updates

Zero-downtime deployments with maxUnavailable: 1 ensuring continuous availability.

Session Affinity

sessionAffinity: ClientIP keeps players connected to the same instance across reconnects.
Failover Timeline:

Method 3: HAProxy with Health Checks

For traditional infrastructure, configure HAProxy for automatic failover:
haproxy.cfg
Health Check Parameters:
  • inter 2s - Check every 2 seconds
  • fall 3 - Mark down after 3 failed checks (6 seconds)
  • rise 2 - Mark up after 2 successful checks (4 seconds)
  • on-marked-down shutdown-sessions - Gracefully close connections when backend fails
Failover Behavior:

Layer 2: Backend Server Failover

Gate automatically handles backend server failures and reconnects players to available servers.

Try List Configuration

The try list defines the server order Gate attempts when connecting players:
config.yml
Behavior on Login:
1

Player Joins

Gate receives player connection.
2

Try Primary Server

Gate attempts connection to lobby-primary.
3

Failover on Failure

If lobby-primary is offline, Gate automatically tries lobby-backup.
4

Continue Down List

If lobby-backup also fails, Gate tries survival, then creative.
5

Final Failure

If all servers fail, player is disconnected with a message.

Automatic Reconnection on Disconnect

Gate can automatically reconnect players when they’re kicked from a server:
config.yml
Failover Triggers: Triggers Failover:
  • Server crashes (connection lost)
  • Server becomes unreachable (network failure)
  • Server sends disconnect without reason
  • Server times out
Does NOT Trigger Failover:
  • Server kicks player with explicit reason (“You are banned”)
  • Player uses /server command
  • Server shutdown with proper kick message
Example Scenario:
Important: Set failoverOnUnexpectedServerDisconnect: true carefully. If a server legitimately kicks players (e.g., for rule violations), failover will circumvent the kick by reconnecting them to another server.

Lite Mode Backend Failover

In Lite mode, Gate tries backends in order automatically:
config.yml
Failover Flow: Benefits:
  • Automatic backend health checking
  • Instant failover on connection failure
  • Custom fallback messages when all backends down
  • Works for both player connections and status pings

Layer 3: Connection-Level Failover

Gate handles individual connection failures gracefully.

Connection Timeouts

Configure aggressive timeouts for fast failure detection:
config.yml
Recommendations: Behavior:

Rate Limiting and Protection

Protect against connection floods that could prevent legitimate failover:
config.yml
Benefits:
  • Prevents connection exhaustion during failures
  • Ensures resources available for failover operations
  • Protects against DoS attacks during incidents

High-Availability Deployment Patterns

Multiple Gate instances actively serving traffic:
Characteristics:
  • All instances actively handling connections
  • Load distributed evenly
  • Maximum resource utilization
  • Survives n-1 failures (can lose any single instance)
Benefits:
  • No idle resources
  • Better performance under normal load
  • Graceful degradation (performance decreases gradually)

Pattern 2: Active-Passive (Cost-Optimized)

Primary instance serves traffic, backup stands ready:
HAProxy Configuration:
Characteristics:
  • Backup only receives traffic when primary fails
  • Lower resource costs (backup can be smaller)
  • Slower failover (backup needs to handle full load suddenly)
Use Cases:
  • Cost-sensitive deployments
  • Predictable traffic patterns
  • Development/staging environments

Pattern 3: Multi-Region (Geo-Distributed)

Gate instances across multiple geographic regions:
Lite Mode Configuration:
config.yml
Benefits:
  • Survives entire region failures
  • Lower latency for global players
  • Compliance with data residency requirements
Challenges:
  • More complex configuration
  • Higher operational costs
  • Cross-region data synchronization

Disaster Recovery

Backup and Restore Procedures

1

Backup Gate Configuration

2

Store Backups Securely

3

Test Restore Procedure

Regularly test restoration in a staging environment:
4

Automate with Cron

Recovery Time Objectives (RTO)

Set and measure recovery objectives:

Monitoring and Alerting

Critical Metrics to Monitor

Gate Instance Health

  • Process uptime
  • Memory usage
  • CPU utilization
  • Connection count

Backend Server Status

  • Reachability (ping/status)
  • Response time
  • Player count
  • Failed connection attempts

Failover Events

  • Failover frequency
  • Recovery time
  • Affected players
  • Root cause (if known)

Player Experience

  • Login success rate
  • Connection errors
  • Unexpected disconnects
  • Average connection time

Example Monitoring with Prometheus

If Gate exposes metrics (via HTTP API or custom exporter):
prometheus-alerts.yml

Log-Based Monitoring

Monitor Gate logs for failover events:

Testing Failover

Regularly test failover mechanisms to ensure they work when needed:

Test 1: Backend Server Failover

1

Simulate Backend Failure

2

Verify Failover

  • Attempt player connection
  • Confirm connection to backup server
  • Check Gate logs for failover messages
3

Restore Primary

4

Verify Recovery

  • Confirm primary server in rotation
  • New connections use primary

Test 2: Gate Instance Failover

1

Simulate Gate Failure

2

Verify Load Balancer Failover

  • Monitor load balancer logs
  • Confirm traffic routed to healthy instances
  • Test new player connections
3

Measure Recovery Time

  • Time from failure to instance replacement
  • Time from failure to full traffic recovery

Test 3: Chaos Engineering

Use chaos engineering tools for comprehensive testing:

Best Practices

Defense in Depth

Implement failover at multiple layers (frontend, Gate, backend) for maximum resilience.

Test Regularly

Schedule monthly failover drills to verify mechanisms work correctly.

Monitor Continuously

Set up alerts for failures and track failover events over time.

Document Procedures

Maintain runbooks for common failure scenarios and recovery procedures.

Automate Recovery

Use orchestration tools (Kubernetes, Systemd) for automatic instance recovery.

Optimize Timeouts

Balance fast failover with avoiding false positives from temporary issues.

Troubleshooting

Expected Behavior: Players connected to failed instance will disconnect.Mitigation:
  • Use failoverOnUnexpectedServerDisconnect: true for automatic backend failover
  • Implement session affinity on frontend load balancer
  • Use multiple Gate instances to minimize impact radius
Possible Causes:
  • All backends unhealthy but health checks inconsistent
  • Timeout values too aggressive
  • Network issues causing intermittent failures
Solutions:
  • Increase connectionTimeout and health check intervals
  • Implement exponential backoff for failed backends
  • Fix underlying network/server issues
Check:
  • Backup server configured correctly in try list or as HAProxy backup
  • Primary server is actually failing (not just slow)
  • Health checks detecting primary failure properly
Debug:
Possible Causes:
  • Long timeout values
  • Slow health check intervals
  • Resource exhaustion (CPU/memory)
Solutions:
  • Reduce connectionTimeout to 2-5 seconds
  • Increase health check frequency
  • Scale up instance resources

Load Balancing

Configure load balancing strategies for optimal distribution

Gate Connect

Use Connect for automatic failover and load balancing

Kubernetes Deployment

Deploy Gate on Kubernetes with built-in self-healing

Configuration Reference

Complete configuration options documentation