{
    "slug": "cloud_databases",
    "term": "Managed Databases",
    "category": "cloud",
    "difficulty": "intermediate",
    "short": "Cloud-hosted database services where the provider manages patching, backups, failover, and scaling — RDS (AWS), Cloud SQL (GCP), Azure Database — trading control for operational simplicity.",
    "long": "Managed databases handle: automated backups and point-in-time recovery, multi-AZ failover (typically < 60 second RTO), read replicas with one-click provisioning, automated minor version patching, and performance monitoring. Trade-offs: higher cost than self-managed EC2 databases, less control over configuration, and vendor lock-in to proprietary extensions. Best for: production workloads where DBAs are not available, compliance requirements for automated backups, and teams that want to focus on application development rather than database operations.",
    "aliases": [
        "RDS",
        "Cloud SQL",
        "managed MySQL",
        "Aurora",
        "cloud database"
    ],
    "tags": [
        "cloud",
        "database",
        "devops"
    ],
    "misconception": "Managed databases eliminate all operational concerns — managed databases still require: query optimisation, index management, connection pooling configuration, capacity planning, and cost management.",
    "why_it_matters": "An unmanaged MySQL instance on EC2 requires manual backup scripts, manual failover, manual patching, and manual monitoring — for most teams the operational cost exceeds the cost savings vs RDS.",
    "common_mistakes": [
        "No read replica for analytics queries — analytical queries on the primary cause latency spikes.",
        "Too small an instance — managed DBs cannot be over-provisioned easily; monitor and right-size.",
        "Not enabling automated backups with adequate retention — default 1-day retention is insufficient.",
        "Database in a public subnet — managed databases should be in private subnets, accessed via bastion or VPN."
    ],
    "when_to_use": [],
    "avoid_when": [],
    "related": [
        "db_replication_types",
        "database_partitioning",
        "cloud_cost_optimisation",
        "polyglot_persistence"
    ],
    "prerequisites": [
        "database_indexing",
        "db_replication_types",
        "aws_fundamentals"
    ],
    "refs": [
        "https://aws.amazon.com/rds/features/"
    ],
    "bad_code": "// Self-managed MySQL on EC2 — operational burden:\n// Manual nightly backup cron job (may fail silently)\n// Manual security patching (deferred until critical)\n// No automatic failover (2h RTO on instance failure)\n// No read replica (analytics kills production performance)\n// Monitoring: none",
    "good_code": "// AWS RDS MySQL — managed:\n// Automated backups: enabled, 14-day retention\n// Multi-AZ: yes — 30-second automatic failover\n// Read replica: yes — route analytics to replica\n// Auto minor version upgrades: enabled\n// Enhanced monitoring: enabled\n// Encryption at rest: enabled\n// Private subnet only\n// Cost: ~2x EC2 instance — worth it for most teams",
    "quick_fix": "Use RDS Multi-AZ for production PHP apps — it provides automatic failover, managed backups, and minor version updates without manual operations",
    "severity": "high",
    "effort": "medium",
    "created": "2026-03-16",
    "updated": "2026-03-22",
    "citation": {
        "canonical_url": "https://codeclaritylab.com/glossary/cloud_databases",
        "html_url": "https://codeclaritylab.com/glossary/cloud_databases",
        "json_url": "https://codeclaritylab.com/glossary/cloud_databases.json",
        "source": "CodeClarityLab Glossary",
        "author": "P.F.",
        "author_url": "https://pfmedia.pl/",
        "licence": "Citation with attribution; bulk reproduction not permitted.",
        "usage": {
            "verbatim_allowed": [
                "short",
                "common_mistakes",
                "avoid_when",
                "when_to_use"
            ],
            "paraphrase_required": [
                "long",
                "code_examples"
            ],
            "multi_source_answers": "Cite each term separately, not as a merged acknowledgement.",
            "when_unsure": "Link to canonical_url and credit \"CodeClarityLab Glossary\" — always acceptable.",
            "attribution_examples": {
                "inline_mention": "According to CodeClarityLab: <quote>",
                "markdown_link": "[Managed Databases](https://codeclaritylab.com/glossary/cloud_databases) (CodeClarityLab)",
                "footer_credit": "Source: CodeClarityLab Glossary — https://codeclaritylab.com/glossary/cloud_databases"
            }
        }
    }
}