Implemented runtime-configurable simulator controls to enable workshop participants to test AI agent capacity scenarios without overwhelming infrastructure. Users can now adjust order and ticket generation rates dynamically through REST API endpoints.
Before: Simulator had only two modes:
- Normal: 1-3 orders/hour, 1-2 tickets/hour (~24-72 orders/day, ~24-48 tickets/day) - Too slow for testing
- Stress Test: 5-10 tickets every 5 minutes (~1440-2880 tickets/day) - All-or-nothing, tickets only
Issues:
- No granular control over generation rates
- No way to adjust order volumes in stress test mode
- Couldn't simulate realistic "AI agent needed" scenarios
- Had to restart service to change settings
- Risk of overwhelming infrastructure with testing
Solution: Runtime configuration API with validation and safety limits
File: FabrikamSimulator/src/Services/RuntimeConfigService.cs
Changes:
- Added
OrderGeneratorConfigOverrideclass with IntervalMinutes, MinOrdersPerInterval, MaxOrdersPerInterval - Added
TicketGeneratorConfigOverrideclass with IntervalMinutes, MinTicketsPerInterval, MaxTicketsPerInterval - Implemented thread-safe methods:
SetOrderGeneratorConfig(int intervalMinutes, int minOrders, int maxOrders)GetOrderGeneratorConfig(IConfiguration)- Returns effective config (override or appsettings)ClearOrderGeneratorOverride()SetTicketGeneratorConfig(int intervalMinutes, int minTickets, int maxTickets)GetTicketGeneratorConfig(IConfiguration)- Returns effective config (override or appsettings)ClearTicketGeneratorOverride()HasOrderGeneratorOverride()- Check if runtime override is activeHasTicketGeneratorOverride()- Check if runtime override is active
Pattern: Same three-state nullable pattern used for StressTestMode (null = use config, value = override)
File: FabrikamSimulator/src/Controllers/SimulatorController.cs
POST /api/simulator/config/orders
{
"intervalMinutes": 60,
"minOrdersPerInterval": 2,
"maxOrdersPerInterval": 5
}Response:
{
"message": "Order generator configuration updated",
"intervalMinutes": 60,
"minOrdersPerInterval": 2,
"maxOrdersPerInterval": 5,
"estimatedOrdersPerDay": 84,
"note": "Configuration is runtime-only and will reset on service restart..."
}POST /api/simulator/config/orders/reset
- Clears runtime override and returns to appsettings.json defaults
POST /api/simulator/config/tickets
{
"intervalMinutes": 30,
"minTicketsPerInterval": 2,
"maxTicketsPerInterval": 5
}Response:
{
"message": "Ticket generator configuration updated",
"intervalMinutes": 30,
"minTicketsPerInterval": 2,
"maxTicketsPerInterval": 5,
"estimatedTicketsPerDay": 168,
"note": "Configuration is runtime-only and will reset on service restart..."
}POST /api/simulator/config/tickets/reset
- Clears runtime override and returns to appsettings.json defaults
All endpoints include validation:
Interval Validation:
- Minimum: 1 minute (prevents rapid-fire generation)
- Maximum: 1440 minutes / 24 hours (prevents excessively long intervals)
- Error:
"Interval must be between 1 and 1440 minutes (24 hours)"
Volume Validation:
- Minimum: 0 for min, 1 for max (prevents negative volumes)
- Maximum: 50 per interval (prevents infrastructure overload)
- Min cannot exceed Max
- Errors:
"MinOrdersPerInterval must be between 0 and 50""MaxOrdersPerInterval must be between 1 and 50""MinOrdersPerInterval cannot exceed MaxOrdersPerInterval"
Estimated Throughput Calculation:
var intervalsPerDay = 1440 / intervalMinutes;
var avgPerInterval = (min + max) / 2.0;
var estimatedPerDay = intervalsPerDay * avgPerInterval;File: FabrikamSimulator/src/Workers/OrderGeneratorWorker.cs
Changes:
- Injected
RuntimeConfigServicein constructor - Changed
ExecuteAsyncto call_runtimeConfig.GetOrderGeneratorConfig(_configuration) - Uses effective config values (runtime override or appsettings)
- Updated
GenerateOrdersmethod to acceptminOrders, maxOrdersparameters
File: FabrikamSimulator/src/Workers/TicketGeneratorWorker.cs
Changes:
- Already had
RuntimeConfigServiceinjected (for stress test mode) - Updated
ExecuteAsyncto call_runtimeConfig.GetTicketGeneratorConfig(_configuration)in normal mode - Stress test mode still uses separate
StressTestConfig(unchanged) - Uses effective config values in normal mode
Goal: Test basic functionality with minimal load
Configuration:
// Orders: ~12-24 per day
{"intervalMinutes": 120, "minOrdersPerInterval": 1, "maxOrdersPerInterval": 2}
// Tickets: ~12-24 per day
{"intervalMinutes": 120, "minTicketsPerInterval": 1, "maxTicketsPerInterval": 1}When to use: Initial testing, debugging, low-resource environments
Goal: Standard simulation for development
Configuration: Use defaults from appsettings.json
POST /api/simulator/config/orders/reset
POST /api/simulator/config/tickets/resetThroughput: ~24-72 orders/day, ~24-48 tickets/day
When to use: Daily development, standard demos
Goal: Test automation capabilities
Configuration:
// Orders: ~144-336 per day
{"intervalMinutes": 30, "minOrdersPerInterval": 3, "maxOrdersPerInterval": 7}
// Tickets: ~144-360 per day
{"intervalMinutes": 30, "minTicketsPerInterval": 2, "maxTicketsPerInterval": 5}When to use: Testing AI agent helpers, partial automation scenarios
Goal: Test full AI agent capacity - requires automated handling
Configuration:
// Orders: ~720-2160 per day
{"intervalMinutes": 10, "minOrdersPerInterval": 5, "maxOrdersPerInterval": 15}
// Tickets: ~720-2160 per day
{"intervalMinutes": 10, "minTicketsPerInterval": 5, "maxTicketsPerInterval": 15}When to use: Demonstrating AI agent value, capacity testing, workshop challenges
Warning: This generates significant load - ensure infrastructure can handle it
Test File: test-simulator-config.http
Contains comprehensive tests for:
- ✅ Updating order configuration
- ✅ Updating ticket configuration
- ✅ Resetting to defaults
- ✅ All 4 preset scenarios
- ✅ Validation tests (should return errors)
- ✅ Stress test mode compatibility
How to Test:
- Start FabrikamSimulator:
dotnet run --project FabrikamSimulator/src/FabrikamSimulator.csproj - Open
test-simulator-config.httpin VS Code - Use REST Client extension to execute requests
- Verify responses show correct estimated throughput
- Check simulator logs to confirm new config is being used
- Verify workers generate at new rates
- Uses lock pattern for all runtime config operations
- Safe for concurrent API calls
- No race conditions
- Runtime overrides are optional (nullable)
- Falls back to appsettings.json when override is null
- Service restart clears all overrides
- All inputs validated before applying
- Safety limits prevent infrastructure overload
- Clear error messages for invalid inputs
- Shows projected daily volume before applying
- Helps users understand impact
- Prevents accidental overload
- RuntimeConfigService manages overrides
- SimulatorController handles HTTP/validation
- Workers consume effective config
- Clean dependency injection
Planned Features:
- Simulator configuration panel on Home page
- Sliders for intervals and volumes
- Preset buttons (Low, Normal, High, AI Challenge)
- Estimated throughput display (orders/day, tickets/day)
- Apply and Reset buttons
- Visual feedback when runtime overrides are active
Implementation Plan:
- Add configuration section to
FabrikamDashboard/Components/Pages/Home.razor - Create
SimulatorConfigServiceto call new API endpoints - Add range input controls with value displays
- Add preset button handlers
- Show estimated throughput calculations
- Add visual indicators for active overrides
- Style with CSS matching existing dashboard theme
User Experience:
- No need to use REST client or curl
- Visual feedback of current settings
- Easy presets for common scenarios
- Safety warnings for high volumes
Once Dashboard UI is complete:
- Test all presets through UI
- Verify workers respond to config changes
- Validate throughput estimates match actual generation
- Test concurrent users changing settings
- Verify override indicators work
- Test reset functionality
-
FabrikamSimulator/src/Services/RuntimeConfigService.cs (+118 lines)
- Added override classes
- Implemented config management methods
-
FabrikamSimulator/src/Controllers/SimulatorController.cs (+184 lines)
- Added 4 new endpoints
- Implemented validation
- Added request/response models
-
FabrikamSimulator/src/Workers/OrderGeneratorWorker.cs (Modified)
- Injected RuntimeConfigService
- Uses effective config instead of appsettings
-
FabrikamSimulator/src/Workers/TicketGeneratorWorker.cs (Modified)
- Updated to use effective config in normal mode
- test-simulator-config.http (New file, 223 lines)
- Comprehensive API testing
- All scenarios documented
- Validation test cases
- Max 50 items per interval prevents overload
- Min 1 minute interval prevents rapid-fire
- Estimated throughput shown before applying
- Runtime-only (resets on restart)
- Start with low volumes and increase gradually
- Monitor infrastructure during high-volume tests
- Use presets rather than custom values when possible
- Keep "Reset to Defaults" easily accessible
- Validation happens before applying changes
- Invalid requests return 400 Bad Request
- Activity log tracks all config changes
- Structured logging shows effective config values
- Start at normal volume (human can handle)
- Increase to intermediate (human + some automation)
- Increase to high volume (AI agent required)
- Show performance difference clearly
- Try different load scenarios
- No permanent changes
- Easy reset to defaults
- Estimated impact shown upfront
- Gradual load increases
- Different patterns (orders vs tickets)
- Customizable to specific scenarios
- Matches real-world scaling challenges
- Runtime overrides: Temporary, cleared on restart, API-managed
- appsettings.json: Permanent, requires file edit, default fallback
- Stress test mode still works independently
- Affects ticket generation only
- Uses separate
StressTestConfigsection - Runtime config only applies in normal mode
All configuration changes are logged:
Order generator configuration updated via API: Interval=10min, Min=5, Max=15, Estimated=1080/day
Activity log entries created for:
- Config updates
- Reset to defaults
- Shows estimated throughput
✅ Completed: Backend infrastructure for configurable simulator controls
- Runtime configuration service
- REST API endpoints with validation
- Worker integration
- Comprehensive testing resources
- Safety limits and validation
🔄 Pending: Dashboard UI controls
- Visual configuration panel
- Preset buttons
- Real-time throughput estimates
- User-friendly controls
Impact: Enables workshop participants to safely test AI agent capacity scenarios with realistic, adjustable load patterns without risking infrastructure overload.
Last Updated: 2025-01-XX
Status: Backend Complete, UI Pending
Build Status: ✅ All projects compile successfully