기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
Amazon DocumentDB 작업 프로파일링
Amazon DocumentDB(MongoDB 호환)를 사용하여 클러스터에서 수행된 작업의 실행 시간 및 세부 정보를 기록할 수 있습니다. 프로파일러는 개별 쿼리 성능 및 전체 클러스터 성능을 개선하기 위해 클러스터에서 가장 느린 작업을 모니터링하는 경우에 유용합니다.
프로파일러 특성은 기본적으로 비활성화됩니다. 이 옵션을 사용하도록 설정하면 프로파일러 로그 고객 정의 임계값(예: 100ms)보다 오래 걸리는 작업을 Amazon CloudWatch Logs에 기록합니다. 로깅되는 세부 정보에는 프로파일링된 명령, 시간, 계획 요약 및 클라이언트 메타데이터가 포함됩니다. 작업이 CloudWatch 로그에 기록된 후 CloudWatch 로그 인사이트를 사용하여 Amazon DocumentDB 프로파일링 데이터를 분석, 모니터링 및 보관할 수 있습니다. 공통적인 쿼리는 공통 쿼리 섹션에 제공됩니다.
활성화되면 프로파일러는 클러스터에 있는 추가 리소스를 사용합니다. 높은 임계값(예: 500ms)으로 시작하여 값을 점차적으로 낮추면서 느린 작업을 식별하는 것이 좋습니다. 임계값 50ms로 시작하면 처리량이 많은 애플리케이션의 경우 클러스터에서 성능 문제가 발생할 수 있습니다. 프로파일러는 클러스터 수준에서 사용 가능하며 클러스터의 모든 인스턴스와 데이터베이스에서 작동합니다. Amazon DocumentDB 로그는 작업을 최상의 방법으로 Amazon CloudWatch Logs에 기록합니다.
Amazon DocumentDB는 프로파일러를 활성화하기 위해 추가 요금을 부과하지 않지만 CloudWatch 로그 사용에 대한 표준 요금이 부과됩니다. CloudWatch 로그 요금에 대한 자세한 내용은 Amazon CloudWatch 요금을 참조하십시오.
지원되는 연산자
Amazon DocumentDB 프로파일러는 다음 작업을 지원합니다:
aggregate
count
delete
distinct
find
(OP_QUERY 및 명령)
findAndModify
insert
update
제한 사항
슬로우 쿼리 프로파일러는 쿼리의 전체 결과 집합이 한 배치에 들어갈 수 있고 결과 집합이 16MB(최대 BSON 크기) 미만인 경우에만 프로파일러 로그를 내보낼 수 있습니다. 16MB 이상의 결과 세트는 자동으로 여러 배치로 분할됩니다.
대부분의 드라이버나 쉘은 기본 배치 크기를 작게 설정할 수 있습니다. 쿼리의 일부로 배치 크기를 지정할 수 있습니다. 슬로우 쿼리 로그를 캡처하기 위해 예상 결과 집합의 크기를 초과하는 배치 크기를 권장합니다. 결과 집합 크기가 확실하지 않거나 크기가 다른 경우 배치 크기를 큰 수(예: 100k)로 설정할 수도 있습니다.
그러나 더 큰 배치 크기를 사용하면 응답이 클라이언트로 전송되기 전에 데이터베이스에서 더 많은 결과를 검색해야 합니다. 일부 쿼리의 경우 결과를 얻기 전에 지연이 더 길어질 수 있습니다. 전체 결과 집합을 소비할 계획이 없는 경우, 더 많은 I/O를 사용하여 쿼리를 처리하고 결과를 버릴 가능성이 있습니다.
Amazon DocumentDB 프로파일러 활성화
클러스터에서 프로파일러를 활성화하는 작업은 3단계 프로세스입니다. 모든 단계를 완료하거나 프로파일링 로그가 CloudWatch Logs로 전송되지 않도록 합니다. 프로파일러는 클러스터 수준에서 설정되며 클러스터의 모든 데이터베이스와 인스턴스에 대해 수행됩니다.
클러스터에서 프로파일러를 활성화하려면
-
기본 클러스터 파라미터 그룹을 수정할 수 없으므로, 사용 가능한 사용자 지정 클러스터 파라미터 그룹이 있는지 확인하십시오. 자세한 내용은 Amazon DocumentDB 클러스터 파라미터 그룹 생성 섹션을 참조하십시오.
-
사용 가능한 사용자 지정 클러스터 파라미터 그룹을 사용하여 profiler
, profiler_threshold_ms
및 profiler_sampling_rate
파라미터를 수정합니다. 자세한 내용은 Amazon DocumentDB 클러스터 파라미터 그룹 수정 섹션을 참조하십시오.
-
사용자 지정 클러스터 매개 변수 그룹을 사용하고 profiler
CloudWatch Logs로 로그 내보내기를 사용하도록 클러스터를 생성하거나 수정합니다.
다음 섹션에서는 AWS Management Console 및 AWS Command Line Interface ()를 사용하여 이러한 단계를 구현하는 방법을 보여줍니다AWS CLI.
- Using the AWS Management Console
-
-
시작하기 전에 Amazon DocumentDB 클러스터와 사용자 정의 클러스터 파라미터 그룹이 없는 경우, 이를 생성합니다. 자세한 내용은 Amazon DocumentDB 클러스터 파라미터 그룹 생성 및 Amazon DocumentDB 클러스터 생성 섹션을 참조하십시오.
-
사용 가능한 사용자 지정 클러스터 파라미터 그룹을 사용하여 다음 파라미터를 수정합니다. 자세한 내용은 Amazon DocumentDB 클러스터 파라미터 그룹 수정 섹션을 참조하십시오.
-
profiler
- 쿼리 프로파일링을 활성화하거나 비활성화합니다. 허용된 값은 enabled
및 disabled
입니다. 기본값은 disabled
입니다. 프로파일링을 활성화하려면 값을 enabled
로 설정합니다.
-
profiler_threshold_ms
- profiler
를 enabled
으로 설정하면
profiler_threshold_ms
보다 더 오래 걸리는 모든 명령이 CloudWatch 로그에 기록됩니다. 허용된 값은 [50-INT_MAX]
입니다. 기본값은 100
입니다.
-
profiler_sampling_rate
- 프로파일링하거나 로깅해야 하는 느린 작업의 조각입니다. 허용된 값은 [0.0-1.0]
입니다. 기본값은 1.0
입니다.
-
사용자 지정 클러스터 매개 변수 그룹을 사용하도록 클러스터를 수정하고 Amazon CloudWatch에 게시자 프로파일러 로그 내보내기를 설정합니다.
-
탐색 창에서 클러스터를 선택하여 사용자 지정 파라미터 그룹을 클러스터에 추가합니다.
-
파라미터 그룹을 연결할 클러스터의 이름 왼쪽에 있는 버튼을 선택합니다. 작업, 수정 순으로 선택하여 클러스터를 수정합니다.
-
클러스터 옵션의 위 단계에서 사용자 지정 파라미터 그룹을 선택하여 클러스터에 추가합니다.
-
로그 내보내기에서 Amazon CloudWatch에 게시자로 등록할 프로파일 로그를 선택합니다.
-
수정 사항의 요약을 보려면 계속을 선택합니다.
-
변경 사항을 확인한 후 즉시 적용하거나 수정 일정 아래의 다음 유지 관리 기간 중에 적용할 수 있습니다.
-
클러스터를 새 파라미터 그룹으로 업데이트하려면 클러스터 수정을 선택합니다.
- Using the AWS CLI
-
다음 절차는 sample-cluster
클러스터에 지원되는 모든 작업에 대해 프로파일러를 활성화합니다.
-
시작하기 전에 다음 명령을 실행한 후 이름에 default
가 없고 docdb3.6
이 파라미터 그룹 패밀리인 클러스터 파라미터 그룹의 출력을 검토하여 사용 가능한 사용자 지정 클러스터 파라미터 그룹이 있는지 확인합니다. 기본이 아닌 클러스터 파라미터 그룹이 없는 경우 Amazon DocumentDB 클러스터 파라미터 그룹 생성 단원을 참조하십시오.
aws docdb describe-db-cluster-parameter-groups \
--query 'DBClusterParameterGroups[*].[DBClusterParameterGroupName,DBParameterGroupFamily]'
다음 출력에서는 sample-parameter-group
만 두 기준을 모두 충족합니다.
[
[
"default.docdb3.6",
"docdb3.6"
],
[
"sample-parameter-group"
,
"docdb3.6"
]
]
-
사용자 지정 클러스터 파라미터 그룹을 사용하여 다음 파라미터를 수정합니다:
-
profiler
- 쿼리 프로파일링을 활성화하거나 비활성화합니다. 허용된 값은 enabled
및 disabled
입니다. 기본값은 disabled
입니다. 프로파일링을 활성화하려면 값을 enabled
로 설정합니다.
-
profiler_threshold_ms
- profiler
를 enabled
으로 설정하면 profiler_threshold_ms
보다 더 오래 걸리는 모든 명령이 CloudWatch에 기록됩니다. 허용된 값은 [50-INT_MAX]
입니다. 기본값은 100
입니다.
-
profiler_sampling_rate
- 프로파일링하거나 로깅해야 하는 느린 작업의 조각입니다. 허용된 값은 [0.0-1.0]
입니다. 기본값은 1.0
입니다.
aws docdb modify-db-cluster-parameter-group \
--db-cluster-parameter-group-name sample-parameter-group \
--parameters ParameterName=profiler,ParameterValue=enabled,ApplyMethod=immediate \
ParameterName=profiler_threshold_ms,ParameterValue=100,ApplyMethod=immediate \
ParameterName=profiler_sampling_rate,ParameterValue=0.5,ApplyMethod=immediate
-
이전 단계의 sample-parameter-group
사용자 지정 클러스터 파라미터 그룹을 사용하고 파라미터 --enable-cloudwatch-logs-exports
를 profiler
으로 설정하도록 Amazon DocumentDB 클러스터를 수정합니다.
다음 코드는 이전 단계에서 sample-parameter-group
를 사용하도록 클러스터 sample-cluster
을 수정하고 사용하도록 설정된 CloudWatch 로그 내보내기에 profiler
을 추가합니다.
aws docdb modify-db-cluster \
--db-cluster-identifier sample-cluster \
--db-cluster-parameter-group-name sample-parameter-group \
--cloudwatch-logs-export-configuration '{"EnableLogTypes":["profiler"]}'
이 작업의 출력은 다음과 같이 표시됩니다.
{
"DBCluster": {
"AvailabilityZones": [
"us-east-1c",
"us-east-1b",
"us-east-1a"
],
"BackupRetentionPeriod": 1,
"DBClusterIdentifier": "sample-cluster",
"DBClusterParameterGroup": "sample-parameter-group",
"DBSubnetGroup": "default",
"Status": "available",
"EarliestRestorableTime": "2020-04-07T02:05:12.479Z",
"Endpoint": "sample-cluster.node.us-east-1.docdb.amazonaws.com",
"ReaderEndpoint": "sample-cluster.node.us-east-1.docdb.amazonaws.com",
"MultiAZ": false,
"Engine": "docdb",
"EngineVersion": "3.6.0",
"LatestRestorableTime": "2020-04-08T22:08:59.317Z",
"Port": 27017,
"MasterUsername": "test",
"PreferredBackupWindow": "02:00-02:30",
"PreferredMaintenanceWindow": "tue:09:50-tue:10:20",
"DBClusterMembers": [
{
"DBInstanceIdentifier": "sample-instance-1",
"IsClusterWriter": true,
"DBClusterParameterGroupStatus": "in-sync",
"PromotionTier": 1
},
{
"DBInstanceIdentifier": "sample-instance-2",
"IsClusterWriter": true,
"DBClusterParameterGroupStatus": "in-sync",
"PromotionTier": 1
}
],
"VpcSecurityGroups": [
{
"VpcSecurityGroupId": "sg-abcd0123",
"Status": "active"
}
],
"HostedZoneId": "ABCDEFGHIJKLM",
"StorageEncrypted": true,
"KmsKeyId": "arn:aws:kms:us-east-1:<accountID>:key/sample-key",
"DbClusterResourceId": "cluster-ABCDEFGHIJKLMNOPQRSTUVWXYZ",
"DBClusterArn": "arn:aws:rds:us-east-1:<accountID>:cluster:sample-cluster",
"AssociatedRoles": [],
"ClusterCreateTime": "2020-01-10T22:13:38.261Z",
"EnabledCloudwatchLogsExports": [
"profiler"
],
"DeletionProtection": true
}
}
Amazon DocumentDB 프로파일러 비활성화
프로파일러를 실행 중지하려면 profiler
매개 변수와 profiler
로그를 CloudWatch Logs로 내보내기를 모두 실행 중지해야 합니다.
프로파일러 비활성화
다음과 AWS CLI같이 AWS Management Console 또는를 사용하여 profiler
파라미터를 비활성화할 수 있습니다.
- Using the AWS Management Console
-
다음 절차에서는를 사용하여 Amazon DocumentDB AWS Management Console 를 비활성화합니다profiler
.
-
에 로그인 AWS Management Console하고 https://console.aws.amazon.com/docdb Amazon DocumentDB 콘솔을 엽니다.
-
탐색 창에서 파라미터 그룹을 선택합니다. 그런 다음 프로파일러를 비활성화하려는 클러스터 파라미터 그룹의 이름을 선택합니다.
-
그 결과 표시되는 클러스터 파라미터 페이지에서 profiler
파라미터 왼쪽에 있는 버튼을 선택하고 편집을 선택합니다.
-
프로파일러 수정 대화 상자의 목록에서 disabled
를 선택합니다.
-
클러스터 파라미터 수정을 선택합니다.
- Using the AWS CLI
-
AWS CLI를 사용하여 클러스터에서 profiler
를 비활성화하려면 다음과 같이 클러스터를 수정합니다.
aws docdb modify-db-cluster-parameter-group \
--db-cluster-parameter-group-name sample-parameter-group \
--parameters ParameterName=profiler,ParameterValue=disabled,ApplyMethod=immediate
프로파일러 로그 내보내기 비활성화
다음과 AWS CLI같이 AWS Management Console 또는를 사용하여 CloudWatch Logs로 profiler
로그 내보내기를 비활성화할 수 있습니다.
- Using the AWS Management Console
-
다음 절차에서는를 사용하여 CloudWatch AWS Management Console 로 로그를 내보내는 Amazon DocumentDB를 비활성화합니다.
-
https://console.aws.amazon.com/docdb에서 Amazon DocumentDB 콘솔을 엽니다.
-
탐색 창에서 클러스터를 선택합니다. 로그 내보내기를 비활성화할 클러스터의 이름 왼쪽에 있는 버튼을 선택합니다.
-
작업 메뉴에서 수정을 선택합니다.
-
로그 내보내기 섹션까지 아래로 스크롤하여 프로필러 로그를 선택 취소합니다.
-
Continue(계속)을 선택합니다.
-
변경 사항을 검토하고, 언제 이 변경 사항을 클러스터에 적용할지를 선택합니다:
-
예약된 다음 유지 관리 기간에 적용
-
즉시 적용
-
클러스터 수정을 선택합니다.
- Using the AWS CLI
-
다음 코드는 클러스터sample-cluster
를 수정하고 CloudWatch 프로파일러 로그를 비활성화합니다.
Linux, macOS, Unix의 경우:
aws docdb modify-db-cluster \
--db-cluster-identifier sample-cluster \
--cloudwatch-logs-export-configuration '{"DisableLogTypes":["profiler"]}'
Windows의 경우:
aws docdb modify-db-cluster ^
--db-cluster-identifier sample-cluster ^
--cloudwatch-logs-export-configuration '{"DisableLogTypes":["profiler"]}'
이 작업의 출력은 다음과 같이 표시됩니다.
{
"DBCluster": {
"AvailabilityZones": [
"us-east-1c",
"us-east-1b",
"us-east-1a"
],
"BackupRetentionPeriod": 1,
"DBClusterIdentifier": "sample-cluster",
"DBClusterParameterGroup": "sample-parameter-group",
"DBSubnetGroup": "default",
"Status": "available",
"EarliestRestorableTime": "2020-04-08T02:05:17.266Z",
"Endpoint": "sample-cluster.node.us-east-1.docdb.amazonaws.com",
"ReaderEndpoint": "sample-cluster.node.us-east-1.docdb.amazonaws.com",
"MultiAZ": false,
"Engine": "docdb",
"EngineVersion": "3.6.0",
"LatestRestorableTime": "2020-04-09T05:14:44.356Z",
"Port": 27017,
"MasterUsername": "test",
"PreferredBackupWindow": "02:00-02:30",
"PreferredMaintenanceWindow": "tue:09:50-tue:10:20",
"DBClusterMembers": [
{
"DBInstanceIdentifier": "sample-instance-1",
"IsClusterWriter": true,
"DBClusterParameterGroupStatus": "in-sync",
"PromotionTier": 1
},
{
"DBInstanceIdentifier": "sample-instance-2",
"IsClusterWriter": true,
"DBClusterParameterGroupStatus": "in-sync",
"PromotionTier": 1
}
],
"VpcSecurityGroups": [
{
"VpcSecurityGroupId": "sg-abcd0123",
"Status": "active"
}
],
"HostedZoneId": "ABCDEFGHIJKLM",
"StorageEncrypted": true,
"KmsKeyId": "arn:aws:kms:us-east-1:<accountID>:key/sample-key",
"DbClusterResourceId": "cluster-ABCDEFGHIJKLMNOPQRSTUVWXYZ",
"DBClusterArn": "arn:aws:rds:us-east-1:<accountID>:cluster:sample-cluster",
"AssociatedRoles": [],
"ClusterCreateTime": "2020-01-10T22:13:38.261Z",
"DeletionProtection": true
}
}
Amazon DocumentDB 프로파일러 로그에 액세스
Amazon CloudWatch에서 프로필 로그에 액세스하려면 다음 단계를 수행합니다.
공통 쿼리
다음은 프로파일링된 명령을 분석하는 데 사용할 수 있는 몇 가지 공통적인 쿼리입니다. CloudWatch Logs Insights에 대한 자세한 내용은 CloudWatch Logs Insights로 로그 데이터 분석 및 샘플 쿼리를 참조하십시오.
지정된 모음에서 가장 느린 10개 작업 가져오기
filter ns="test.foo" | sort millis desc | limit 10
모음에서 60ms보다 오래 걸린 모든 업데이트 작업 가져오기
filter millis > 60 and op = "update"
지난 달에 가장 느린 10개 작업 가져오기
sort millis desc | limit 10
COLLSCAN 계획 요약을 사용하여 모든 쿼리 가져오기
filter planSummary="COLLSCAN"