Performance_optimization
Chapter 47: Node Performance Optimization
Section titled “Chapter 47: Node Performance Optimization”Overview
Section titled “Overview”Optimizing blockchain node performance is critical for achieving better throughput, lower latency, and reduced resource usage. This chapter covers comprehensive techniques to maximize your node’s efficiency.
47.1 Hardware Optimization
Section titled “47.1 Hardware Optimization”Recommended Hardware Specifications
Section titled “Recommended Hardware Specifications”┌─────────────────────────────────────────────────────────────────────────────┐│ RECOMMENDED HARDWARE FOR BLOCKCHAIN NODES │├─────────────────────────────────────────────────────────────────────────────┤│ ││ ENTRY-LEVEL NODE PRODUCTION NODE ││ ━━━━━━━━━━━━━━━━ ━━━━━━━━━━━━━━━━ ││ CPU: 4 cores CPU: 8+ cores ││ RAM: 8 GB DDR4 RAM: 32 GB DDR4 ││ Storage: 512 GB NVMe Storage: 2 TB NVMe ││ Network: 100 Mbps Network: 1 Gbps ││ ││ ARCHIVE NODE VALIDATOR NODE ││ ━━━━━━━━━━━━ ━━━━━━━━━━━━━━ ││ CPU: 8+ cores CPU: 4 cores ││ RAM: 32 GB DDR4 RAM: 16 GB DDR4 ││ Storage: 8+ TB NVMe Storage: 512 GB NVMe ││ Network: 1 Gbps Network: 1 Gbps ││ │└─────────────────────────────────────────────────────────────────────────────┘Storage Optimization
Section titled “Storage Optimization”| Storage Type | Read Speed | Write Speed | IOPS | Recommended For |
|---|---|---|---|---|
| NVMe SSD | 3,500 MB/s | 3,000 MB/s | 500K+ | All nodes |
| SATA SSD | 550 MB/s | 520 MB/s | 90K | Light nodes |
| HDD | 120 MB/s | 100 MB/s | 200 | Not recommended |
RAM and CPU Considerations
Section titled “RAM and CPU Considerations”┌─────────────────────────────────────────────────────────────────┐│ RAM AND CPU OPTIMIZATION │├─────────────────────────────────────────────────────────────────┤│ ││ RAM USAGE PATTERNS: ││ ━━━━━━━━━━━━━━━━━━━━━ ││ ││ ┌──────────────────┐ ┌──────────────────┐ ││ │ Geth/Erigon │ │ Cosmos │ ││ │ ━━━━━━━━━━━━ │ │ ━━━━━━━━━━━ │ ││ │ │ │ │ ││ │ State Cache: │ │ State Cache: │ ││ │ 4-8 GB │ │ 2-4 GB │ ││ │ │ │ │ ││ │ mempool: 1-2 GB │ │ mempool: 1 GB │ ││ │ │ │ │ ││ │ overhead: 2 GB │ │ overhead: 2 GB │ ││ └──────────────────┘ └──────────────────┘ ││ ││ CPU OPTIMIZATION: ││ ━━━━━━━━━━━━━━━━━ ││ ││ - Enable turbo boost for single-thread performance ││ - Use CPUs with high clock speed (3.5+ GHz) ││ - Disable hyper-threading for consistent performance ││ - Pin node process to specific cores ││ │└─────────────────────────────────────────────────────────────────┘47.2 Software Optimization
Section titled “47.2 Software Optimization”Geth Performance Tuning
Section titled “Geth Performance Tuning”# Optimized Geth startup flagsgeth \ --mainnet \ --syncmode "snap" \ --cache 8192 \ --cache.database 4096 \ --cache.gc 1024 \ --txpool.pricebump 1 \ --txpool.nolocals \ --txpool.accountslots 16 \ --txpool.globalslots 4096 \ --http \ --http.addr "0.0.0.0" \ --http.port 8545 \ --http.api "eth,net,web3,debug,txpool" \ --http.vhosts "*" \ --http.corsdomain "*" \ --ws \ --ws.addr "0.0.0.0" \ --ws.port 8546 \ --ws.api "eth,net,web3,debug,txpool" \ --ws.origins "*" \ --datadir /data/ethereum \ --keystore /data/ethereum/keystore \ --networkid 1 \ --port 30303 \ --maxpeers 50 \ --nat "extip:YOUR_IP" \ --pprof \ --pprof.addr "127.0.0.1" \ --pprof.port 6060 \ --metrics \ --metrics.addr "127.0.0.1" \ --metrics.port 6061Erigon Performance Tuning
Section titled “Erigon Performance Tuning”# Erigon optimized configurationerigon \ --chain mainnet \ --datadir /data/erigon \ --http \ --http.addr "0.0.0.0" \ --http.port 8545 \ --http.api "eth,net,web3,debug,txpool,erigon,debug" \ --ws \ --ws.addr "0.0.0.0" \ --ws.port 8546 \ --ws.api "eth,net,web3" \ --http.vhosts "*" \ --http.corsdomain "*" \ --metrics \ --metrics.addr "127.0.0.1" \ --metrics.port 6060 \ --pprof \ --pprof.addr "127.0.0.1" \ --pprof.port 6061 \ --torrent.download.rate 50mb \ --db.size.limit 3tb \ --maxpeers 100 \ --rpc.batch.concurrency 100 \ --rpc.allow-unprotected-txs \ --txpool.locals 0xYourAddressDatabase Engine Optimization
Section titled “Database Engine Optimization”# Using PebbleDB (faster than LevelDB)--database.engine pebbledb
# LevelDB configuration--database.leveldb.compression snappy--database.leveldb.cache 4096Cache Configuration
Section titled “Cache Configuration”| Parameter | Default | Recommended | Description |
|---|---|---|---|
--cache | 128 | 8192 | Memory allocated for caching |
--cache.database | 128 | 4096 | Database cache size |
--cache.gc | 128 | 1024 | Garbage collection cache |
47.3 Network Optimization
Section titled “47.3 Network Optimization”P2P Network Configuration
Section titled “P2P Network Configuration”# Increase peer connections--maxpeers 100
# Bootnode configuration--bootnodes "enode://...@ip:port,enode://...@ip:port"
# Static peers--staticnodes "enode://..."
# NAT traversal--nat "extip:203.0.113.1"
# P2P network tuning--p2p.dialtimeout 10s--p2p.readlimit 32MB--p2p.writelimit 32MBBandwidth Optimization
Section titled “Bandwidth Optimization”┌─────────────────────────────────────────────────────────────────┐│ BANDWIDTH OPTIMIZATION │├─────────────────────────────────────────────────────────────────┤│ ││ UPLOAD BOTTLENECK SOLUTIONS: ││ ━━━━━━━━━━━━━━━━━━━━━━━━━━━ ││ ││ 1. Enable compression ││ - P2P compression reduces bandwidth by 40-60% ││ - Most clients have this enabled by default ││ ││ 2. Peer selection optimization ││ - Prefer peers with good latency (<100ms) ││ - Balance inbound/outbound connections ││ ││ 3. Bandwidth limits ││ - Set reasonable limits to prevent saturation ││ - --p2p.bandwidth.upload: 10MB/s ││ - --p2p.bandwidth.download: 25MB/s ││ ││ RECOMMENDED NETWORK: ││ ━────────────────━━━━━━ ││ - Minimum: 100 Mbps symmetric ││ - Recommended: 1 Gbps symmetric ││ - For archive nodes: 1 Gbps+ ││ │└─────────────────────────────────────────────────────────────────┘47.4 Operating System Optimization
Section titled “47.4 Operating System Optimization”Linux Kernel Tuning
Section titled “Linux Kernel Tuning”# Increase file descriptorsecho "* soft nofile 65536" >> /etc/security/limits.confecho "* hard nofile 65536" >> /etc/security/limits.confecho "root soft nofile 65536" >> /etc/security/limits.confecho "root hard nofile 65536" >> /etc/security/limits.conf
# Network optimizationecho "net.core.rmem_max=16777216" >> /etc/sysctl.confecho "net.core.wmem_max=16777216" >> /etc/sysctl.confecho "net.ipv4.tcp_rmem=4096 87380 16777216" >> /etc/sysctl.confecho "net.ipv4.tcp_wmem=4096 65536 16777216" >> /etc/sysctl.confecho "net.core.netdev_max_backlog=50000" >> /etc/sysctl.conf
# Apply changessysctl -p
# Disable transparent huge pages (can cause performance issues)echo never > /sys/kernel/mm/transparent_hugepage/enabledecho never > /sys/kernel/mm/transparent_hugepage/defragCPU Affinity
Section titled “CPU Affinity”# Set CPU affinity for geth processsudo apt install util-linuxsudo setcap cap_sys_nice+ep /usr/bin/geth
# Run with specific coresgeth --cpus 4 ...47.5 Monitoring Performance
Section titled “47.5 Monitoring Performance”Key Metrics to Monitor
Section titled “Key Metrics to Monitor”| Metric | Target | Description |
|---|---|---|
| CPU Usage | < 70% | Average CPU usage |
| Memory Usage | < 80% | RAM usage |
| Disk I/O | < 80% | Disk throughput |
| Disk IOPS | < 70% | Input/output operations |
| Network In | Monitor | Inbound bandwidth |
| Network Out | Monitor | Outbound bandwidth |
| Block Import Time | < 500ms | Time to import block |
| Mempool Size | Monitor | Pending transactions |
Prometheus Metrics
Section titled “Prometheus Metrics”scrape_configs: - job_name: 'ethereum-node' static_configs: - targets: ['localhost:6060'] metrics_path: /debug/metrics/prometheus47.6 Performance Benchmarking
Section titled “47.6 Performance Benchmarking”Benchmark Tools
Section titled “Benchmark Tools”# Geth benchmarkgeth snapshot bench --TrieCache 100000 --TrieBranchBuffer 16 --TrieNodeCache 100000
# Erigon benchmarkerigon bench blocks --block 15000000
# Custom benchmark script#!/bin/bash# benchmark.sh
echo "Starting benchmark..."
# Record initial metricsSTART_TIME=$(date +%s)START_CPU=$(top -bn1 | grep "Cpu(s)" | awk '{print $2}')
# Run load testfor i in {1..100}; do curl -s -X POST http://localhost:8545 \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \ > /dev/nulldone
# Record final metricsEND_TIME=$(date +%s)END_CPU=$(top -bn1 | grep "Cpu(s)" | awk '{print $2}')
echo "Requests completed in $((END_TIME - START_TIME)) seconds"echo "Average CPU: $(( (START_CPU + END_CPU) / 2 ))%"47.7 Interview Questions
Section titled “47.7 Interview Questions”| Question | Answer |
|---|---|
| What hardware is recommended for an Ethereum node? | NVMe SSD, 8+ GB RAM, multi-core CPU |
| What is the difference between snap and full sync? | Snap sync downloads only latest state, full syncs entire blockchain |
| How do you optimize database performance? | Use NVMe, enable compression, tune cache settings |
| What is the optimal cache size for Geth? | 4-8 GB for production nodes |
| How do you reduce P2P bandwidth usage? | Enable compression, limit peers, use quality peers |
Summary
Section titled “Summary”- Hardware: Use NVMe SSD and adequate RAM
- Software: Configure cache, database engine, and P2P settings
- Network: Optimize peer selection and bandwidth
- OS: Tune kernel parameters and file descriptors
- Monitor: Track CPU, memory, disk, and network metrics
Next Chapter
Section titled “Next Chapter”In Chapter 50: Solana Node Setup, we’ll explore other blockchain nodes.
Last Updated: 2026-02-20