An incident runbook for PHP applications turns an alert into a sequence of controlled decisions. It is not a list of commands or a document that assumes a cause: it must indicate which symptom has been detected, what evidence to collect, which actions are acceptable, when to stop, and who can decide the next step.
This is especially important in applications with web traffic, background PHP processes, queues, cron, external integrations, and shared databases. An apparently simple intervention, such as restarting consumers or retrying messages, can conceal the root cause, duplicate operations, or increase the load on an already degraded service.
What a runbook addresses and what it must not replace

A runbook reduces improvisation during repeatable or foreseeable situations. It makes the order of checks, the limits of an intervention, and the evidence required to declare recovery explicit. It also enables development, operations, and business teams to share the same language during an incident.
It does not replace the controls that must exist before the incident:
- Observability: metrics, correlated logs, traces, and alerts with understandable thresholds. A procedure does not compensate for an ambiguous signal or one without context.
- Training and permissions: the people who execute it must understand the risk and have only the access they need.
- Backups and tested restoration: a backup is not a recovery strategy if its integrity, scope, and restoration time are unknown.
- Architecture: idempotent retries, resource limits, timeouts, circuit breakers, and dependency isolation reduce the need for manual interventions.
- Change management: a deployment is not the same as a release. The runbook must know which version is active and whether a gradual rollout can reduce the risk of a rollback.
The goal is not to document every possible failure. It is to standardize responses for signals with operational impact and for which an incorrect decision can worsen the system state.
When an alert deserves a specific procedure
Not every alert requires its own document. It is advisable to prioritize situations that combine frequency, impact, time pressure, or dependencies between teams. An alert deserves a runbook when the response should not depend on remembering steps under stress.
- It recurs and usually requires the same initial checks.
- It affects revenue, customer processes, deadlines, or the availability of a critical function.
- The corrective action is reversible only within a limited window.
- It requires coordination between the PHP application, infrastructure, the database, or an API provider.
- A manual action can cause data loss, duplication, or exposure.
- The alert has known false positives that must be ruled out with specific evidence.
Start with the observable symptom, not a theory. “Pending jobs are increasing,” “endpoint latency exceeds the threshold,” “5xx errors are rising,” or “an integration returns invalid responses” are useful inputs. “The database is saturated” is a hypothesis that must be verified, not the starting point for the procedure.
The minimum structure of an actionable runbook
A useful operational document can be read and executed during an incident. It must avoid phrases such as “review the logs” without specifying what to look for, over what interval, and which outcome changes the decision.
- Purpose and scope: describe the covered symptom, the affected components, and those that are out of scope. Indicate whether it applies to production, specific environments, or a type of process.
- Input signals: include the alert, thresholds, relevant dashboards, error message, and conditions that distinguish a real alert from noise.
- Initial owner and permissions: specify who acknowledges the incident, who executes actions, and who authorizes high-impact operations.
- Risks and stop conditions: make clear which actions must not be performed, which data could be affected, and when to escalate without proceeding.
- Steps and evidence: each step must request a check, record an expected result, and define the next decision branch.
- Exit: define which evidence allows the incident to be closed and what follow-up remains open afterward.
Internal links to dashboards, repositories, or tools can be useful in the operational version, but they must not be the only context. Note which metric to observe, which label to filter by, and which time window to use. If a tool is unavailable, the team must know which alternative evidence it can gather.
Separate diagnosis, mitigation, and recovery
A frequent cause of prolonged incidents is mixing investigation and changes. The runbook must classify actions according to their risk level and purpose.
Safe actions and diagnosis
Acknowledging the alert, opening a coordination channel, capturing metrics, querying error logs, and checking dependency status are generally low-risk actions. Even so, they must have limits: expensive queries against a degraded database or unfiltered log searches can also add pressure.
Diagnosis must formulate testable hypotheses. For example: if connection errors increase and the connection pool is exhausted, investigate the dependency and usage pattern before changing limits. If only a recently rolled-out version fails, compare its traffic and errors with the previous version.
Mitigation and recovery
Mitigation limits damage without claiming that the cause has been fixed: reducing exposure to a feature, pausing a job intake, or applying rate limiting are possible examples. Recovery returns the service to an acceptable state: restoring a consumer, rolling back a version, or processing pending work in a controlled manner.
Each action must include a decision point: which metric improves, how long it is observed, and what happens if it worsens. Restarting a PHP process may be valid as a bounded mitigation, but it must not be an automatic instruction if there are non-idempotent tasks, database locks, or unexplained memory consumption.
Hypothetical example: backlog of jobs in a PHP queue
Consider a PHP application with consumers that process notifications, synchronizations, or commerce tasks. The alert indicates that the number of pending jobs is steadily increasing. The runbook must not simply instruct to “empty the queue.”
- Confirm the scope: measure pending jobs by job type, message age, intake rate, and processing rate. Check whether the delay affects all consumers or a specific path.
- Review consumer health: active processes, restarts, memory, PHP errors, timeouts, and repeated exceptions. Also check connectivity to the queue and the dependencies called by the jobs.
- Classify the hypothesis: abnormally high intake, insufficient capacity, blocked job, code error, slow external dependency, or invalid data. Do not increase consumers if the destination dependency is already saturated.
- Define retry limits. Messages that repeatedly fail must go to a review path or error queue when the design allows it; retrying them without limits can amplify traffic and duplicate effects.
- Apply gradual recovery: restore or scale consumers in steps, observe the success rate, and monitor errors, latency, and database load. Maintain a stop condition if the backlog grows faster or failures increase.
- Validate the outcome: check that old work is decreasing, that there are no duplicates, that associated operations are consistent, and that the alert stabilizes during a defined window.
If jobs produce external effects, such as charges, emails, or inventory changes, the runbook must require human review before reprocessing batches. Idempotency reduces risk, but it must not be assumed without evidence from the design and the affected data.
Protect sensitive data and irreversible operations
A procedure that touches personal data, credentials, orders, payments, or regulatory records needs additional controls. It is not enough for the command to be technically correct.
- Use least-privilege permissions and separate accounts for read access, operational intervention, and administration.
- Require dual confirmation for deletions, bulk reprocessing, restorations, or direct data modifications.
- Record who authorized and executed the action, which data interval it covered, and what result it produced.
- Define a validation sample before acting on the entire set.
- Establish an explicit stop condition for discrepancies, unidentifiable data, or effects outside the initial scope.
Avoid including secrets in the runbook, logs, or screenshots. The document can indicate the authorized system for obtaining temporary credentials, but it must not turn sensitive information into permanent text.
Escalation and verification after recovery

Escalation is not a failure of the team handling the alert; it is a risk-control decision. Escalate to development when there is a possible application defect, version regression, or non-idempotent behavior. Escalate to infrastructure if there is resource exhaustion, network, storage, or runtime platform issues. Involve the external provider when the evidence points to its API or service. Request a business decision if mitigation requires pausing sales, delaying communications, or accepting a different processing order.
Also define a maximum time for each phase. If there is not enough evidence after the initial diagnosis, or if a mitigation does not improve the signal within the expected interval, the responsible person must escalate instead of repeating actions.
Recovery ends when more than the disappearance of the alert has been verified:
- The initial symptom remains within limits during an observation window.
- Pending work, transactions, and affected data are consistent.
- Users can complete the relevant flows without noticeable degradation.
- Related alerts show no side effects after the change.
- The timeline, confirmed or ruled-out hypotheses, actions, and pending improvements are documented.
Review the runbook after using it. Remove steps that did not provide evidence, incorporate decisions that were necessary, and turn recurring findings into observability, testing, or architecture improvements. This is how the procedure stops being static documentation and becomes a safe recovery tool.



