← Home ← Codex ← DEBT
Browse by Category
+ added · updated 7d
← Back to glossary

PHP Deployment on Cloud Platforms

Cloud PHP 5.0+ Intermediate
debt(d9/e7/b7/t7)
d9 Detectability Operational debt — how invisible misuse is to your safety net

Closest to 'silent in production until users hit it' (d9). The detection_hints note automated=no and the code_pattern describes manual SSH deployments with no rollback mechanism. Tools listed (aws-codedeploy, ecs, ecr, terraform) are infrastructure provisioning tools, not detectors of misuse. Session loss, container ephemeral storage issues, and cold-start cost surprises only manifest under real traffic or production conditions — no linter or SAST catches these architectural choices.

e7 Effort Remediation debt — work required to fix once spotted

Closest to 'cross-cutting refactor across the codebase' (e7). The quick_fix (ECS Fargate with CodeDeploy blue/green) is not a one-liner — it requires building Docker images, pushing to ECR, rewriting task definitions, configuring CodeDeploy pipelines, migrating sessions to Redis, moving file storage to S3, and tuning PHP-FPM workers. This touches infrastructure, application code, and deployment pipeline across the entire system.

b7 Burden Structural debt — long-term weight of choosing wrong

Closest to 'strong gravitational pull' (e7). The deployment model (EC2 vs ECS vs Lambda/Bref) shapes every scaling, cost, and operational decision. Common mistakes listed (sessions, ephemeral storage, FPM tuning, long-running processes on Lambda) show how this choice bleeds into application architecture. The applies_to covers both web and CLI contexts, meaning the burden is felt across multiple workstreams. Every future change — autoscaling, queue workers, file uploads — is constrained by the original deployment model.

t7 Trap Cognitive debt — how counter-intuitive correct behaviour is

Closest to 'serious trap (contradicts how a similar concept works elsewhere)' (t7). The misconception is explicit: developers assume serverless PHP is always cheapest, but cold starts add latency and consistent traffic is cheaper on containers. This directly contradicts the general serverless cost narrative common in the industry. Additional traps around session handling (multi-instance EC2), ephemeral container storage, and Lambda timeouts for long-running processes represent multiple serious gotchas that contradict reasonable assumptions from non-cloud PHP backgrounds.

About DEBT scoring →

Also Known As

PHP on AWS PHP serverless Bref ECS PHP

TL;DR

Deployment options for PHP on AWS, GCP, and Azure — EC2/VMs, containers (ECS, Cloud Run), serverless (Lambda via Bref), and PaaS (Elastic Beanstalk, App Engine).

Explanation

PHP cloud deployment options: EC2/VMs (full control, nginx + PHP-FPM, manual scaling), ECS/Fargate (containerised PHP-FPM, auto-scaling, no server management), Cloud Run/GCP (container on demand, scales to zero), Lambda + Bref (serverless PHP, pay per invocation, cold starts), Elastic Beanstalk/App Engine (PaaS, abstracts infrastructure). For most PHP web apps: ECS Fargate or Cloud Run offer the best balance — containers provide reproducibility, auto-scaling handles traffic spikes, and no server management is needed.

Common Misconception

Serverless PHP (Lambda/Bref) is always the cheapest option — cold starts add latency, and consistent traffic is cheaper on containers; serverless excels at spiky, unpredictable workloads.

Why It Matters

Choosing the right deployment model determines scaling behaviour, cost, and operational complexity — a PHP app deployed on EC2 with manual scaling will go down under traffic spikes that ECS would handle automatically.

Common Mistakes

  • PHP sessions on multiple EC2 instances without sticky sessions or Redis — session data lost on each request.
  • Local file storage on containers — containers are ephemeral; use S3 for file storage.
  • Not setting PHP-FPM worker count for container memory — match pm.max_children to available RAM.
  • Bref for long-running PHP processes — Lambda has a 15-minute timeout; use ECS for queue workers.

Code Examples

✗ Vulnerable
// PHP on EC2 with local file storage — breaks on scale:
$uploadPath = '/var/www/html/uploads/' . $filename;
move_uploaded_file($_FILES['file']['tmp_name'], $uploadPath);
// Works on single server
// Behind load balancer: uploaded file only on one server
// User request may hit different server — file not found
✓ Fixed
// PHP on ECS Fargate with S3 for files:
// Dockerfile: FROM php:8.3-fpm-alpine
// Files go to S3, not local filesystem:
$s3->putObject([
    'Bucket' => getenv('S3_BUCKET'),
    'Key'    => 'uploads/' . $filename,
    'Body'   => fopen($_FILES['file']['tmp_name'], 'r'),
]);
// Sessions in Redis — shared across all containers:
// session.save_handler = redis
// session.save_path = tcp://redis.internal:6379

Added 16 Mar 2026
Edited 22 Mar 2026
Views 50
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings T 2 pings W 1 ping T 0 pings F 0 pings S 1 ping S 0 pings M 0 pings T 0 pings W 2 pings T 1 ping F 1 ping S 5 pings S 6 pings M 0 pings T 0 pings W 0 pings T 1 ping F 0 pings S 1 ping S 0 pings M 0 pings T 0 pings W 0 pings T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 0 pings W
No pings yet today
No pings yesterday
Scrapy 12 Amazonbot 7 Perplexity 5 Ahrefs 4 Unknown AI 3 Google 3 SEMrush 3 Claude 2 ChatGPT 2 Bing 1 Meta AI 1 Majestic 1
crawler 39 crawler_json 4 pre-tracking 1
DEV INTEL Tools & Severity
🟡 Medium ⚙ Fix effort: High
⚡ Quick Fix
Use ECS Fargate with CodeDeploy blue/green — push Docker image to ECR, update task definition, CodeDeploy shifts traffic and rolls back automatically on health check failure
📦 Applies To
PHP 5.0+ web cli
🔗 Prerequisites
🔍 Detection Hints
Manual SSH deployment; no rollback mechanism; downtime during deployments; no smoke test before traffic switch
Auto-detectable: ✗ No aws-codedeploy ecs ecr terraform
⚠ Related Problems
🤖 AI Agent
Confidence: Low False Positives: Medium ✗ Manual fix Fix: High Context: File


✓ schema.org compliant