optimism

Enhanced DA Throttling Mechanisms

The op-batcher includes sophisticated throttling mechanisms to manage data availability (DA) backlogs and prevent excessive costs during high-load periods. These mechanisms dynamically adjust block building constraints based on current DA load.

Overview

Data availability throttling addresses situations where transaction volume exceeds the DA layer’s throughput capacity. Without throttling, this can lead to:

The throttling system prevents these issues by instructing sequencers to limit block data production when backlogs exceed configured thresholds.

Throttling Controller Types

The batcher supports four throttling strategies, each with different response characteristics. The strategies can be understood in this diagram: Throttling Strategies

NOTE Be aware that using 0 for either throttle.block-size-lower-limit and throttle.tx-size-lower-limit results in no throttling limits being applied (for blocks and transactions respectively).

Step Controller (Default)

Behavior: Binary on/off throttling

[!WARNING] If selecting the step controller, you should not rely on default throttling parameters as this could cause too much throttling to be applied too quickly.

Linear Controller

Behavior: Linear scaling throttling intensity

Quadratic Controller

Behavior: Quadratic scaling throttling intensity

PID Controller (⚠️ EXPERIMENTAL)

What a PID Controller is

PID Controller is a control mechanism that automatically adjusts the batcher’s throttling intensity output to maintain a desired load.

Behavior: Proportional-Integral-Derivative control

⚠️ EXPERIMENTAL FEATURE WARNING

The PID controller is experimental and should only be used by users with deep understanding of control theory. Improper configuration can lead to system instability, oscillations, or poor performance. Use at your own risk and only with extensive testing.

Runtime Management via RPC

The batcher exposes admin RPC endpoints for dynamic throttling control without restarts:

Get Controller Status

curl -X POST -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","method":"admin_getThrottleController","params":[],"id":1}' \
  http://localhost:8545

Response:

{
  "jsonrpc": "2.0",
  "result": {
    "type": "quadratic",
    "threshold": 1000000,
    "current_load": 750000,
    "intensity": 0.25,
    "max_tx_size": 128000,
    "max_block_size": 1500000
  },
  "id": 1
}

Switch Controller Type

Step Controller:

curl -X POST -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","method":"admin_setThrottleController","params":["step", null],"id":1}' \
  http://localhost:8545

Linear Controller:

curl -X POST -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","method":"admin_setThrottleController","params":["linear", null],"id":1}' \
  http://localhost:8545

Quadratic Controller:

curl -X POST -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","method":"admin_setThrottleController","params":["quadratic", null],"id":1}' \
  http://localhost:8545

PID Controller:

curl -X POST -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","method":"admin_setThrottleController","params":["pid", {"kp": 0.3, "ki": 0.15, "kd": 0.08, "integral_max": 50.0, "output_max": 1.0, "sample_time": "5s"}],"id":1}' \
  http://localhost:8545

Reset Controller State

curl -X POST -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","method":"admin_resetThrottleController","params":[],"id":1}' \
  http://localhost:8545

PID Controller Configuration

Parameters

The PID controller uses six key parameters:

Core PID Parameters:

Protection Parameters:

Predefined Profiles

⚠️ EXPERIMENTAL: These profiles are starting points only. Proper tuning requires understanding your specific system characteristics and extensive testing.

Gentle Throttling (Conservative, stable):

{
  "kp": 0.1,
  "ki": 0.05,
  "kd": 0.02,
  "integral_max": 1000.0,
  "output_max": 1.0,
  "sample_time": "10s"
}

Balanced Throttling (Recommended default):

{
  "kp": 0.3,
  "ki": 0.15,
  "kd": 0.08,
  "integral_max": 1000.0,
  "output_max": 1.0,
  "sample_time": "2s"
}

Aggressive Throttling (Fast response, may overshoot):

{
  "kp": 0.8,
  "ki": 0.4,
  "kd": 0.2,
  "integral_max": 2000.0,
  "output_max": 1.0,
  "sample_time": "2s"
}

Tuning Guidelines

⚠️ WARNING: PID tuning requires expertise. Improper tuning can cause instability.

  1. Start Conservative: Begin with gentle settings and gradually increase responsiveness
  2. Tune One Parameter at a Time: Change kp first, then ki, then kd
  3. Monitor System Response: Watch for oscillations, overshoot, and stability
  4. Test Under Load: Validate behavior under various load conditions
  5. Have Rollback Plan: Be prepared to switch back to step/linear controllers

Basic Tuning Process:

  1. Set ki=0, kd=0, start with small kp (0.1)
  2. Increase kp until system responds adequately without overshoot
  3. Add small ki (0.05) to eliminate steady-state error
  4. Add small kd (0.02) to improve transient response
  5. Adjust integral_max to prevent windup
  6. Fine-tune based on observed behavior

Throttling Operation

How It Works

  1. Monitoring: Batcher continuously monitors pending DA bytes in its queue
  2. Threshold Checking: Compares current load against configured threshold
  3. Intensity Calculation: Controller calculates throttling intensity (0.0 to 1.0)
  4. Parameter Mapping: Intensity maps to specific tx/block size limits
  5. Endpoint Updates: Sends miner_setMaxDASize RPC calls to configured endpoints
  6. Enforcement: Sequencers/builders enforce the limits during block construction

Endpoint Communication

The throttling system communicates with multiple endpoints in parallel:

Each endpoint runs in its own goroutine with:

Metrics and Monitoring

The batcher exposes Prometheus metrics for throttling monitoring:

Best Practices

Controller Selection

Use Step Controller when:

Use Linear Controller when:

Use Quadratic Controller when:

Use PID Controller when:

General Recommendations

  1. Start Simple: Begin with step or linear controllers
  2. Monitor Closely: Watch metrics and system behavior
  3. Test Thoroughly: Validate under various load conditions
  4. Plan for Failure: Have fallback controllers configured
  5. Document Changes: Record configuration changes and their effects
  6. Regular Review: Periodically assess controller performance

Common Pitfalls

Troubleshooting

Common Issues

Controller Not Responding:

Oscillating Behavior (PID):

Slow Response:

High Error Rates:

Diagnostic Commands

Check controller status:

curl -s -X POST -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","method":"admin_getThrottleController","params":[],"id":1}' \
  http://localhost:8545 | jq

Reset and start fresh:

curl -X POST -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","method":"admin_resetThrottleController","params":[],"id":1}' \
  http://localhost:8545

Switch to safe mode (step controller):

curl -X POST -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","method":"admin_setThrottleController","params":["step", null],"id":1}' \
  http://localhost:8545