平滑化された CPU 使用率: データベースごとに、合計 CPU 使用率の稼働平均をインスタンスの CPU リソースの割合(%)で表したものです。各データポイントは過去 24 時間の平均を表します。この指標を使用して、アラートを作成し、24 時間などの長時間にわたって CPU 使用率を分析します。この指標のグラフは、 Google Cloud コンソールまたは Cloud Monitoring コンソールの 24 時間の稼働平均で確認できます。
CPU 使用率(優先度別): インスタンスの CPU リソースに占める CPU 使用率の割合で、優先度、ユーザー開始のタスク、システム開始のタスクでグループ化されています。この指標を使用して、アラートを作成し、CPU 使用率を概要レベルで分析します。この指標のグラフは、Google Cloud コンソールまたは Cloud Monitoring コンソールで確認できます。
オペレーションの種類ごとの CPU 使用率: ユーザーが開始したオペレーション(読み取り、書き込み、commit など)でグループ化し、その CPU 使用率をインスタンスの CPU リソースの割合(%)で表したものです。高 CPU 使用率の調査の説明に従い、この指標を使用して、CPU 使用率の詳細な内訳を取得し、さらにトラブルシューティングします。この指標のグラフは Cloud Monitoring コンソールで作成できます。
CPU 使用率は、リクエストのレイテンシに影響する可能性があります。個々のバックエンド サーバーが過負荷状態になると、リクエストのレイテンシが大きくなります。アプリケーションでベンチマークとアクティブなモニタリングを実行することによって、Spanner がパフォーマンス要件を満たしていることを確認する必要があります。
したがって、パフォーマンスの影響が大きいアプリケーションでは、次のセクションで説明する手法を使用して CPU 使用率をさらに低下させる必要がある場合があります。
CPU 使用率の 100% 超過
Spanner インスタンスの CPU 使用率が 100% を超えることがあります。これは、インスタンスで構成されている量よりも多くの CPU リソースがインスタンスで使用されていることを意味します。
CPU リソースの使用率が 100% を超えると、CPU 使用率の急増時(たとえば、リクエスト トラフィックの急激な増加時)にパフォーマンスが向上し、予測可能性が高まることがあります。
CPU 容量の使用率が 100% を超えることは保証されません。通常のデータベース オペレーションでは当てにしないでください。
Spanner インスタンスの CPU 使用率が長時間 100% に近い値になるか、100% を超えると、通常のオペレーションのパフォーマンスとレイテンシが低下するリスクがあります。CPU リソースを追加しても、一貫したパフォーマンスを安全に確保することはできません。
このような CPU 使用率の増加分については、お客様に課金されません。
CPU 使用率の低下
このセクションでは、インスタンスの CPU 使用率を低下させる方法について説明します。
一般に、まずインスタンスのコンピューティング容量を増やすことをおすすめします。コンピューティング容量を増やしたら、高 CPU 使用率の根本原因を調べて対処します。
コンピューティング容量の増加
推奨される CPU 使用率の最大値を超える場合は、インスタンスのコンピューティング容量を増加して、インスタンスが引き続き効率よく動作するようにすることを強くおすすめします。このプロセスを自動化する場合は、UpdateInstance メソッドを使用して CPU 使用率をモニタリングし、必要に応じてコンピューティング容量を増加または減少するアプリケーションを作成できます。
必要なコンピューティング容量を判断するには、優先度の高い CPU 使用率のピークと 24 時間の平滑化された平均の両方を考慮します。CPU 使用率が推奨最大値を常に下回るように、十分なコンピューティング容量を割り当ててください。上記のとおり、パフォーマンスの影響が大きいアプリケーションでは、(ワークロードの急激な増加に対応するなどの目的で)ノードを余分に割り当てる必要がある場合があります。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-09-05 UTC。"],[],[],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)."]]