Bulk API Calls Demo
See how WebSpark.HttpClientUtility efficiently handles multiple concurrent HTTP requests in .NET 10. This demonstration showcases concurrency control, timeout management, and resilience patterns for bulk operations.
Bulk Call Results
| Iteration | Elapsed Time (ms) | Completion Date | Build Date |
|---|---|---|---|
| 1 | 81 | 6/26/2026 10:16:24 PM | N/A |
| 2 | 72 | 6/26/2026 10:16:24 PM | N/A |
| 3 | 73 | 6/26/2026 10:16:25 PM | N/A |
| 4 | 89 | 6/26/2026 10:16:25 PM | N/A |
| 5 | 80 | 6/26/2026 10:16:25 PM | N/A |
| 6 | 85 | 6/26/2026 10:16:25 PM | N/A |
| 7 | 78 | 6/26/2026 10:16:25 PM | N/A |
| 8 | 77 | 6/26/2026 10:16:25 PM | N/A |
| 9 | 94 | 6/26/2026 10:16:25 PM | N/A |
| 10 | 94 | 6/26/2026 10:16:25 PM | N/A |
The table above shows the results of performing multiple asynchronous HTTP GET calls to the specified endpoint. Each row represents an individual request, detailing its execution time and completion date.
WebSpark.HttpClientUtility: Bulk Request Handling
The BulkCallsController demonstrates how WebSpark.HttpClientUtility handles bulk asynchronous HTTP requests efficiently. By leveraging .NET 10's async capabilities and the package's built-in resilience patterns, this demo shows controlled parallelism and optimal resource usage.
Key Features Demonstrated:
- Concurrent HTTP Requests: WebSpark.HttpClientUtility manages multiple HTTP requests concurrently using async tasks and SemaphoreSlim for controlled parallelism.
- Thread Safety: Built-in thread safety mechanisms ensure data integrity in multi-threaded environments.
- Timeouts and Cancellations: Implements CancellationTokenSource with timeout to cancel long-running requests, following .NET 10 best practices.
- Performance Optimization: Using Task.WhenAll with the package's resilience policies significantly reduces overall execution time.
Alternative Approaches:
While the BulkCallsController effectively demonstrates handling bulk requests with `SemaphoreSlim` for concurrency control, other approaches could include:
- Parallel.ForEach: Offers an alternative for concurrent processing but requires careful management of exceptions and concurrency controls.
- TPL Dataflow: Provides advanced options for data buffering and parallel task execution, making it suitable for complex data processing workflows.
- Cloud-Native Solutions: Leveraging Azure Functions or other serverless platforms with built-in scaling can offload concurrency management to cloud infrastructure.
Best Practices:
- Monitor and Log: Use logging and telemetry to monitor the performance and health of bulk async operations, enabling proactive tuning of concurrency levels and timeouts.
- Adjust Concurrency: Optimize the maximum thread count (`maxThreads`) based on system capabilities and endpoint performance to balance resource usage and throughput.
- Handle Failures Gracefully: Implement retry logic or circuit breakers using libraries like Polly to handle transient failures and improve resilience.