인덱서 런타임 및 성능
적절한 구성과 리소스 모니터링은 가능한 가장 성능 좋은 custom indexer를 제공한다. 예를 들면:
-
수집, 데이터베이스 connections, pipeline 선택을 위한 런타임 구성 옵션과
tokio_console같은 디버깅 도구의 목적 있는 사용은 indexer 성능을 세밀하게 조정하는 데 도움이 된다. -
테이블에 대한 효율적인 데이터 pruning을 목표로 한 합리적인 전략은 시간이 지나도 성능을 유지하게 한다.
-
Prometheus metrics를 노출하고 확장하는 best practices를 따르면 indexer 성능을 추적하는 데 도움이 된다.
이 기법들을 함께 사용하면 개발과 프로덕션 모두에서 빠르고, 리소스 효율적이며, 모니터링하기 쉬운 indexers를 운영할 수 있다.
구성 fine-tuning
인덱싱 프레임워크는 서로 다른 사용 사례의 성능을 최적화하기 위한 여러 수준의 구성을 제공한다. 이 섹션은 기본 구성 옵션을 다루며, 더 복잡한 pipeline별 튜닝은 인덱서 파이프라인 아키텍처에서 다룬다.
ingestion layer 구성
checkpoint 데이터가 어떻게 가져와지고 분배되는지 제어한다:
use sui_indexer_alt_framework::config::ConcurrencyConfig;
let ingestion_config = IngestionConfig {
// Buffer size across all downstream workers (default: 5000)
checkpoint_buffer_size: 10000,
// Concurrency for checkpoint fetches.
// Adaptive by default: starts at 1 and scales up to 500 based on
// downstream channel pressure.
ingest_concurrency: ConcurrencyConfig::Adaptive {
initial: 1,
min: 1,
max: 500,
},
// Or use fixed concurrency:
// ingest_concurrency: ConcurrencyConfig::Fixed { value: 200 },
// Retry interval for missing checkpoints in ms (default: 200)
retry_interval_ms: 100,
// gRPC streaming configuration (applies when --streaming-url is provided)
// Initial batch size after streaming connection failure (default: 10)
streaming_backoff_initial_batch_size: 20,
// Maximum batch size after repeated streaming failures (default: 10000)
streaming_backoff_max_batch_size: 20000,
// Timeout for streaming connection in ms (default: 5000)
streaming_connection_timeout_ms: 10000,
// Timeout for streaming operations (peek/next) in ms (default: 5000)
streaming_statement_timeout_ms: 10000,
};
Tuning guidelines:
checkpoint_buffer_size: 높은 처리량 시나리오에서는 늘리고 메모리 사용량을 줄이려면 낮춘다.ingest_concurrency: 동시에 실행되는 checkpoint fetch 수를 제어한다. 기본적으로 이는 adaptive이며 1에서 시작해 downstream broadcast channel이 얼마나 차 있는지에 따라 최대 500까지 확장된다. 컨트롤러는 진동을 피하기 위해 dead band(채움률 60%–85%)를 사용하며 channel이 빠르게 비워질 때는 concurrency를 늘리고 적체될 때는 줄인다. 정적 한도를 위해ConcurrencyConfig::Fixed로 재정의하거나 adaptive bounds를 커스터마이즈할 수 있다. Adaptive controller는 채움 비율 임곗값을 재정의하기 위한dead_bandparameter도 노출하지만 기본값은 대부분의 워크로드에서 잘 동작한다.retry_interval_ms: 값이 낮을수 록 실시간 데이터의 지연 시간이 줄고 값이 높을수록 불필요한 재시도가 줄어든다.streaming_backoff_initial_batch_size: 초기 스트리밍 실패 후 polling을 통해 처리할 checkpoints 수이다. 값이 낮을수록 스트리밍 복구가 빨라지고 값이 높을수록 연결 시도가 줄어든다.streaming_backoff_max_batch_size: 반복 실패 후 polling을 통해 처리할 최대 checkpoints 수이다. 배치 크기는 초기 크기에서 이 최대값까지 지수적으로 증가한다. 값이 높을수록 장시간 장애 동안 연결 시도가 줄어든다.streaming_connection_timeout_ms: 스트리밍 연결 수립을 기다리는 시간이다. 네트워크가 느릴수록 값을 늘린다.streaming_statement_timeout_ms: 스트리밍 데이터 작업(peek/next)을 기다리는 시간이다. checkpoints가 크거나 네트워크가 느리면 값을 늘린다.
database connection 구성
let db_args = DbArgs {
// Connection pool size (default: 100)
db_connection_pool_size: 200,
// Connection timeout in ms (default: 60,000)
db_connection_timeout_ms: 30000,
// Statement timeout in ms (default: None)
db_statement_timeout_ms: Some(120000),
};
Tuning guidelines:
db_connection_pool_size: 모든 pipelines의write_concurrency를 기준으로 크기를 정한다.db_connection_timeout_ms: 고부하 시나리오에서 더 빠르게 실패를 감지하려면 줄인다.db_statement_timeout_ms: 예상 쿼리 복잡도와 데이터베이스 성능을 기준으로 설정한다.
command-line 인자
처리를 집중하는 데 도움이 되도록 다음 명령줄 인수를 포함한다. 이 값들은 예시를 위한 것이다. 환경과 목표에 맞는 값을 사용하라.
# Checkpoint range control
--first-checkpoint 1000000 # Start from specific checkpoint
--last-checkpoint 2000000 # Stop at specific checkpoint
# Pipeline selection
--pipeline "tx_counts" # Run specific pipeline only
--pipeline "events" # Can specify multiple pipelines
사용 사례:
- Checkpoint range: 백필과 과거 데이터 처리에 필수적이다.
- Pipeline selection: 선택적 재처리 또는 테스트에 유용하다.
- Skip watermark: 워터마크 일관성이 필요하지 않을 때 더 빠른 백필을 가능하게 한다.
pipeline별 고급 tuning
pipeline 내부 동작에 대한 깊은 이해가 필요한 복잡한 구성 시나리오는 다음을 참조하라:
Tokio runtime debugging
성능에 민감한 pipelines나 async runtime 문제를 해결할 때 sui-indexer-alt-framework는 async Rust 애플리케이션을 위한 강력한 디버거인 tokio-console과 통합된다. 이 도구는 task 실행에 대한 실시간 인사이트를 제공해 성능 병목, 멈춘 tasks, 메모리 문제를 식별하는 데 도움을 준다.
Tokio console 사용 시점
Tokio console은 특히 다음에 유용하다:
- Performance debugging: 느리거나 블로킹되는 tasks 식별.
- Memory analysis: 과도한 메모리를 소비하는 tasks 탐색.
- Concurrency issues: 절대 양보하지 않거나 스스로를 과도하게 깨우는 tasks 탐지.
- Runtime behavior: task 스케줄링 및 실행 패턴 이해.
설정 지침
추가 정보는 Tokio GitHub repo의 README를 참조하라.
-
Add dependencies
Cargo.toml에telemetry_subscribersdependency를 추가한다:[dependencies]
telemetry_subscribers = { git = "https://github.com/MystenLabs/sui.git", branch = "main" } -
Initialize telemetry
main함수 시작 부분에 telemetry initialization을 추가한다:#[tokio::main]
async fn main() -> Result<()> {
// Enable tracing, configured by environment variables
let _guard = telemetry_subscribers::TelemetryConfig::new()
.with_env()
.init();
// Your indexer code here...
} -
Run with console enabled
필요한 플래그와 함께 indexer를 시작한다:
RUSTFLAGS="--cfg tokio_unstable" TOKIO_CONSOLE=1 cargo runFlag explanations:
TOKIO_CONSOLE=1:telemetry_subscribers에서tokio-console통합을 활성화한다.RUSTFLAGS="--cfg tokio_unstable":tokio-console이 task instrumentation 데이터를 수집하는 데 필요하다.
-
Launch the console dashboard
# Install tokio-console if not already installed
cargo install tokio-console
# Connect to your running indexer (default: localhost:6669)
tokio-console성공하면 실행 중인 모든 Tokio task에 대한 정보가 포함된 dashboard가 나타난다:

console 기능
console dashboard, 사용 가능한 views, warnings, diagnostic capabilities에 대한 자세한 내용은 공식 tokio-console documentation을 참조하라.
production 고려 사항
tokio-console은 런타임 오버헤드를 도입하므로 프로덕션에서는 신중하게 사용해야 한다. 개발 및 staging에서 정기적으로 사용하는 것은 안전하지만 프로덕션 사용은 신중한 평가가 필요하다. 프로덕션에서 활성화하기 전에는 특정 워크로드에 미치는 영향을 측정하기 위해 Tokio console을 활성화한 경우와 비활성화한 경우 모두에서 성능 벤치마크를 실행해야 한다. 시스템 리소스를 모니터링하면서 maintenance windows 또는 목표가 명확한 문제 해결 세션 동안에만 활성화하는 것을 고려하라.
메트릭
sui-indexer-alt-framework는 indexer 성능과 상태를 모니터링하기 위한 내장 Prometheus metrics를 제공한다. 모든 metrics는 HTTP를 통해 자동 노출되며 custom metrics로 확장할 수 있다.