1. A small startup is launching an internal scheduling microservice that runs 5-minute background tasks triggered by Cloud Scheduler every hour. The tasks process in-memory data, take approximately 30 seconds to execute, and have variable resource requirements. Which compute solution is most cost-effective?
- A. Compute Engine with a single n1-standard-1 instance running continuously
- B. Cloud Functions with a 512 MB memory allocation and 60-second timeout✓ Correct
- C. GKE cluster with a single node for containerized workload management
- D. Cloud Run deployed as a service scaled to zero replicas when idle
Explanation
Cloud Functions is the best choice because the workload is short-lived (30 seconds), triggered on a schedule, and doesn't require constant availability. You pay only for execution time (0.1-second granularity), making it extremely cost-efficient for sporadic tasks. Cloud Run would work but requires at least one warm instance by default and higher memory overhead. Compute Engine with a continuously running instance wastes money since the task only runs 1 hour per day (60 minutes of compute vs. ~30 seconds of actual work). GKE adds unnecessary orchestration complexity and cost for a simple scheduled task.