> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wasabihosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SCP:SL Server Optimization Guide

> Optimize your SCP: Secret Laboratory server for best performance

# SCP:SL Server Optimization

This guide provides comprehensive optimization strategies for your SCP: Secret Laboratory server to ensure smooth gameplay and optimal performance.

## Performance Baseline

Before optimizing, establish performance baselines:

<Accordion title="Key Performance Metrics">
  | Metric              | Good       | Acceptable | Poor         |
  | ------------------- | ---------- | ---------- | ------------ |
  | **Tick Rate**       | 60 TPS     | 50-59 TPS  | Below 50 TPS |
  | **Server FPS**      | 60+ FPS    | 45-60 FPS  | Below 45 FPS |
  | **RAM Usage**       | Under 2GB  | 2-3GB      | Over 3GB     |
  | **CPU Usage**       | Under 40%  | 40-70%     | Over 70%     |
  | **Network Latency** | Under 50ms | 50-100ms   | Over 100ms   |
</Accordion>

<Info>
  Monitor these metrics through your Wasabi Hosting Gamepanel dashboard or server console.
</Info>

## Configuration Optimization

### Gameplay Configuration

Optimize `config_gameplay.txt` for better performance:

```yaml theme={null}
# Optimized Gameplay Settings

# Reduce item spawn rates for better performance
item_spawn_multiplier: 0.9

# Faster item cleanup
dropped_item_despawn_time: 120
item_despawn_time: 240

# Ragdoll cleanup
ragdoll_cleanup_time: 8
max_ragdolls: 20

# Efficient respawn timing
respawn_time_minimum: 15
respawn_time_maximum: 20

# Decontamination (reduces entity count in LCZ)
decontamination_time: 690

# Warhead timing (ends rounds before performance degrades)
warhead_auto_detonate_time: 900
```

<Tip>
  Lower `item_spawn_multiplier` and faster despawn times significantly reduce entity count, improving server performance.
</Tip>

### Network Optimization

Configure network settings in `config.txt`:

```yaml theme={null}
# Network Performance Settings
tick_rate: 60
send_rate: 60
max_snapshot_entities: 128

# Connection Settings
timeout_time: 60
max_ping: 500
kick_on_timeout: true

# Bandwidth Management
network_compression: true
max_packet_size: 1024
interpolation: 0.1
```

### Server Process Optimization

Optimize startup parameters:

```bash theme={null}
# Recommended Startup Parameters
-port 7777 \
-maxplayers 20 \
-nographics \
-batchmode \
-nodedicateddelete \
-logFile logs/server.log \
-high
```

<Accordion title="Parameter Explanations">
  | Parameter        | Purpose                       | Performance Impact                     |
  | ---------------- | ----------------------------- | -------------------------------------- |
  | `-nographics`    | Disables graphics rendering   | High - Essential for dedicated servers |
  | `-batchmode`     | Runs without user interaction | Medium - Reduces overhead              |
  | `-high`          | Sets process priority to high | Medium - Better CPU allocation         |
  | `-logFile`       | Custom log location           | Low - Better log management            |
  | `-maxplayers 20` | Limits player count           | Variable - Scale based on hardware     |
</Accordion>

## System-Level Optimization

### Memory Management

```yaml theme={null}
# Memory Optimization Settings

# Garbage Collection
gc_mode: incremental
gc_interval: 300

# Memory Limits
max_memory: 2048  # MB
memory_cleanup_threshold: 1536  # MB

# Object Pool Settings
enable_object_pooling: true
pool_size_weapons: 50
pool_size_items: 100
pool_size_projectiles: 200
```

<Warning>
  Setting memory limits too low can cause crashes. Ensure at least 2GB is allocated for optimal performance.
</Warning>

### CPU Optimization

Distribute load across CPU cores:

```yaml theme={null}
# Multi-threading Settings
enable_multithreading: true
worker_threads: 4
physics_thread_count: 2

# CPU Priority
process_priority: high
affinity_mask: auto  # Let the OS handle core allocation
```

## Plugin Optimization

### EXILED Plugin Framework

Optimize EXILED configuration:

```yaml theme={null}
# EXILED Optimization (~/.config/EXILED/Configs/exiled.yml)
debug: false
environment: production

# Performance Settings
max_event_handlers: 100
event_handler_timeout: 5000

# Logging (reduce for better performance)
log_level: Info
log_events: false
detailed_errors: false
```

### Plugin Best Practices

<Accordion title="Choosing Efficient Plugins">
  **Performance-Friendly Plugins:**

  * Well-maintained and regularly updated
  * Minimal event subscriptions
  * Efficient database queries
  * Proper error handling
  * Asynchronous operations where possible

  **Avoid:**

  * Abandoned or outdated plugins
  * Plugins that hook into every game event
  * Poorly coded plugins with memory leaks
  * Redundant plugins providing similar features
</Accordion>

## Database Optimization

If using plugins with database functionality:

```yaml theme={null}
# MySQL Optimization
database:
  # Connection Pooling
  min_pool_size: 2
  max_pool_size: 10
  connection_timeout: 15

  # Query Optimization
  use_prepared_statements: true
  enable_query_cache: true
  cache_size: 256  # MB

  # Performance
  batch_size: 100
  async_operations: true
```

<Tip>
  Use connection pooling to reuse database connections and reduce overhead.
</Tip>

## Entity Management

### Item and Ragdoll Cleanup

```yaml theme={null}
# Entity Cleanup Configuration

# Automatic Cleanup
enable_auto_cleanup: true
cleanup_interval: 60  # seconds

# Item Management
max_items_per_room: 30
item_despawn_time: 180
dropped_item_despawn_time: 120

# Ragdoll Management
ragdoll_cleanup_time: 10
max_ragdolls: 20
cleanup_ragdolls_on_round_end: true

# Projectile Management
projectile_lifetime: 30
max_active_projectiles: 50
```

### Door and Elevator Optimization

```yaml theme={null}
# Door Settings
door_update_rate: 10  # Updates per second
door_close_time: 5

# Elevator Settings
elevator_movement_speed: 5.0
elevator_wait_time: 3
```

## Round Optimization

### Efficient Round Settings

```yaml theme={null}
# Round Configuration for Performance

# Quick Round Start
lobby_waiting_time: 20
round_start_countdown: 10

# Auto-Restart
auto_round_restart: true
auto_round_restart_time: 5

# Round Duration
warhead_auto_detonate_time: 900  # 15 minutes
max_round_time: 1200  # 20 minutes

# Respawn Optimization
respawn_time_minimum: 15
respawn_time_maximum: 20
max_respawn_amount: 15
```

<Info>
  Shorter rounds prevent performance degradation from entity buildup and keep the server fresh.
</Info>

## Network and Bandwidth Optimization

### Connection Settings

```yaml theme={null}
# Network Optimization

# Rate Settings
tick_rate: 60
send_rate: 60
receive_rate: 60

# Bandwidth
max_rate: 100000
min_rate: 10000

# Compression
enable_compression: true
compression_level: 6  # Balance between CPU and bandwidth

# Anti-DDoS
rate_limit_enabled: true
max_connections_per_ip: 2
connection_throttle: 1000  # ms between connections
```

### Port Configuration

```yaml theme={null}
# Efficient Port Setup
server_port: 7777
query_port: 7777
max_simultaneous_queries: 50
```

## Performance Monitoring

### Logging Configuration

Balance between information and performance:

```yaml theme={null}
# Optimized Logging

# Log Levels
log_level: Warning  # Only log warnings and errors
debug_logging: false

# Log Rotation
log_rotation: daily
max_log_files: 7
compress_old_logs: true

# Specific Logging
log_player_connections: true
log_admin_commands: true
log_performance_warnings: true
log_every_action: false  # Disable verbose logging
```

### Performance Alerts

Configure alerts for performance issues:

```yaml theme={null}
# Performance Monitoring

# Thresholds
cpu_usage_alert: 80
memory_usage_alert: 85
tick_rate_alert: 45
lag_spike_threshold: 100  # ms

# Alert Actions
alert_admins: true
auto_cleanup_on_lag: true
emergency_restart_threshold: 90  # % CPU
```

## Player Count Optimization

### Scaling by Player Count

<Tabs>
  <Tab title="Small (8-12 players)">
    ```yaml theme={null}
    # Optimized for 8-12 players
    max_players: 12
    max_items_spawn: 80
    max_ragdolls: 15
    item_spawn_multiplier: 0.8

    # Can afford higher quality
    tick_rate: 60
    send_rate: 60
    ```
  </Tab>

  <Tab title="Medium (12-20 players)">
    ```yaml theme={null}
    # Optimized for 12-20 players
    max_players: 20
    max_items_spawn: 96
    max_ragdolls: 20
    item_spawn_multiplier: 0.9

    # Balanced settings
    tick_rate: 60
    send_rate: 60
    ```
  </Tab>

  <Tab title="Large (20-30 players)">
    ```yaml theme={null}
    # Optimized for 20-30 players
    max_players: 30
    max_items_spawn: 120
    max_ragdolls: 25
    item_spawn_multiplier: 1.0

    # May need to reduce quality
    tick_rate: 50
    send_rate: 50

    # More aggressive cleanup
    dropped_item_despawn_time: 90
    ragdoll_cleanup_time: 8
    ```
  </Tab>
</Tabs>

## Anti-Cheat Optimization

Balance security and performance:

```yaml theme={null}
# Anti-Cheat Settings

# Enable Essential Checks
enable_anticheat: true
check_player_speed: true
check_noclip: true
check_item_spawn: true

# Reduce Check Frequency (better performance)
anticheat_check_interval: 5  # seconds
anticheat_tolerance: 0.7

# Disable Expensive Checks (if low on resources)
check_every_packet: false
deep_packet_inspection: false
```

## Advanced Optimization Techniques

### Object Pooling

```yaml theme={null}
# Object Pooling Configuration

# Enable Pooling
enable_object_pooling: true

# Pool Sizes
pool_bullets: 500
pool_grenades: 50
pool_items: 200
pool_effects: 100

# Pool Behavior
prewarm_pools: true
dynamic_pool_sizing: true
max_pool_growth: 2.0
```

### Async Operations

```yaml theme={null}
# Asynchronous Processing

# Enable Async
enable_async_physics: true
enable_async_pathfinding: true
enable_async_loading: true

# Threading
max_background_threads: 4
background_thread_priority: low
```

### Caching

```yaml theme={null}
# Caching Configuration

# Enable Caches
enable_player_cache: true
enable_room_cache: true
enable_spawn_cache: true

# Cache Settings
cache_lifetime: 300  # seconds
max_cache_size: 512  # MB
cache_cleanup_interval: 60
```

## Hardware Recommendations

<Accordion title="Recommended Specifications by Player Count">
  | Player Count | CPU               | RAM | Network |
  | ------------ | ----------------- | --- | ------- |
  | **8-12**     | 2 cores @ 3.0GHz+ | 2GB | 10 Mbps |
  | **12-20**    | 4 cores @ 3.5GHz+ | 4GB | 25 Mbps |
  | **20-30**    | 6 cores @ 4.0GHz+ | 6GB | 50 Mbps |

  <Info>
    These are minimum recommendations. More resources will always improve performance.
  </Info>
</Accordion>

## Optimization Checklist

Use this checklist to optimize your server:

* [ ] Configure optimal player count for your hardware
* [ ] Enable item and ragdoll cleanup
* [ ] Set appropriate despawn times
* [ ] Configure network compression
* [ ] Optimize tick rate based on player count
* [ ] Remove unnecessary plugins
* [ ] Enable object pooling
* [ ] Configure efficient logging
* [ ] Set up automatic round restart
* [ ] Enable warhead auto-detonation
* [ ] Configure database connection pooling (if applicable)
* [ ] Set process priority to high
* [ ] Monitor performance metrics regularly
* [ ] Keep server and plugins updated

## Troubleshooting Performance Issues

<Accordion title="High CPU Usage">
  **Common Causes:**

  * Too many plugins running intensive operations
  * Large player count exceeding server capacity
  * Memory leaks in plugins
  * Inefficient event handlers

  **Solutions:**

  * Reduce max player count
  * Disable non-essential plugins
  * Lower tick rate to 50 or 45
  * Enable more aggressive cleanup
  * Update or remove problematic plugins
</Accordion>

<Accordion title="Memory Leaks">
  **Common Causes:**

  * Poorly coded plugins not releasing objects
  * Excessive ragdoll/item accumulation
  * Large log files

  **Solutions:**

  * Enable automatic cleanup
  * Reduce entity spawn rates
  * Restart server regularly (daily recommended)
  * Update plugins to latest versions
  * Enable log rotation and compression
</Accordion>

<Accordion title="Network Lag">
  **Common Causes:**

  * Insufficient bandwidth
  * DDoS attacks
  * Too many simultaneous connections
  * Large packet sizes

  **Solutions:**

  * Enable network compression
  * Implement rate limiting
  * Configure anti-DDoS protection (use Firewall Manager)
  * Reduce send/receive rates if needed
  * Limit connections per IP
</Accordion>

<Accordion title="Low Tick Rate">
  **Common Causes:**

  * Server overloaded
  * Blocking operations in game thread
  * Insufficient CPU resources
  * Too many entities

  **Solutions:**

  * Reduce player count
  * Enable async operations
  * Increase cleanup frequency
  * Remove CPU-intensive plugins
  * Lower visual quality settings
</Accordion>

## Maintenance Schedule

Regular maintenance ensures optimal performance:

**Daily:**

* Monitor performance metrics
* Check error logs
* Verify tick rate stability

**Weekly:**

* Review plugin performance
* Clean up old logs
* Update critical plugins
* Analyze player feedback

**Monthly:**

* Full server restart
* Plugin audit (remove unused)
* Configuration review
* Performance benchmark tests
* Server and plugin updates

<Tip>
  Schedule restarts during off-peak hours to minimize player disruption.
</Tip>

## Performance Testing

Test optimization changes:

<Steps>
  <Step title="Establish baseline">
    Record current performance metrics before changes
  </Step>

  <Step title="Apply single change">
    Make one optimization change at a time
  </Step>

  <Step title="Monitor for 24 hours">
    Observe performance over a full day cycle
  </Step>

  <Step title="Compare metrics">
    Compare new metrics to baseline
  </Step>

  <Step title="Keep or revert">
    Keep change if improved, revert if worse
  </Step>
</Steps>

By following these optimization guidelines, your SCP: Secret Laboratory server on Wasabi Hosting will deliver excellent performance and a smooth gameplay experience for your players.

<Card title="Get your own SCP: Secret Laboratory server" icon="rocket" href="https://wasabihosting.com/game-servers/scp-sl">
  Deploy a DDoS-protected SCP: Secret Laboratory server on AMD Ryzen hardware in about two minutes, and plans start at €8.00/month.
</Card>
