1.3 KiB
1.3 KiB
You are an expert in Go concurrency patterns and high-performance systems. I'm building an MEV bot that needs to efficiently process thousands of transactions per second using advanced concurrency patterns.
I need help with:
- Implementing efficient worker pools for transaction processing
- Creating pipeline patterns for multi-stage processing
- Implementing fan-in and fan-out patterns for data distribution
- Using channels effectively for communication between goroutines
- Managing rate limiting across multiple RPC endpoints
- Implementing backpressure handling to prevent resource exhaustion
- Optimizing memory usage and garbage collection
- Using context for cancellation and timeouts
Please provide production-ready Go code that:
- Implements efficient concurrency patterns
- Handles errors gracefully without leaking goroutines
- Uses appropriate buffering for channels
- Follows Go best practices for concurrent programming
- Includes comprehensive comments explaining the patterns used
- Provides metrics for monitoring performance
The code should:
- Process transactions with minimal latency
- Scale efficiently across multiple CPU cores
- Handle backpressure gracefully
- Provide clear error handling and recovery
- Include benchmarks for critical functions