우선순위: 우선순위에 따라 Spanner는 먼저 실행할 태스크를 결정할 수 있습니다. 시스템 태스크의 우선순위는 미리 결정되며 구성할 수 없습니다. 사용자 태스크는 특별히 언급되지 않은 한 높은 우선순위로 실행됩니다. read 및 executeSql과 같은 많은 데이터 요청을 통해 해당 요청에 대해 낮은 우선순위를 지정할 수 있습니다. 예를 들어 이것은 성능 SLO가 엄격하지 않은 일괄 처리, 유지보수, 분석 쿼리를 실행할 때 유용할 수 있습니다.
우선순위가 높은 태스크는 일반적으로 우선순위가 낮은 태스크보다 우선 실행됩니다. Spanner는 우선순위가 낮은 태스크와 경합이 발생하더라도 사용 가능한 CPU 리소스의 최대 100%까지 우선순위가 높은 태스크에 사용되도록 허용합니다. 우선순위가 낮은 시스템 태스크가 단기적으로 지연될 수 있지만 결국은 실행되어야 합니다. 따라서 모든 태스크를 처리하도록 인스턴스에 충분한 컴퓨팅 용량을 프로비저닝해야 합니다.
우선순위가 높은 태스크가 없는 경우 Spanner는 사용 가능한 CPU 리소스를 최대 100%까지 활용하여 우선순위가 낮은 태스크를 더욱 빠르게 완료합니다.
백그라운드 사용량 급증은 문제가 발생했다는 징후가 아니며, 사용자 태스크를 포함하여 우선순위가 낮은 태스크가 우선순위가 높은 태스크에 거의 즉각적으로 리소스를 양보할 수 있습니다.
평탄화된 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 콘솔에서 이 측정항목의 차트를 만들 수 있습니다.
다음 표에서는 리전, 이중 리전, 멀티 리전 인스턴스의 최대 CPU 사용량에 대한 권장사항을 지정합니다.
이 수치는 리전 인스턴스의 전체 영역이나 이중 리전 및 멀티 리전 인스턴스의 전체 리전이 손실될 경우 트래픽을 계속 처리할 수 있도록 인스턴스에 충분한 컴퓨팅 용량을 제공하기 위한 것입니다.
CPU 사용률은 요청 지연 시간에 영향을 미칠 수 있습니다. 개별 백엔드 서버에 과부하가 발생하면 요청 지연 시간이 길어집니다. 애플리케이션은 벤치마크 및 활성 모니터링을 실행하여 Spanner가 성능 요구사항을 충족하는지 확인해야 합니다.
따라서 성능에 민감한 애플리케이션의 경우 다음 섹션에 설명된 기술을 사용하여 CPU 사용률을 추가로 줄여야 할 수 있습니다.
CPU 사용률 100% 초과
일부 경우에는 Spanner 인스턴스의 CPU 사용률이 100%를 초과할 수 있습니다. 즉, 인스턴스에 구성된 것보다 많은 CPU 리소스가 인스턴스에 사용됩니다.
갑작스러운 요청 트래픽 증가와 같이 CPU 사용률이 급증하는 기간 중에는 보다 효율적이고 예측 가능한 성능을 제공하기 위해 CPU 리소스가 100% 넘게 사용될 수 있습니다.
100%를 초과하는 CPU 용량은 보장되지 않으며 일반 데이터베이스 작업에 사용되지 않아야 합니다.
100% CPU 사용률을 초과하거나 근접한 상태로 Spanner 인스턴스를 장시간 실행하면 일반 작업 성능이 저하되고 지연 시간이 늘어날 위험이 있습니다. 추가 CPU 리소스는 일관적인 성능을 위해 의존할 수 있는 안전한 메커니즘이 아닙니다.
이 추가 CPU 사용률에 대해서는 고객에게 청구되지 않습니다.
CPU 사용률 줄이기
이 섹션에서는 인스턴스의 CPU 사용률을 줄이는 방법을 설명합니다.
일반적으로 인스턴스의 컴퓨팅 용량을 늘리는 방법부터 시도해 보는 것이 좋습니다. 컴퓨팅 용량을 늘린 후 높은 CPU 사용률의 근본 원인을 조사하고 해결할 수 있습니다.
컴퓨팅 용량 늘리기
권장되는 CPU 사용률 최댓값을 초과하는 경우 인스턴스가 계속 원활하게 작동하도록 인스턴스의 컴퓨팅 용량을 늘리는 것이 좋습니다. 이 프로세스를 자동화하려면 CPU 사용률을 모니터링하는 애플리케이션을 만든 다음 필요에 따라 UpdateInstance 메서드를 사용하여 컴퓨팅 용량을 늘리거나 줄이면 됩니다.
필요한 컴퓨팅 용량을 판단하려면 24시간 평탄화 평균뿐만 아니라 우선순위가 높은 CPU 최대 사용률도 고려합니다. 항상 충분한 수의 컴퓨팅 용량을 할당하여 CPU 사용률을 권장되는 최댓값 아래로 유지하세요. 앞에서 설명한 것처럼 워크로드 급증을 수용할 수 있도록 성능에 민감한 애플리케이션에 추가 컴퓨팅 용량을 할당해야 할 수 있습니다.
컴퓨팅 용량이 충분하지 않으면 Spanner는 우선순위에 따라 태스크를 연기합니다. 데이터베이스 압축, 스키마 변경 유효성 검사와 같이 우선순위가 낮은 시스템 태스크는 사용자 태스크보다 뒤로 미뤄도 무방합니다. 그러나 이러한 태스크는 인스턴스의 정상적인 작동에 필수적이므로 Spanner는 이를 무한정 연기할 수는 없습니다. Spanner는 컴퓨팅 리소스 부족으로 인해 특정 기간(몇 시간 내지 하루) 이내에 우선순위가 낮은 태스크를 완료할 수 없는 경우 시스템 태스크의 우선순위를 높일 수 있습니다. 이 변경 사항은 사용자 태스크의 성능에 영향을 줍니다.
점검 도구를 사용한 추가 조사
작업 유형별 CPU 사용률 측정항목에서 특정 유형의 작업이 높은 CPU 사용률에 기여하고 있는 것으로 나타나면 Spanner 점검 도구를 사용하여 문제를 해결합니다. 자세한 내용은 높은 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)."]]