Skip to content

Commit de96f09

Browse files
committed
Performance: Bulk Resize für Shared Hosting optimiert
Problem: Auf Plesk-Servern bleibt das Modal bei 20% stehen/dauert sehr lange Änderungen: - MAX_PARALLEL_PROCESSES von 3 auf 1 reduziert (Shared Hosting) - Memory Limit auf 256M erhöht (@ini_set) - Execution Time auf 60 Sekunden gesetzt (@set_time_limit) - Timeout-Check nach 45 Sekunden (verhindert PHP Timeout) - Neue Konstante MAX_EXECUTION_TIME_PER_IMAGE (30s) Begründung: Shared Hosting Server haben limitierte Ressourcen. Sequentielle Verarbeitung (1 Bild nach dem anderen) ist zuverlässiger als parallele Verarbeitung. Für High-Performance Server kann max_parallel über Config erhöht werden.
1 parent b0da6da commit de96f09

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

lib/BulkResize.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ class BulkResize
2323
const IMAGEMAGICK_ONLY_FORMATS = ['psd'];
2424
const SKIPPED_FORMATS = ['tif', 'tiff', 'svg', 'heic'];
2525
const BATCH_CACHE_KEY = 'filepond_bulk_batch_';
26-
const MAX_PARALLEL_PROCESSES = 3;
26+
const MAX_PARALLEL_PROCESSES = 1; // Reduziert auf 1 für bessere Kompatibilität mit Shared Hosting
27+
const MAX_EXECUTION_TIME_PER_IMAGE = 30; // Maximale Zeit pro Bild in Sekunden
2728

2829
/**
2930
* Maximale parallele Prozesse (konfigurierbar)
@@ -170,6 +171,12 @@ private static function updateBatchStatus(string $batchId, array $updates): bool
170171
*/
171172
public static function processNextBatchItems(string $batchId): array
172173
{
174+
// Erhöhe Memory Limit falls möglich
175+
@ini_set('memory_limit', '256M');
176+
177+
// Setze Execution Time Limit
178+
@set_time_limit(60);
179+
173180
$status = self::getBatchStatus($batchId);
174181

175182
if (!$status) {
@@ -183,8 +190,14 @@ public static function processNextBatchItems(string $batchId): array
183190
$maxParallel = self::getMaxParallelProcesses();
184191
$processed = 0;
185192
$results = [];
193+
$startTime = time();
186194

187195
while ($processed < $maxParallel && !empty($status['processQueue'])) {
196+
// Timeout-Check: Breche ab wenn zu lange
197+
if (time() - $startTime > 45) {
198+
rex_logger::factory()->log('warning', 'Bulk Resize: Timeout nach 45 Sekunden erreicht');
199+
break;
200+
}
188201
$filename = array_shift($status['processQueue']);
189202
$status['currentFiles'][] = $filename;
190203

0 commit comments

Comments
 (0)