Cloud Service Selection and Cloud Architecture Best Practices: A Practical Guide

    This guide turns cloud service selection into a reusable engineering methodology. Instead of treating a vendor's marketing updates as the starting point, it shows you how to define requirements as measurable targets (QPS, latency, availability, capacity growth, compliance, budget), map them against five core categories of cloud resources, and then build the architecture up through a five-level path—from a single instance to multi-region disaster recovery. You will learn how to avoid common pitfalls (brand-first thinking, comparing unit price instead of TCO, confusing autoscaling with high availability), write reproducible and rollback-ready deployments, design health checks and graceful shutdown, build observability with the RED/USE methods and Little's Law, govern cloud cost, and meet security and compliance baselines. A final selection checklist ties every decision back to verifiable evidence. All product names are generic categories, so the framework applies to any cloud provider, including Baidu AI Cloud.

    Introduction: From Following Updates to Building Judgment

    The source material here is a minimal cloud-vendor “watch” page: a user follows a cloud provider on social media, and the activity feed shows “No activity yet.” Setting the specific brand aside, this fragment is worth a moment’s thought for any technical team. When developers start following a cloud vendor, the information entry point is usually marketing content and release notes on social platforms—yet real technology selection is rarely built on such fragments.

    Marketing material and release notes are not worthless: the arrival of new instance types, new regions, and new specifications can directly change architectural options and unit cost. But they cannot answer the questions that decide whether a system succeeds or fails:

    • Is the bottleneck of the current architecture in compute, storage, network, or the data tier?
    • What kind of redundancy does a given availability and latency target require?
    • How long does it take to detect a failure, and how long to recover?
    • How does cost change when traffic doubles?

    This article abstracts “cloud service selection” into a reusable technical methodology: first clarify requirements, then match them against capabilities, then build the architecture, and finally validate with data. Every product name below is a generic category, tied to no specific vendor, so you can use this framework to evaluate any cloud provider—including Baidu AI Cloud.

    1. Align on Concepts First: The Three-Layer Cloud Model

    Before discussing “selection,” let’s align on vocabulary. The industry generally splits the cloud technology stack into three layers:

    Layer Focus Typical generic capabilities
    IaaS (Infrastructure as a Service) Provisioning and isolation of compute, storage, and network resources Cloud servers, block storage, virtual private networks, load balancers
    PaaS (Platform as a Service) Managed middleware and runtimes that reduce environment operations Cloud databases, cache services, container platforms, message queues
    SaaS (Software as a Service) Ready-to-use application capabilities Collaboration suites, CRM and other business software

    The essence of cloud service selection is a trade-off between controllability and operational cost:

    • The lower the layer, the stronger your control over system details—and the more operational responsibility you carry.
    • The higher the layer, the faster you deliver—but the narrower the room for customization.

    This is not a matter of good versus bad, but of where the boundary of responsibility lies. The fundamental difference between a cloud provider and a traditional data-center provider is the shared responsibility model: the cloud provider operates the physical facilities, the virtualization layer, and the underlying operation of managed services; you always retain the operating system patching, application vulnerabilities, account permissions, and data backups. When core data is spread across managed services from multiple providers, you must also confirm they sit within the same jurisdiction and meet consistent data-compliance requirements. Many security incidents trace back to mistakenly handing all responsibility to the platform.

    2. Common Selection Pitfalls

    2.1 Pitfall 1: Substituting “Brand Recognition” for “Capability Fit”

    A well-known vendor usually offers a complete set of general capabilities, but project success is often decided by the details:

    • Is the required instance type available in the target region?
    • Is the target cloud database version compatible with the existing application?
    • How is outbound public-internet bandwidth billed?
    • Are ticket response and retry fallbacks in place during failures?

    A mismatch on any single dimension can cost you multiples during scaling or migration.

    2.2 Pitfall 2: Comparing Unit Price Instead of Total Cost of Ownership (TCO)

    A plan with the lowest headline price can see its actual bill pushed up by:

    • Cross-AZ, cross-region, and outbound public-internet traffic;
    • Long-term retention of snapshots and backups;
    • Storage of logs and monitoring data;
    • Services billed per request;
    • The labor spent repeatedly rehearsing a migration from an on-premises data center.

    Bring all foreseeable spending over a 2–3 year horizon into the comparison.

    2.3 Pitfall 3: Equating “Elasticity” with “Automatic High Availability”

    Autoscaling solves a capacity problem, not a single-point-of-failure problem. If the application is stateful, keeps sessions locally, and the database has only one instance, adding more instances cannot remove the single point—it only widens the failure surface.

    2.4 Pitfall 4: Copying Someone Else’s Architecture

    Another team’s design rests on their business characteristics: access patterns, peak rhythms, compliance requirements, team size. Copying an architecture out of context often means inheriting both its flaws and its redundancy.

    3. Requirements Profiling: Translating “Wants” into “Metrics”

    The starting point for selection is not a product catalog but business constraints. The table below converts vague desires into verifiable metrics:

    Dimension Questions to answer Verifiable output
    Access pattern Read-heavy or write-heavy? Any obvious peaks and troughs? Daily and peak QPS, bandwidth estimate
    Latency What is the end-to-end response target? Is jitter-sensitive? P95/P99 latency targets
    Availability How much does one hour of downtime cost? Can it degrade gracefully? Availability target and error budget
    Data Total volume, growth rate, hot/cold ratio, consistency requirements? Capacity growth curve and consistency level
    Compliance Which regions store the data? Is localized storage required? Data classification and list of deployment regions
    Team Is there dedicated operations staff? How many middleware systems can they maintain? Upper limit on the number of components
    Cost Is the budget a fixed cap or does it grow with the business? Monthly budget and unit-cost target

    For the availability target, use the industry-standard “number of nines,” mapped to maximum monthly downtime (over a 30-day month, rounded to the nearest second):

    Availability Max monthly downtime Typical architectural meaning
    99.9% ~43 minutes Redundancy within a single AZ
    99.95% ~22 minutes Multi-AZ deployment
    99.99% ~4 minutes Multi-AZ + fast failover and drills
    99.999% ~3 seconds Multi-region disaster recovery; cost and complexity rise sharply

    Once an SLO (service-level objective) is set, it should become the yardstick for failure drills and acceptance testing—not a slogan on the first page of a proposal.

    The requirements list can be structured into a configuration baseline, put under version control, and used as shared input for capacity planning, cost estimation, and architecture review:

    1. # service-baseline.yaml: service baseline shared by capacity planning and cost estimation
    2. service: order-service
    3. replicas: 6 # initial instance count
    4. availability_target: 99.95% # maps to multi-AZ deployment
    5. latency_p99_ms: 300
    6. capacity:
    7. qps_daily: 800 # daily peak QPS
    8. qps_forecast: 3000 # projected peak QPS during a major promotion
    9. payload_kb: 50 # request body size, used to estimate bandwidth
    10. data:
    11. growth_gb_per_month: 500 # monthly data growth
    12. consistency: read-after-write # consistency requirement
    13. budget:
    14. monthly_cap: 30000 # monthly budget cap (currency units)

    4. Cloud Capability Landscape: Five Core Resource Categories

    The general product lines of mainstream cloud providers usually fall into five categories. Understanding the capabilities and costs of each is the prerequisite for using the cloud well.

    4.1 Compute: Running the Business Logic

    Type Typical scenarios Key considerations
    Cloud servers Main application, self-managed middleware Whether the instance family matches the workload, whether live resizing is supported
    Bare metal servers HPC, specially licensed software Longer delivery time; less elastic than virtualized instances
    Container platforms Microservices, rapid releases Image size, resource quotas, and scaling policies need careful design
    Function compute Event-driven short tasks Cold starts, concurrency quotas, and single-execution time limits

    The most overlooked point in selection is the difference between instance families: compute-optimized, memory-optimized, and general-purpose instances offer different cost-performance per unit. Choose the instance type based on load-test data rather than nominal specs, and confirm the target type has ample stock in your chosen AZ.

    4.2 Storage: The Foundation of Data Persistence

    • Block storage: Mounted as the system or data disk of a cloud server, with low latency. Capacity, IOPS, and throughput may vary by disk type, and some types support expansion without downtime.
    • Object storage: Non-structured data storage accessed over HTTP, suited to images, videos, backups, and static assets. Pay attention to the request-based billing model, storage tiers, and lifecycle rules.
    • File storage: A shared file system that can be mounted by multiple instances simultaneously, suited to scenarios needing a shared directory. But when multiple application instances read and write the same file at once, contention easily arises; prefer a database or object storage for shared state.

    4.3 Network: Connectivity and the Traffic Entry Point

    • Virtual private network (VPC): The logically isolated network on the cloud, the foundation of all network planning.
    • Subnets and routing: Carving out subnets and defining routes determines which resources can reach the public internet.
    • Load balancing: Distributes traffic and probes backend health, supporting Layer-4 connection forwarding and Layer-7 request routing by domain and path.
    • Content delivery network (CDN): Caches static assets at edge nodes to reduce origin load.
    • Elastic public IP: A public address that can move between instances.

    One common and costly pitfall is treating a cloud server’s data disk as shared storage and mounting the same disk on multiple instances. A cloud disk can usually be attached to only one instance at a time; this design cannot scale throughput and also risks data contention.

    4.4 Data Services: Managed Middleware

    • Cloud database (relational): Managed high-availability primary/standby, automated backups, and failover.
    • Cache service: Reduces latency for hot-data reads.
    • Message queue: Asynchronous decoupling and traffic peak shaving.
    • Big data and analytics services: For offline computing and reporting.

    Managed services remove the operational burden of patching, backup, and failover, at the cost of tunable parameters being limited by version and configuration ranges. Read the “parameter limits” and “version support matrix” carefully, and avoid relying on unsupported features.

    4.5 Security and Operations: Governance and Observability

    • Access management: Sub-accounts, permission policies, and temporary credentials.
    • Key management: Centralized custody and rotation of sensitive configuration.
    • Log service: Centralized collection, search, and retention of logs.
    • Monitoring and alerting: Metric collection, threshold evaluation, and notifications.
    • Backup and disaster recovery: Snapshots, cross-region replication, and recovery drills.

    These capabilities generate no direct business value, but they determine whether failures can be detected and localized within minutes.

    5. Architecture Evolution: A Five-Level Path

    You don’t need to get there in one step. The following five levels can evolve step by step as the business matures, and each has clear applicability conditions and new cost items.

    5.1 L0: Single-Instance Deployment (Validation Phase)

    The application, database, and cache all run on one cloud server. Fastest to deploy and cheapest, but a failure in compute, storage, or network takes the whole service down. Suited only to internal tools, prototype validation, or workloads that tolerate long outages.

    5.2 L1: Separating Compute from Data (Early Stage)

    Move the database to a managed service, put user-uploaded files in object storage, and keep only stateless logic on the application servers.

    1. Users ──▶ App servers (1-2)
    2. ├──────▶ Cloud database
    3. └──────▶ Object storage (images, attachments, backups)

    This is the most cost-effective improvement. Once data is decoupled from compute nodes, application instances can be rebuilt or replaced at any time, and release rollbacks won’t drag the data along.

    5.3 L2: Load Balancing + Multi-AZ (Growth Stage)

    Place application instances across two or more AZs behind a load balancer, and deploy the database primary/standby across AZs. The load balancer automatically removes nodes that fail health checks.

    1. Users ──▶ Load balancer ──┬──▶ App instance A (AZ 1)
    2. ├──▶ App instance B (AZ 2)
    3. └──▶ App instance C (AZ 2)
    4. │
    5. ▼
    6. Cloud database (primary/standby across AZs)

    Reaching this level requires two prerequisites:

    1. The application is stateless: sessions are externalized to a cache service, files are written to object storage;
    2. Health checks truly reflect dependency state: probing only the TCP port cannot detect problems like an exhausted database connection pool.

    5.4 L3: Autoscaling + Asynchronous Decoupling (Scale Stage)

    Introduce an auto-scaling group that adds or removes instances based on CPU utilization, request count, or queue backlog. Handle non-real-time tasks asynchronously via a message queue.

    1. Clients ──▶ Load balancer ──▶ Auto-scaling group (scales on CPU / queue length)
    2. │
    3. ├──▶ Cache service (hot data)
    4. ├──▶ Message queue ──▶ Consumer group
    5. ├──▶ Cloud database (primary/standby + read replicas)
    6. └──▶ Object storage ──▶ CDN

    Here the queue acts as a “buffer pool”: when a traffic spike arrives, it enters the queue first, and consumers drain it at a pace they can handle, avoiding a database crushed by a sudden write surge. But a queue is only a buffer, not infinite capacity: if the production rate stays above the consumption rate, the backlog keeps growing, so you must set backlog alarms.

    5.5 L4: Multi-Region Disaster Recovery (Critical Workloads)

    For workloads with extremely high availability requirements, deploy an identical environment in a second region and shift traffic by weight through global traffic management.

    Three key constraints:

    • Cross-region data synchronization is asynchronous, so the RPO (tolerable data loss) is not zero;
    • Failover must be drilled regularly; an untested DR plan often fails in a real incident;
    • Two regions mean two sets of infrastructure costs, which must be weighed against the cost of downtime before deciding.

    5.6 Architecture Diagram and Deployment Checklist

    1. ┌─────────────────┐
    2. Clients ───────▶ │ CDN │ (static assets)
    3. └────────┬────────┘
    4. │ origin pull
    5. ┌────────▼────────┐
    6. │ Load balancer │ (public entry)
    7. └────────┬────────┘
    8. ┌───────────────┼───────────────┐
    9. ▼ ▼ ▼
    10. ┌─────────┐ ┌─────────┐ ┌─────────┐
    11. │ App A │ │ App B │ │ App C │
    12. │ AZ A │ │ AZ B │ │ AZ B │
    13. └────┬────┘ └────┬────┘ └────┬────┘
    14. └───────────────┼───────────────┘
    15. ▼
    16. ┌─────────┬─────────┬─────────┐
    17. ▼ ▼ ▼
    18. Cache Message Q Cloud DB (primary/standby across AZs)
    19. │
    20. ▼
    21. Object storage (backups)

    Companion conventions:

    1. #!/usr/bin/env bash
    2. # preflight.sh: environment and config checks before release; abort on any failure
    3. set -euo pipefail
    4. # 1. All config must come from env vars or a config center; no hard-coded values
    5. : "${DB_HOST:?missing database host config}"
    6. : "${APP_MODE:?missing run-mode config}"
    7. # 2. Verify the health check endpoint is reachable
    8. code=$(curl -s -o /dev/null -w '%{http_code}' "http://127.0.0.1:8080/healthz")
    9. [ "$code" = "200" ] || { echo "health check failed: $code" >&2; exit 1; }
    10. # 3. Verify enough free disk space (e.g., logs written to local disk)
    11. free_pct=$(df -P /var/log | awk 'NR==2 {gsub("%","",$5); print 100-$5}')
    12. [ "$free_pct" -ge 20 ] || { echo "insufficient disk space: ${free_pct}%" >&2; exit 1; }
    13. echo "preflight passed"

    6. Deployment and Release: Repeatable and Rollback-Ready

    6.1 Environment Consistency

    “It runs on my machine” is mostly a symptom of environment drift. In practice, follow three rules:

    1. Lock dependency versions;
    2. Externalize configuration as environment variables or a config center;
    3. Use the same image or system template for test and production environments.

    6.2 Graceful Shutdown

    When an instance is scaled in or updated, a process that is terminated immediately causes in-flight requests to fail. The standard approach: on receiving the termination signal, first stop accepting new requests, then drain in-flight requests, and finally exit.

    1. import signal
    2. import sys
    3. import threading
    4. stopping = threading.Event()
    5. def shutdown(signum, frame):
    6. # First drain traffic (detected via load balancer health checks), then wait for in-flight requests
    7. stopping.set()
    8. print(f"received signal {signum}, entering graceful shutdown", flush=True)
    9. signal.signal(signal.SIGTERM, shutdown)
    10. signal.signal(signal.SIGINT, shutdown)
    11. # Pseudocode: the main loop must check `stopping` and exit once in-flight requests finish
    12. while not stopping.is_set():
    13. handle_one_request()
    14. print("in-flight requests done, process exiting", flush=True)
    15. sys.exit(0)

    Working with the release flow, the order for taking an instance offline should be:

    1. Remove it from the load balancer;
    2. Wait until health checks have failed for the threshold number of consecutive attempts;
    3. Wait for in-flight requests to finish;
    4. Terminate the process.

    Reversing this order means draining traffic and terminating the process happen at the same time, causing request failures.

    6.3 Health Check Endpoint

    Health checks should distinguish “liveness” from “readiness”: when liveness fails, the instance is restarted; when readiness fails, the instance is temporarily removed from traffic. Below is a readiness probe using only the standard library:

    1. import json
    2. from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
    3. class Probe(BaseHTTPRequestHandler):
    4. def do_GET(self):
    5. if self.path == "/healthz":
    6. # A real implementation should check dependencies such as the DB connection pool and queues
    7. body = json.dumps({"status": "ok"}).encode()
    8. self.send_response(200)
    9. self.send_header("Content-Type", "application/json")
    10. self.send_header("Content-Length", str(len(body)))
    11. self.end_headers()
    12. self.wfile.write(body)
    13. else:
    14. self.send_response(404)
    15. self.end_headers()
    16. def log_message(self, *args):
    17. pass # avoid probe logs drowning out application logs
    18. # Bind only to a private address so the probe endpoint is not exposed to the public internet
    19. ThreadingHTTPServer(("10.0.0.10", 8080), Probe).serve_forever()

    In production, implement this with a proper web framework. The probe endpoint should meet at least two conditions: bind only to a private address, and sample or rate-limit probe logs.

    6.4 Batched Release and Fast Rollback

    Before releasing, be clear on three things:

    • Batches: no more than one-third of the total instances per batch, observing error rate and P99 latency between batches;
    • Keep a buffer: retain at least one batch of old-version instances until the new version is stable;
    • Rollback-ready: keep the previous version of the image or artifact, and rehearse the rollback procedure in advance.
    1. #!/usr/bin/env bash
    2. # rolling_release.sh: release in batches; stop if any batch fails its health check
    3. set -euo pipefail
    4. TOTAL=6 # total number of instances
    5. BATCH=2 # instances per batch
    6. BATCH_NO=0
    7. i=0
    8. while [ "$i" -lt "$TOTAL" ]; do
    9. end=$(( i + BATCH ))
    10. [ "$end" -gt "$TOTAL" ] && end=$TOTAL
    11. BATCH_NO=$(( BATCH_NO + 1 ))
    12. echo "[batch $BATCH_NO] updating instances $((i+1))~$end"
    13. for host in $(printf "10.0.1.%d\n" $(seq $((i+1)) "$end")); do
    14. ssh -o StrictHostKeyChecking=yes "$host" "sudo ./deploy.sh"
    15. done
    16. # Verify each new instance reaches ready state
    17. for host in $(printf "10.0.1.%d\n" $(seq $((i+1)) "$end")); do
    18. curl -fsS "http://$host:8080/healthz" >/dev/null
    19. done
    20. sleep 30 # observation window between batches
    21. i=$end
    22. done
    23. echo "release complete; old-version instances kept until the observation period ends"

    7. Observability: Making Failures Visible

    Without observability, failure detection depends on user complaints. The industry typically builds it across three layers:

    Layer Content Typical use
    Metrics Request rate, error rate, latency distribution, saturation Alerting and capacity planning
    Logs Structured application logs, access logs, audit logs Failure localization and traceability
    Traces The call chain of a single request across services Locating cross-component bottlenecks

    For metric collection, follow the RED method:

    • Rate: number of requests per unit time;
    • Errors: number of failed requests;
    • Duration: latency distribution, at minimum P95 and P99.

    At the resource layer, add the USE method:

    • Utilization: CPU, memory, disk, and bandwidth utilization;
    • Saturation: queue length, connection count, thread-pool usage;
    • Errors: hardware and system errors.

    Alert design has three principles:

    1. Tiered: P0 triggers an immediate phone alert, P1 is handled during working hours, P2 goes into a daily report;
    2. Actionable: every alert spells out the response action, avoiding “received but no idea what to do”;
    3. Storm-proof: alerts derived from the same root cause should be suppressed and merged.

    For capacity estimation, apply Little’s Law. The average number of concurrent requests in a system is roughly the product of the request arrival rate and the average processing time: at a peak of 1000 QPS with an average processing time of 50 ms, steady-state concurrency is about 50. Add a 1.5–2x buffer and a burst factor, and you can estimate the required instance count and database connection-pool size—avoiding guesswork.

    8. Cost Governance: Making the Bill Explainable

    Cost overruns usually aren’t a unit-price problem, but “no one owns the resource lifecycle.” Establish three mechanisms:

    1. Tagging: tag resources with business, environment, and owner labels, aggregate the bill by tag, and make cost attribution clear;
    2. Budget alerts: set a monthly budget per project and notify ahead of the threshold, rather than discovering it when the bill arrives at month’s end;
    3. Regular audits: check each week for idle instances, unattached cloud disks, unreferenced snapshots, expired logs, and default-open public ports.

    For optimization order, handle “waste” first, then “efficiency”:

    1. Scale down or reclaim long-term low-load resources (e.g., instances with CPU consistently below 10%);
    2. Tier storage and apply lifecycle rules, moving cold data to infrequently accessed tiers;
    3. Consolidate small instances to reduce management overhead;
    4. Choose a long-term payment model for stable baseline load and keep the elastic portion on-demand;
    5. Front static assets with a CDN to reduce origin bandwidth consumption;
    6. Use preemptible or spot instances for latency-insensitive tasks, but implement checkpointing to resume from where they stopped.

    One point is often overlooked: each level up the architecture ladder improves availability and elasticity, but unit compute cost may also rise. So cost optimization should not compromise redundancy; it should find the lowest-cost solution under the given availability target.

    9. Security and Compliance Baseline

    • Least privilege: authorize sub-accounts by role; forbid long-term sharing of the primary account’s credentials;
    • Temporary credentials: use short-lived credentials when programs access cloud resources; rotate keys regularly and keep them in centralized custody;
    • Network isolation: assign no public IP to application instances; expose only the necessary ports through the load balancer;
    • Data encryption: use TLS in transit and enable storage-side encryption for data at rest;
    • Audit trail: centrally retain login, permission-change, and key-access events for a period that meets compliance requirements;
    • Recoverable backups: a backup is only valuable if it can be restored. Regularly extract backups for real recovery drills, and verify RTO and RPO.

    10. Selection Checklist

    Before making a decision, confirm each item below:

    • Requirements are quantified into verifiable metrics such as QPS, latency, availability, and capacity growth;
    • The target instance type and database version are available in the target region and validated by load testing;
    • The architecture spans at least two AZs; single points are identified and have a mitigation plan;
    • The application is stateless; sessions and files are externalized;
    • Health checks truly reflect dependency state, and the drain/terminate order is correct;
    • Releases support batches and rollback, and the rollback procedure has been rehearsed;
    • Metrics, logs, and traces are all in place, and alerting is tiered and actionable;
    • Cost is aggregated by tag, and budget alerts are configured;
    • Permissions follow least privilege, keys are not committed to the codebase, and backup recovery has been verified.

    Conclusion

    Return to the opening scenario: following a cloud vendor’s updates isn’t a bad thing—but it’s only the starting point. What truly determines system quality is the ability to translate business requirements into metrics, translate metrics into architecture, and turn architecture into a repeatable engineering process. The cloud is a means, not an end; the endpoint of selection is not “which cloud you use” but “delivering a stable service continuously, in a verifiable way, at a controlled cost.”