feat(Production): Complete production deployment infrastructure

- Add comprehensive health check system with multiple endpoints
- Add Prometheus metrics endpoint
- Add production logging configurations (5 strategies)
- Add complete deployment documentation suite:
  * QUICKSTART.md - 30-minute deployment guide
  * DEPLOYMENT_CHECKLIST.md - Printable verification checklist
  * DEPLOYMENT_WORKFLOW.md - Complete deployment lifecycle
  * PRODUCTION_DEPLOYMENT.md - Comprehensive technical reference
  * production-logging.md - Logging configuration guide
  * ANSIBLE_DEPLOYMENT.md - Infrastructure as Code automation
  * README.md - Navigation hub
  * DEPLOYMENT_SUMMARY.md - Executive summary
- Add deployment scripts and automation
- Add DEPLOYMENT_PLAN.md - Concrete plan for immediate deployment
- Update README with production-ready features

All production infrastructure is now complete and ready for deployment.
This commit is contained in:
2025-10-25 19:18:37 +02:00
parent caa85db796
commit fc3d7e6357
83016 changed files with 378904 additions and 20919 deletions

View File

@@ -9,7 +9,6 @@ use App\Framework\Queue\Distribution\JobDistributionService;
use App\Framework\Queue\Failover\FailoverRecoveryService;
use App\Framework\Queue\Health\WorkerHealthCheckService;
use App\Framework\Queue\Jobs\JobPriority;
use App\Framework\Queue\Jobs\JobStatus;
use App\Framework\Queue\Workers\WorkerRegistry;
use App\Framework\Queue\Workers\WorkerStatus;
use PHPUnit\Framework\TestCase;
@@ -17,9 +16,13 @@ use PHPUnit\Framework\TestCase;
final class RealisticLoadScenariosTest extends TestCase
{
private DatabaseManager $database;
private WorkerRegistry $workerRegistry;
private JobDistributionService $distributionService;
private WorkerHealthCheckService $healthCheckService;
private FailoverRecoveryService $failoverService;
protected function setUp(): void
@@ -60,7 +63,7 @@ final class RealisticLoadScenariosTest extends TestCase
// Medium-capacity workers for inventory updates
...$this->createWorkers(12, 30, 'inventory_worker'),
// Lower-capacity workers for email notifications
...$this->createWorkers(20, 15, 'notification_worker')
...$this->createWorkers(20, 15, 'notification_worker'),
];
$this->registerWorkers($workers);
@@ -105,7 +108,7 @@ final class RealisticLoadScenariosTest extends TestCase
// Medium workers for image processing
...$this->createWorkers(8, 50, 'image_processor'),
// Light workers for metadata extraction
...$this->createWorkers(12, 25, 'metadata_worker')
...$this->createWorkers(12, 25, 'metadata_worker'),
];
$this->registerWorkers($workers);
@@ -150,7 +153,7 @@ final class RealisticLoadScenariosTest extends TestCase
// Fraud detection workers
...$this->createWorkers(10, 15, 'fraud_detector'),
// Settlement workers
...$this->createWorkers(5, 30, 'settlement_worker')
...$this->createWorkers(5, 30, 'settlement_worker'),
];
$this->registerWorkers($workers);
@@ -197,7 +200,7 @@ final class RealisticLoadScenariosTest extends TestCase
// Data validation workers
...$this->createWorkers(8, 75, 'validator'),
// Report generation workers
...$this->createWorkers(4, 150, 'report_generator')
...$this->createWorkers(4, 150, 'report_generator'),
];
$this->registerWorkers($workers);
@@ -244,7 +247,7 @@ final class RealisticLoadScenariosTest extends TestCase
// Heavy computation workers
...$this->createWorkers(5, 80, 'compute_worker'),
// Notification workers
...$this->createWorkers(20, 10, 'notification_worker')
...$this->createWorkers(20, 10, 'notification_worker'),
];
$this->registerWorkers($workers);
@@ -254,7 +257,7 @@ final class RealisticLoadScenariosTest extends TestCase
['duration' => 60, 'rate' => 20, 'mix' => 'normal'],
['duration' => 120, 'rate' => 50, 'mix' => 'peak'],
['duration' => 60, 'rate' => 15, 'mix' => 'background'],
['duration' => 90, 'rate' => 35, 'mix' => 'mixed']
['duration' => 90, 'rate' => 35, 'mix' => 'mixed'],
];
$overallResults = [];
@@ -293,7 +296,7 @@ final class RealisticLoadScenariosTest extends TestCase
$workers = [
...$this->createWorkers(12, 25, 'primary_worker'),
...$this->createWorkers(8, 30, 'secondary_worker'),
...$this->createWorkers(6, 20, 'backup_worker')
...$this->createWorkers(6, 20, 'backup_worker'),
];
$this->registerWorkers($workers);
@@ -312,7 +315,7 @@ final class RealisticLoadScenariosTest extends TestCase
'jobs_processed' => 0,
'jobs_failed' => 0,
'response_times' => [],
'failover_events' => []
'failover_events' => [],
];
$failoverTriggered = false;
@@ -321,7 +324,7 @@ final class RealisticLoadScenariosTest extends TestCase
$cycleStart = microtime(true);
// Trigger failover at 1/3 of test duration
if (!$failoverTriggered && (microtime(true) - $startTime) > ($testDuration / 3)) {
if (! $failoverTriggered && (microtime(true) - $startTime) > ($testDuration / 3)) {
echo "\nTriggering failover scenario...\n";
// Fail primary workers
@@ -329,13 +332,13 @@ final class RealisticLoadScenariosTest extends TestCase
$this->updateWorkerStatus("primary_worker_{$i}", WorkerStatus::FAILED);
}
$failoverTime = PerformanceTestHelper::measureTime(function() {
$failoverTime = PerformanceTestHelper::measureTime(function () {
$this->failoverService->performFullSystemRecovery();
});
$metrics['failover_events'][] = [
'time' => microtime(true) - $startTime,
'recovery_time' => $failoverTime
'recovery_time' => $failoverTime,
];
echo "Failover completed in {$failoverTime}ms\n";
@@ -346,7 +349,7 @@ final class RealisticLoadScenariosTest extends TestCase
for ($i = 0; $i < $baseJobRate; $i++) {
$job = PerformanceTestHelper::createTestJob("realworld_job_{$metrics['jobs_processed']}");
$result = PerformanceTestHelper::measureTimeWithResult(function() use ($job) {
$result = PerformanceTestHelper::measureTimeWithResult(function () use ($job) {
try {
return $this->distributionService->distributeJob($job);
} catch (\Exception $e) {
@@ -382,7 +385,7 @@ final class RealisticLoadScenariosTest extends TestCase
echo "Success rate: {$successRate}%\n";
echo "Response times: " . PerformanceTestHelper::formatStatistics($responseStats) . "\n";
if (!empty($metrics['failover_events'])) {
if (! empty($metrics['failover_events'])) {
echo "Failover recovery time: {$metrics['failover_events'][0]['recovery_time']}ms\n";
}
@@ -408,7 +411,7 @@ final class RealisticLoadScenariosTest extends TestCase
'response_times' => [],
'memory_snapshots' => [],
'start_memory' => null,
'end_memory' => null
'end_memory' => null,
];
if ($enableResourceMonitoring) {
@@ -426,7 +429,7 @@ final class RealisticLoadScenariosTest extends TestCase
$jobType = $this->selectJobType($jobMix);
$job = $this->createJobForType($jobType, $jobCounter);
$result = PerformanceTestHelper::measureTimeWithResult(function() use ($job) {
$result = PerformanceTestHelper::measureTimeWithResult(function () use ($job) {
try {
return $this->distributionService->distributeJob($job);
} catch (\Exception $e) {
@@ -448,7 +451,7 @@ final class RealisticLoadScenariosTest extends TestCase
if ($enableResourceMonitoring && microtime(true) >= $nextSnapshotTime) {
$metrics['memory_snapshots'][] = [
'time' => microtime(true) - $startTime,
'memory' => PerformanceTestHelper::getMemoryUsage()
'memory' => PerformanceTestHelper::getMemoryUsage(),
];
$nextSnapshotTime += $snapshotInterval;
}
@@ -488,7 +491,7 @@ final class RealisticLoadScenariosTest extends TestCase
'success_rate' => round($successRate, 2),
'avg_response_time' => $responseStats['avg'],
'p95_response_time' => $responseStats['p95'],
'p99_response_time' => $responseStats['p99']
'p99_response_time' => $responseStats['p99'],
];
if ($includeResourceMetrics && isset($metrics['start_memory'], $metrics['end_memory'])) {
@@ -513,7 +516,7 @@ final class RealisticLoadScenariosTest extends TestCase
'inventory_update' => 25,
'payment_processing' => 20,
'email_notification' => 10,
'user_analytics' => 5
'user_analytics' => 5,
];
}
@@ -523,7 +526,7 @@ final class RealisticLoadScenariosTest extends TestCase
'video_transcode' => 30,
'image_resize' => 40,
'thumbnail_generation' => 20,
'metadata_extraction' => 10
'metadata_extraction' => 10,
];
}
@@ -533,7 +536,7 @@ final class RealisticLoadScenariosTest extends TestCase
'payment_processing' => 50,
'fraud_detection' => 25,
'account_verification' => 15,
'transaction_logging' => 10
'transaction_logging' => 10,
];
}
@@ -543,7 +546,7 @@ final class RealisticLoadScenariosTest extends TestCase
'data_transformation' => 40,
'data_validation' => 30,
'report_generation' => 20,
'data_archival' => 10
'data_archival' => 10,
];
}
@@ -553,24 +556,24 @@ final class RealisticLoadScenariosTest extends TestCase
'normal' => [
'web_request' => 50,
'background_task' => 30,
'notification' => 20
'notification' => 20,
],
'peak' => [
'web_request' => 60,
'background_task' => 20,
'notification' => 15,
'compute_task' => 5
'compute_task' => 5,
],
'background' => [
'background_task' => 60,
'compute_task' => 30,
'notification' => 10
'notification' => 10,
],
'mixed' => [
'web_request' => 35,
'background_task' => 25,
'compute_task' => 25,
'notification' => 15
'notification' => 15,
],
default => ['web_request' => 100]
};
@@ -638,7 +641,8 @@ final class RealisticLoadScenariosTest extends TestCase
private function calculateStandardDeviation(array $values): float
{
$mean = array_sum($values) / count($values);
$sumSquaredDiffs = array_sum(array_map(fn($v) => pow($v - $mean, 2), $values));
$sumSquaredDiffs = array_sum(array_map(fn ($v) => pow($v - $mean, 2), $values));
return sqrt($sumSquaredDiffs / count($values));
}
@@ -652,6 +656,7 @@ final class RealisticLoadScenariosTest extends TestCase
WorkerStatus::AVAILABLE
);
}
return $workers;
}
@@ -717,4 +722,4 @@ final class RealisticLoadScenariosTest extends TestCase
$pdo->exec('DELETE FROM workers');
$pdo->exec('DELETE FROM jobs');
}
}
}