[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-03。"],[[["\u003cp\u003eRegional Persistent Disk and Hyperdisk Balanced High Availability offer synchronous data replication between two zones, ensuring high availability by mitigating data loss from a single zonal failure.\u003c/p\u003e\n"],["\u003cp\u003eDesigning HA services requires careful consideration of application, file system, and operating system characteristics, particularly crash tolerance, to determine the best-suited storage solution.\u003c/p\u003e\n"],["\u003cp\u003eChoosing between synchronous application replication, asynchronous application replication, or synchronous disk replication with Regional Persistent Disk or Hyperdisk Balanced High Availability involves trade-offs in cost, performance, and resiliency, which should be evaluated based on specific needs.\u003c/p\u003e\n"],["\u003cp\u003eSynchronous disk replication using Regional Persistent Disk or Hyperdisk Balanced High Availability can reduce maintenance costs by automatically writing data to two replicas without the need for application-level replication, and the failover time is bounded.\u003c/p\u003e\n"],["\u003cp\u003eHealth checks play a critical role in managing high availability setups by monitoring VM instances and making failover decisions, requiring a control plane in a separate zone to ensure fault tolerance.\u003c/p\u003e\n"]]],[],null,["# Build HA services using synchronously replicated disks\n\n*** ** * ** ***\n\nRegional Persistent Disk and Hyperdisk Balanced High Availability are storage options that let you implement high availability (HA) services in Compute Engine. Regional Persistent Disk and Hyperdisk Balanced High Availability synchronously replicate data between two zones in the same region and ensure HA for disk data for up to one zonal failure.\n\nBuilding high availability services with regional disks\n-------------------------------------------------------\n\nThis section explains how you can build HA services with\nregional Persistent Disk or\nHyperdisk Balanced High Availability disks.\n\n### Design considerations\n\nBefore you start designing a HA service, understand the characteristics\nof the application, the file system, and the operating system. These\ncharacteristics are the basis for the design and can rule out various\napproaches. For example, if an application does not support application-level\nreplication, some corresponding design options are not applicable.\n\nSimilarly, if the application, the file system, or the operating system are not\ncrash tolerant, then using\nregional Persistent Disk or\nHyperdisk Balanced High Availability disks, or even zonal disk snapshots, might not be\nan option. *Crash tolerance* is defined as the ability to recover from an\nabrupt termination without losing or corrupting data\nthat was already committed to a disk prior to the crash.\n\nConsider the following when designing for high availability:\n\n- The effect on the application of using Hyperdisk Balanced High Availability, regional Persistent Disk, or other solutions.\n- Disk write performance.\n- The service recovery time objective - how quickly your service must recover from a zonal outage and the SLA requirements.\n- The cost to build a resilient and reliable service architecture.\n- For more information about region-specific considerations, see [Geography and regions](/docs/geography-and-regions#regions_and_zones).\n\n\u003cbr /\u003e\n\nIn terms of cost, use the following options for synchronous and\nasynchronous application replication:\n\n- **Use two instances of the database and VM.** In this case the following\n items determine the total cost:\n\n - VM instance costs\n - Persistent Disk or Hyperdisk costs\n - Costs of maintaining application replication\n- **Use a single VM with synchronously replicated disks.** To achieve high\n availability with a\n regional\n Persistent Disk or Hyperdisk Balanced High Availability disk, use the same VM instance\n and disk components as the previous option, but also include a synchronously\n replicated disk.\n Regional Persistent Disks and Hyperdisk Balanced High Availability disks are double the\n cost per byte compared to zonal disks because they are replicated in two\n zones.\n\n However, using synchronously replicated disks might reduce\n your maintenance cost because the data is automatically written to two\n replicas without the requirement of maintaining application replication.\n- **Don't start the secondary VM until failover is required.** You can reduce\n host costs even more by starting the secondary VM only on demand during\n failover rather than maintaining the VM as an active standby VM.\n\n### Compare cost, performance, and resiliency\n\nThe following table highlights the trade-offs in cost, performance, and\nresiliency for the different service architectures.\n\n^\\*^ Using regional disks or snapshots is not sufficient to protect from and mitigate against failures and corruptions. Your application, file system, and possibly other software components must be crash consistent or use some sort of [quiescing](https://wikipedia.org/wiki/Quiesce).\n^†^ The replication of some applications provides\nmitigation against some application corruptions. For example, MySQL primary\napplication corruption doesn't cause its replica VM instances to become\ncorrupted as well. Review your application's documentation for details.\n\n^‡^ Data loss means unrecoverable loss of data\ncommitted to persistent storage. Any non-committed data is still lost.\n\n^#^ Failover performance doesn't include file system check and application recovery and load after failover.\n\nBuilding HA database services using regional disks\n--------------------------------------------------\n\nThis section covers high level concepts for building HA solutions\nfor stateful database services (MySQL, Postgres, etc.) using\nCompute Engine with\n\nRegional Persistent Disks and Hyperdisk Balanced High Availability disks.\n\nIf there are broad outages in Google Cloud, for example, if a whole region\nbecomes unavailable, your application might become unavailable. Depending on\nyour needs, consider\n[cross-regional replication techniques](/architecture/disaster-recovery#how_to_leverage_zones_and_regions_to_achieve_reliability)\nor\n[Asynchronous Replication](/compute/docs/disks/async-pd/about)\nfor even higher availability.\n\nDatabase HA configurations typically have at least two VM instances. Preferably\nthese VM instances are part of one or more managed instance groups:\n\n- A primary VM instance in the primary zone\n- A standby VM instance in a secondary zone\n\nA primary VM instance has at least two disks: a boot disk, and a\nregional disk. The regional disk contains database data and any other mutable\ndata that should be preserved to another zone in case of an outage.\n\nA standby VM instance requires a separate boot disk to be able to recover from\nconfiguration-related outages, which could result from an operating system\nupgrade, for example. Also, you can't force attach a boot disk to another\nVM during a failover.\n\nThe primary and standby VM instances are configured to use a load balancer with\nthe traffic directed to the primary VM based on health check signals. The\n[disaster recovery scenario for data](/solutions/dr-scenarios-for-data)\noutlines other failover configurations, which might be more appropriate for\nyour scenario.\n\n### Challenges with database replication\n\nThe following table lists some common challenges with setting up and managing\napplication synchronous or semi-synchronous replication (like MySQL) and how\nthey compare to synchronous disk replication with\nRegional Persistent Disk\nand Hyperdisk Balanced High Availability disks.\n\nSequence of read and write operations to disks\n----------------------------------------------\n\nIn determining the read and write sequences, or the order in which data is read\nfrom and written to disk, the majority of the work is done by the disk driver in\nyour VM. As a user, you don't have to deal with the replication semantics, and\ncan interact with the file system as usual. The underlying driver handles the\nsequence for reading and writing.\n\nBy default, a Compute Engine VM with\nRegional Persistent Disk or\nHyperdisk Balanced High Availability operates in full replication mode, where requests\nto read or write from disk are sent to both replicas.\n\nIn full replication mode, the following occurs:\n\n- When writing, a write request tries to write to both replicas and acknowledges when both writes succeed.\n- When reading, the VM sends a read request to both replicas, and returns the results from the one that succeeds. If the read request times out, another read request is sent.\n\nIf a replica falls behind or fails to acknowledge that the read or write\nrequests completed, then the\n[replica state](/compute/docs/disks/about-regional-persistent-disk#zonal_replica_state)\nis updated.\n\nHealth checks\n-------------\n\nThe [health checks](/compute/docs/load-balancing/health-checks) used by the\nload balancer are implemented by the health check agent. The health check agent\nserves two purposes:\n\n1. The health check agent resides within the primary and secondary VMs to monitor the VM instances and communicate with the load balancer to direct traffic. This works best when configured with [instance groups](/compute/docs/instance-groups/creating-groups-of-managed-instances#monitoring_groups).\n2. The health check agent syncs with the application-specific regional control plane and makes failover decisions based on control plane behavior. The control plane must be in a zone that differs from the VM instance whose health it is monitoring.\n\nThe health check agent itself must be fault tolerant. For example, notice that,\nin the image that follows, the control plane is separated from the primary VM\ninstance, which resides in zone `us-central1-a`, while the standby VM resides\nin zone `us-central1-f`.\n\n\n*The health check agent's role in primary and standby\nVM instances.*\n\n\u003cbr /\u003e\n\nWhat's next\n-----------\n\n- Learn how to [create and manage regional disks](/compute/docs/disks/regional-persistent-disk).\n- Learn about [Asynchronous Replication](/compute/docs/disks/async-pd/about).\n- Learn how to [configure a SQL Server failover cluster instance for disks in multi-writer mode](/compute/docs/instances/sql-server/configure-failover-cluster-instance-pd-multi-writer).\n- Learn how to [build scalable and resilient web applications on Google Cloud](/architecture/scalable-and-resilient-apps).\n- Review the [disaster recovery planning guide](/architecture/dr-scenarios-planning-guide)."]]