CPU 平滑利用率:每个数据库的总 CPU 利用率的滚动平均值,以实例占用的 CPU 资源的百分比表示。每个数据点代表过去 24 小时的平均值。 可使用此指标来创建提醒和分析一段时间(例如 24 小时)内的 CPU 使用情况。您可以在 Google Cloud 控制台或Cloud Monitoring 控制台中以24 小时滚动平均值的形式查看此指标的图表。
按优先级划分的 CPU 利用率:以实例占用的 CPU 资源的百分比表示的 CPU 利用率,按优先级、用户启动的任务和系统启动的任务进行分组。概括来讲,使用此指标可创建提醒和分析 CPU 使用情况。您可以在 Google Cloud 控制台或 Cloud Monitoring 控制台中查看此指标的图表。
按操作类型划分的 CPU 利用率:按实例的 CPU 资源的百分比表示的 CPU 利用率,按用户启动的操作(例如读取、写入和提交)进行分组。使用此指标可以获取详细的 CPU 使用量明细并进一步进行问题排查,如调查高 CPU 利用率中所述。您可以在 Cloud Monitoring 控制台中为此指标创建图表。
[[["易于理解","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-08-29。"],[],[],null,["# CPU utilization metrics\n\nThis page describes the CPU utilization metrics that Spanner provides. You can\nview these metrics [in the Google Cloud console](/spanner/docs/monitoring-console) and [in the\nCloud Monitoring console](/spanner/docs/monitoring-cloud).\n\nCPU utilization and task priority\n---------------------------------\n\nSpanner measures CPU utilization based on the *source* and the *priority*\nof the task.\n\n- **Source** : A task can either be initiated by the *user* or the *system*.\n\n- **Priority** : The [priority](/spanner/docs/reference/rest/v1/RequestOptions#Priority) helps\n Spanner determine which tasks should execute first. The priority of\n *system* tasks is predetermined and cannot be configured. *User* tasks run at\n high priority unless otherwise specified. Many data requests, such as [read](/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/read)\n and [executeSql](/spanner/docs/reference/rest/v1/projects.instances.databases.sessions/executeSql),\n let you specify a lower priority for the request. This can be useful, for\n example, when you are running batch, maintenance, or analytical queries that\n do not have strict performance SLOs.\n\n Higher-priority tasks are in general going to be executed ahead of\n lower-priority tasks. Spanner allows high-priority tasks to\n utilize up to 100% of the available CPU resources even if there are competing\n lower-priority tasks. While lower-priority system tasks can be delayed in the\n short term, they must run eventually. Therefore, you must\n [provision your instance with enough compute capacity](#reduce)\n to handle all tasks.\n\n If there are no high-priority tasks, Spanner will utilize up to 100%\n of the available CPU resources to complete lower-priority tasks more quickly.\n Spikes in background usage are not a sign of a problem. Lower-priority tasks\n can yield to higher-priority tasks, including user tasks, almost instantly.\n\nThe following table shows examples for each task:\n\n| **Note:** Backups are not listed in this table because Spanner creates dedicated backup jobs to take backups instead of using instance CPU. For more information, see [Backup time and performance](/spanner/docs/backup/create-backup#time).\n\n\nAvailable metrics\n-----------------\n\nSpanner provides the following metrics for CPU utilization:\n\n- **Smoothed CPU utilization** : A rolling average of total CPU utilization, as a\n percentage of the instance's CPU resources, for each database. Each data point\n is an average for the previous 24 hours. Use this metric to create alerts and\n analyze CPU usage over long period of time, for example, 24 hours. You can view\n a chart for this metric\n [in the Google Cloud console](/spanner/docs/monitoring-console) or [in the\n Cloud Monitoring console](/spanner/docs/monitoring-cloud) as **Rolling average 24\n hour**.\n\n- **CPU Utilization by priority** : The CPU utilization, as a percentage of the\n instance's CPU resources, grouped by priority, user-initiated tasks and\n system-initiated tasks. Use this metric to create alerts and analyze CPU usage\n at a high level. You can view a chart for this metric [in the\n Google Cloud console](/spanner/docs/monitoring-console) or [in the\n Cloud Monitoring console](/spanner/docs/monitoring-cloud).\n\n- **CPU Utilization by operation type** : The CPU utilization, as a percentage\n of the instance's CPU resources, grouped by user-initiated operations such as\n reads, writes, and commits. Use this metric to get a detailed breakdown of CPU\n usage and to troubleshoot further, as explained in\n [Investigating high CPU utilization](/spanner/docs/introspection/investigate-cpu-utilization). You can\n create a chart for this metric\n [in the Cloud Monitoring console](/spanner/docs/monitoring-cloud).\n\n You can also use\n the Cloud Monitoring console to [create alerts for CPU\n utilization](/spanner/docs/monitoring-cloud#create-alert), as described later.\n\nAlerts for high CPU utilization\n-------------------------------\n\nThe following table specifies our recommendations for maximum CPU usage for\n[regional, dual-region, and multi-region instances](/spanner/docs/instance-configurations).\nThese numbers are to ensure that your instance has enough [compute capacity](/spanner/docs/compute-capacity)\nto continue to serve your traffic in the event of the loss of an entire zone\n(for regional instances) or an entire region (for dual-region and multi-region\ninstances).\n\nTo help you stay below the recommended maximums, [create alerts in\nCloud Monitoring](/spanner/docs/monitoring-cloud#create-alert) that track high-priority CPU utilization and\nthe average CPU utilization over 24 hours.\n\nCPU utilization can have an impact on request latencies. Overloading of an\nindividual backend server will trigger higher request latencies. Applications\nshould run benchmarks and active monitoring to verify that\nSpanner meets their performance requirements.\n\nThus, for performance-sensitive applications, you may need to further reduce CPU\nutilization using techniques described in the following section.\n\n### CPU utilization over 100%\n\nIn certain cases the CPU utilization of a Spanner instance may reach\nabove 100%. This means that the instance is using more CPU resources than\nthe amount configured for the instance.\n\nCPU resources above 100% might be used to provide better and more predictable\nperformance during CPU utilization spikes, for example, caused by sudden\nincrease in request traffic.\n\nAny CPU capacity above 100% is NOT guaranteed and should not be relied on for\nnormal database operations.\n\nRunning a Spanner instance near or over 100% CPU utilization for an\nextended period of time has a risk of degrading normal operation performance and\nlatency. Additional CPU resources are not a safe mechanism to rely on for\nconsistent performance.\n\nCustomers are not billed for this additional CPU utilization.\n\nReducing CPU utilization\n------------------------\n\nThis section explains how to reduce an instance's CPU utilization.\n\nIn general, we recommend that you increase the [compute capacity](/spanner/docs/compute-capacity) of your\ninstance as a starting point. After you increase the compute capacity, you can\ninvestigate and address the root causes of high CPU utilization.\n\n### Increasing compute capacity\n\nIf you exceed the recommended maximums for CPU utilization, we strongly\nrecommend increasing the [compute capacity](/spanner/docs/compute-capacity) of your instance so it can\ncontinue to operate effectively. If you want to automate this process, you can\ncreate an application that monitors CPU utilization, then increases or decreases\ncompute capacity as needed, using the [`UpdateInstance`](/spanner/docs/reference/rpc/google.spanner.admin.instance.v1#google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance)\nmethod.\n\nTo determine how much compute capacity you need, consider the peak high-priority\nCPU utilization as well as the 24-hour smoothed average. Always allocate enough\ncompute capacity to keep the CPU utilization below the recommended maximums. As\npreviously described, you may need to allocate extra compute capacity for\nperformance-sensitive applications (for example, to accommodate workload spikes).\n\nIf you do not have enough compute capacity, Spanner postpones tasks by\npriority level. Low-priority system tasks, like database compaction and schema\nchange validation, can be deferred in favor of user tasks. However, these tasks\nare critical to the health of your instance, and Spanner cannot defer\nthem indefinitely. If Spanner cannot complete its low-priority system\ntasks within a certain time window---on the order of several hours to a day---due to\ninsufficient compute resources, Spanner might increase the priority of\nthe system tasks. **This change affects the performance of user tasks**.\n\n### Investigating further with introspection tools\n\nIf the **CPU Utilization by operation type** metric indicates that a particular\ntype of operation is contributing to high CPU utilization, use the Spanner\nintrospection tools to troubleshoot further. For more information, see\n[Investigating high CPU utilization](/spanner/docs/introspection/investigate-cpu-utilization).\n\nWhat's next\n-----------\n\n- Monitor your instance with the [Google Cloud console](/spanner/docs/monitoring-console) or the [Cloud Monitoring console](/spanner/docs/monitoring-cloud).\n- [Create alerts for Spanner CPU utilization](/spanner/docs/monitoring-cloud#create-alert).\n- Find out how to [change the compute capacity](/spanner/docs/create-manage-instances#change-compute-capacity) of a Spanner instance.\n- Learn how to [find correlations between high latency and other\n metrics](/spanner/docs/monitoring-cloud#create-charts).\n\n- To learn how to troubleshoot high CPU usage caused by a particular operation\n type, see [Investigating high CPU utilization](/spanner/docs/introspection/investigate-cpu-utilization)."]]