Skip to main content

Reload strategies

Reload strategies in PHPStreamServer define the rules for when workers should be restarted. PHPStreamServer provides several built-in reload strategies of the box. Additionally, plugins can add new reload strategies, enhancing functionality.

🔄️ TTLReloadStrategy

Reloads a worker after a specified time-to-live (TTL) interval. This ensures that workers are periodically restarted, which can help prevent issues caused by long-running processes.

OptionTypeDefaultDescription
ttlintnot setTime-to-live interval in seconds.

🔄️ MaxMemoryReloadStrategy

Reloads a worker when its memory consumption exceeds a specified threshold. This helps manage memory leaks and prevents excessive memory usage.

OptionTypeDefaultDescription
maxMemoryintnot setMemory consumption threshold in bytes.

🔄️ ExceptionReloadStrategy

Reloads a worker when an exception is thrown, except for specified exceptions that are excluded from triggering a reload. This ensures workers don't remain in an unexpected state after encountering an error.

OptionTypeDefaultDescription
allowedExceptionsclass-string[]not setOptional. A list of exception class names that will not trigger a reload.

🔄️🔌 EachRequestReloadStrategy

This is the part of Http Server Plugin

This strategy reloads the worker after every HTTP request, making it primarily useful for debugging purposes.

This strategy does not have any specific configurable options.

🔄️🔌 MaxRequestsReloadStrategy

This is the part of Http Server Plugin

This strategy reloads the worker after handling a specified number of HTTP requests.

OptionTypeDefaultDescription
maxRequestsintnot setThe maximum number of requests a worker can handle before being reloaded.
dispersionPercentageint0Optional. Variability percantage to maxRequests. *

* Adds variability to the reload threshold to avoid restarting all workers simultaneously. For example, with maxRequests = 1000 and dispersionPercentage = 20, workers will be reloaded after handling between 800 and 1000 requests.