An Akka.NET demonstration project showcasing advanced streaming patterns using Akka Streams and the Actor model. This project implements a "stream of streams" architecture where each entity produces its own stream of data points that are processed in parallel.
This application demonstrates how to:
- Process multiple entity streams concurrently using Akka.NET actors and Akka Streams
- Use
SourceRefto create distributed streams of data points - Perform real-time statistical computations on streaming data
- Write results to multiple storage backends concurrently
- Integrate Akka actors with Akka Streams for complex data processing pipelines
The application consists of several key actors that work together to process entity data:
- DataPointActor - Generates entity metadata and creates
SourceRef<DataPoint>streams for each entity - ProcessorActor - Main orchestrator that processes entities, consumes data streams, performs statistical calculations, and coordinates storage operations
- DynamoDbWriterActor - Simulates writing computation results to AWS DynamoDB
- S3WriterActor - Simulates writing computation results to AWS S3
- Entity Processing: The application processes 200 entities (Entity-10 through Entity-209)
- Stream Creation: Each entity gets its own stream of 5-50 randomly generated data points
- Parallel Processing: Multiple entity streams are processed concurrently with configurable parallelism
- Statistical Computation: For each entity stream, the system calculates:
- Average of data point values
- Standard deviation
- Blended average incorporating previous historical data
- Concurrent Storage: Results are written simultaneously to both DynamoDB and S3
- Backpressure Management: Akka Streams handles flow control and backpressure automatically
Demonstrates how to manage multiple independent data streams where each entity produces its own stream of data points that are processed independently but orchestrated centrally.
private const int MaxDataPointsParallelism = 5;
private const int MaxSubStreamParallelism = 5;Uses Akka Streams SourceRef to create materialized stream references that can be passed between actors:
var sourceRef = await Source.From(dataPoints)
.RunWith(streamRef, _materializer);Performs streaming aggregations using Akka Streams operators:
Aggregatefor accumulating statisticsSelectfor transforming dataIdleTimeoutfor handling processing timeouts
Writes results to multiple storage systems concurrently using Task.WhenAll:
var writeToDynamo = _dynamoDbWriterActor.ActorRef.Ask<IWriteResult>(...);
var writeToS3 = _s3WriterActor.ActorRef.Ask<IWriteResult>(...);
var results = await Task.WhenAll(writeToDynamo, writeToS3);- .NET 9.0 - Target framework
- Akka.NET - Actor framework and streaming library
- Akka.Hosting - Dependency injection integration
- Microsoft.Extensions.Hosting - Host builder and application lifetime management
- .NET 9.0 SDK or later
- Clone the repository
- Navigate to the project directory
- Build the project:
dotnet build
- Run the application:
dotnet run --project src/StreamOfStreams
The application will:y
- Process 200 entities in parallel
- Generate random data points for each entity
- Perform statistical calculations on each entity's data stream
- Write results to simulated DynamoDB and S3 storage
- Log progress and completion status
The application will log information about:
- Entity processing start and completion
- Data point generation for each entity
- Statistical computation results
- Storage operation success/failure
- Overall processing completion
This pattern is useful for scenarios such as:
- IoT Data Processing - Processing sensor data streams from multiple devices
- Financial Analytics - Real-time analysis of trading data from multiple instruments
- Log Processing - Analyzing log streams from multiple services or applications
- Machine Learning Pipelines - Processing feature streams for multiple models
- Event Sourcing - Processing event streams from multiple aggregates
This project demonstrates:
- Advanced Akka Streams patterns and operators
- Integration between Akka actors and Akka Streams
- Backpressure handling in streaming applications
- Concurrent processing with parallelism controls
- Actor-based dependency injection using Akka.Hosting
- Error handling and timeout management in streaming pipelines