자동 컴팩션

자동 컴팩션 (Automatic compaction) API

Coordinator duty를 사용한 자동 컴팩션의 상태 및 구성 API 엔드포인트를 다룹니다. 웹 콘솔이나 API에서 자동 컴팩션을 구성할 수 있어요.

출처: 문서

본문

이 문서는 Apache Druid에서 Coordinator duty를 사용한 자동 컴팩션의 상태 및 구성 API 엔드포인트를 설명합니다. Druid 웹 콘솔이나 API에서 자동 컴팩션을 구성할 수 있어요.

실험적(Experimental)

자동 컴팩션 API 대신, 컴팩션 supervisor를 사용해 supervisor API로 자동 컴팩션 작업을 제출할 수도 있습니다. 자세한 내용은 Auto-compaction using compaction supervisors를 참고하세요.

이 문서에서 http://ROUTER_IP:ROUTER_PORT는 여러분의 Router 서비스 주소와 포트를 위한 자리표시자입니다. 이를 배포 정보로 교체하세요. 예를 들어 quickstart 배포라면 http://localhost:8888을 사용합니다.

자동 컴팩션 관리

자동 컴팩션 구성 생성 또는 업데이트

데이터소스의 자동 컴팩션 구성을 생성하거나 업데이트합니다. 자동 컴팩션을 요청 본문의 JSON 객체로 전달하세요.

자동 컴팩션 구성은 dataSource 속성만 있으면 됩니다. Druid는 지정되지 않은 다른 모든 속성을 기본값으로 채워요. 구성 세부 사항은 Automatic compaction dynamic configuration을 참고하세요.

이 엔드포인트는 데이터소스 이름이 존재하지 않아도 HTTP 200 OK 메시지 코드를 반환합니다.

URL

POST /druid/coordinator/v1/config/compaction

응답
  • 200 SUCCESS — 자동 컴팩션 구성을 성공적으로 제출함
샘플 요청

다음 예시는 HOUR 세그먼트 세분성으로 수집된 wikipedia_hour 데이터소스의 자동 컴팩션 구성을 생성합니다. 이 자동 컴팩션 구성은 wikipedia_hour에 컴팩션을 수행해 하루 간격의 데이터를 나타내는 컴팩트된 세그먼트를 만듭니다.

이 예시에서:

  • wikipedia_hour는 HOUR 세그먼트 세분성을 가진 데이터소스입니다.
  • skipOffsetFromLatest가 PT0S로 설정되어, 건너뛰는 데이터가 없음을 뜻합니다.
  • partitionsSpec이 기본값인 dynamic으로 설정되어, Druid가 최적의 파티셔닝 전략을 동적으로 결정합니다.
  • type이 index_parallel로 설정되어, 병렬 인덱싱을 사용함을 뜻합니다.
  • segmentGranularity가 DAY로 설정되어, 각 컴팩트된 세그먼트가 하루의 데이터임을 뜻합니다.

cURL

curl "http://ROUTER_IP:ROUTER_PORT/druid/coordinator/v1/config/compaction"\
--header 'Content-Type: application/json' \
--data '{
    "dataSource": "wikipedia_hour",
    "skipOffsetFromLatest": "PT0S",
    "tuningConfig": {
        "partitionsSpec": {
            "type": "dynamic"
        },
        "type": "index_parallel"
    },
    "granularitySpec": {
        "segmentGranularity": "DAY"
    }
}'

HTTP

POST /druid/coordinator/v1/config/compaction HTTP/1.1
Host: http://ROUTER_IP:ROUTER_PORT
Content-Type: application/json
Content-Length: 281

{
    "dataSource": "wikipedia_hour",
    "skipOffsetFromLatest": "PT0S",
    "tuningConfig": {
        "partitionsSpec": {
            "type": "dynamic"
        },
        "type": "index_parallel"
    },
    "granularitySpec": {
        "segmentGranularity": "DAY"
    }
}
샘플 응답

성공한 요청은 HTTP 200 OK 메시지 코드와 빈 응답 본문을 반환합니다.

자동 컴팩션 구성 제거

데이터소스의 자동 컴팩션 구성을 제거합니다. 이는 데이터소스의 컴팩션 상태를 "Not enabled"로 업데이트합니다.

URL

DELETE /druid/coordinator/v1/config/compaction/{dataSource}

응답
  • 200 SUCCESS — 자동 컴팩션 구성을 성공적으로 삭제함
  • 404 NOT FOUND — 데이터소스에 자동 컴팩션이 없거나 데이터소스 이름이 잘못됨
샘플 요청

cURL

curl --request DELETE "http://ROUTER_IP:ROUTER_PORT/druid/coordinator/v1/config/compaction/wikipedia_hour"

HTTP

DELETE /druid/coordinator/v1/config/compaction/wikipedia_hour HTTP/1.1
Host: http://ROUTER_IP:ROUTER_PORT
샘플 응답

성공한 요청은 HTTP 200 OK 메시지 코드와 빈 응답 본문을 반환합니다.

컴팩션 태스크 용량 업데이트

참고: 이 API는 이제 비권장(deprecated)입니다. Update cluster-level compaction config를 대신 사용하세요.

컴팩션 태스크의 용량을 업데이트합니다. 컴팩션 태스크의 최소 개수는 1, 최대는 2147483647입니다.

최대 컴팩션 태스크 수는 이론상 2147483647로 설정할 수 있지만, 실제 한계는 사용 가능한 클러스터 용량에 의해 결정되며 클러스터 총 용량의 10%로 제한됩니다.

URL

POST /druid/coordinator/v1/config/compaction/taskslots

쿼리 파라미터

최대 컴팩션 태스크 수를 제한하려면 선택적 쿼리 파라미터 ratio와 max를 사용하세요.

  • ratio (선택) — 타입: Float. 기본값: 0.1. 전체 태스크 슬롯 대비 컴팩션 태스크 슬롯의 비율을 제한합니다.
  • max (선택) — 타입: Int. 기본값: 2147483647. 컴팩션 태스크용 태스크 슬롯의 최대 개수를 제한합니다.
응답
  • 200 SUCCESS — 컴팩션 구성을 성공적으로 업데이트함
  • 404 NOT FOUND — 유효하지 않은 max 값
샘플 요청

cURL

curl --request POST "http://ROUTER_IP:ROUTER_PORT/druid/coordinator/v1/config/compaction/taskslots?ratio=0.2&max=250000"

HTTP

POST /druid/coordinator/v1/config/compaction/taskslots?ratio=0.2&max=250000 HTTP/1.1
Host: http://ROUTER_IP:ROUTER_PORT
샘플 응답

성공한 요청은 HTTP 200 OK 메시지 코드와 빈 응답 본문을 반환합니다.

자동 컴팩션 구성 보기

모든 자동 컴팩션 구성 가져오기

모든 자동 컴팩션 구성을 가져옵니다. 모든 데이터소스의 활성 자동 컴팩션 구성을 담은 compactionConfigs 객체를 반환합니다.

이 엔드포인트를 사용해 컴팩션 태스크의 리소스 할당 관리를 위한 compactionTaskSlotRatio와 maxCompactionTaskSlots 값을 가져올 수 있어요.

URL

GET /druid/coordinator/v1/config/compaction

응답
  • 200 SUCCESS — 자동 컴팩션 구성을 성공적으로 조회함
샘플 요청

cURL

curl "http://ROUTER_IP:ROUTER_PORT/druid/coordinator/v1/config/compaction"

HTTP

GET /druid/coordinator/v1/config/compaction HTTP/1.1
Host: http://ROUTER_IP:ROUTER_PORT
샘플 응답
{
    "compactionConfigs": [
        {
            "dataSource": "wikipedia_hour",
            "taskPriority": 25,
            "inputSegmentSizeBytes": 100000000000000,
            "maxRowsPerSegment": null,
            "skipOffsetFromLatest": "PT0S",
            "tuningConfig": {
                "maxRowsInMemory": null,
                "appendableIndexSpec": null,
                "maxBytesInMemory": null,
                "maxTotalRows": null,
                "splitHintSpec": null,
                "partitionsSpec": {
                    "type": "dynamic",
                    "maxRowsPerSegment": 5000000,
                    "maxTotalRows": null
                },
                "indexSpec": null,
                "indexSpecForIntermediatePersists": null,
                "maxPendingPersists": null,
                "pushTimeout": null,
                "segmentWriteOutMediumFactory": null,
                "maxNumConcurrentSubTasks": null,
                "maxRetry": null,
                "taskStatusCheckPeriodMs": null,
                "chatHandlerTimeout": null,
                "chatHandlerNumRetries": null,
                "maxNumSegmentsToMerge": null,
                "totalNumMergeTasks": null,
                "maxColumnsToMerge": null,
                "type": "index_parallel",
                "forceGuaranteedRollup": false
            },
            "granularitySpec": {
                "segmentGranularity": "DAY",
                "queryGranularity": null,
                "rollup": null
            },
            "dimensionsSpec": null,
            "metricsSpec": null,
            "transformSpec": null,
            "ioConfig": null,
            "taskContext": null
        },
        {
            "dataSource": "wikipedia",
            "taskPriority": 25,
            "inputSegmentSizeBytes": 100000000000000,
            "maxRowsPerSegment": null,
            "skipOffsetFromLatest": "PT0S",
            "tuningConfig": {
                "maxRowsInMemory": null,
                "appendableIndexSpec": null,
                "maxBytesInMemory": null,
                "maxTotalRows": null,
                "splitHintSpec": null,
                "partitionsSpec": {
                    "type": "dynamic",
                    "maxRowsPerSegment": 5000000,
                    "maxTotalRows": null
                },
                "indexSpec": null,
                "indexSpecForIntermediatePersists": null,
                "maxPendingPersists": null,
                "pushTimeout": null,
                "segmentWriteOutMediumFactory": null,
                "maxNumConcurrentSubTasks": null,
                "maxRetry": null,
                "taskStatusCheckPeriodMs": null,
                "chatHandlerTimeout": null,
                "chatHandlerNumRetries": null,
                "maxNumSegmentsToMerge": null,
                "totalNumMergeTasks": null,
                "maxColumnsToMerge": null,
                "type": "index_parallel",
                "forceGuaranteedRollup": false
            },
            "granularitySpec": {
                "segmentGranularity": "DAY",
                "queryGranularity": null,
                "rollup": null
            },
            "dimensionsSpec": null,
            "metricsSpec": null,
            "transformSpec": null,
            "ioConfig": null,
            "taskContext": null
        }
    ],
    "compactionTaskSlotRatio": 0.1,
    "maxCompactionTaskSlots": 2147483647,

}

자동 컴팩션 구성 가져오기

데이터소스의 자동 컴팩션 구성을 가져옵니다.

URL

GET /druid/coordinator/v1/config/compaction/{dataSource}

응답
  • 200 SUCCESS — 데이터소스의 구성을 성공적으로 조회함
  • 404 NOT FOUND — 잘못된 데이터소스이거나 데이터소스에 자동 컴팩션이 활성화되어 있지 않음
샘플 요청

다음 예시는 wikipedia_hour 데이터소스의 자동 컴팩션 구성을 조회합니다.

cURL

curl "http://ROUTER_IP:ROUTER_PORT/druid/coordinator/v1/config/compaction/wikipedia_hour"

HTTP

GET /druid/coordinator/v1/config/compaction/wikipedia_hour HTTP/1.1
Host: http://ROUTER_IP:ROUTER_PORT
샘플 응답
{
    "dataSource": "wikipedia_hour",
    "taskPriority": 25,
    "inputSegmentSizeBytes": 100000000000000,
    "maxRowsPerSegment": null,
    "skipOffsetFromLatest": "PT0S",
    "tuningConfig": {
        "maxRowsInMemory": null,
        "appendableIndexSpec": null,
        "maxBytesInMemory": null,
        "maxTotalRows": null,
        "splitHintSpec": null,
        "partitionsSpec": {
            "type": "dynamic",
            "maxRowsPerSegment": 5000000,
            "maxTotalRows": null
        },
        "indexSpec": null,
        "indexSpecForIntermediatePersists": null,
        "maxPendingPersists": null,
        "pushTimeout": null,
        "segmentWriteOutMediumFactory": null,
        "maxNumConcurrentSubTasks": null,
        "maxRetry": null,
        "taskStatusCheckPeriodMs": null,
        "chatHandlerTimeout": null,
        "chatHandlerNumRetries": null,
        "maxNumSegmentsToMerge": null,
        "totalNumMergeTasks": null,
        "maxColumnsToMerge": null,
        "type": "index_parallel",
        "forceGuaranteedRollup": false
    },
    "granularitySpec": {
        "segmentGranularity": "DAY",
        "queryGranularity": null,
        "rollup": null
    },
    "dimensionsSpec": null,
    "metricsSpec": null,
    "transformSpec": null,
    "ioConfig": null,
    "taskContext": null
}

자동 컴팩션 구성 기록 가져오기

데이터소스의 자동 컴팩션 구성 기록을 가져옵니다. 데이터소스가 존재하지 않거나 컴팩션 기록이 없으면 빈 목록을 반환합니다.

응답은 다음 키를 가진 객체의 목록을 포함합니다.

  • globalConfig: 전체 클러스터에 적용되는 자동 컴팩션 구성을 담은 JSON 객체
  • compactionConfig: 데이터소스의 자동 컴팩션 구성을 담은 JSON 객체
  • auditInfo: author, comment, ip 같은 변경 사항에 대한 정보를 담은 JSON 객체
  • auditTime: 변경이 이루어진 날짜와 시간
URL

GET /druid/coordinator/v1/config/compaction/{dataSource}/history

쿼리 파라미터
  • interval (선택) — 타입: ISO-8601. 결과를 지정된 간격 내로 제한합니다. 간격 문자열 구분자로 /를 사용하세요.
  • count (선택) — 타입: Int. 결과 개수를 제한합니다.
응답
  • 200 SUCCESS — 구성 기록을 성공적으로 조회함
  • 400 BAD REQUEST — 잘못된 count 값
샘플 요청

cURL

curl "http://ROUTER_IP:ROUTER_PORT/druid/coordinator/v1/config/compaction/wikipedia_hour/history"

HTTP

GET /druid/coordinator/v1/config/compaction/wikipedia_hour/history HTTP/1.1
Host: http://ROUTER_IP:ROUTER_PORT
샘플 응답
[
    {
        "globalConfig": {
            "compactionTaskSlotRatio": 0.1,
            "maxCompactionTaskSlots": 2147483647,
            "compactionPolicy": {
                "type": "newestSegmentFirst",
                "priorityDatasource": "wikipedia"
            },
            "useSupervisors": true,
            "engine": "native"
        },
        "compactionConfig": {
            "dataSource": "wikipedia_hour",
            "taskPriority": 25,
            "inputSegmentSizeBytes": 100000000000000,
            "maxRowsPerSegment": null,
            "skipOffsetFromLatest": "P1D",
            "tuningConfig": null,
            "granularitySpec": {
                "segmentGranularity": "DAY",
                "queryGranularity": null,
                "rollup": null
            },
            "dimensionsSpec": null,
            "metricsSpec": null,
            "transformSpec": null,
            "ioConfig": null,
            "taskContext": null
        },
        "auditInfo": {
            "author": "",
            "comment": "",
            "ip": "127.0.0.1"
        },
        "auditTime": "2023-07-31T18:15:19.302Z"
    },
    {
        "globalConfig": {
            "compactionTaskSlotRatio": 0.1,
            "maxCompactionTaskSlots": 2147483647,
            "compactionPolicy": {
                "type": "newestSegmentFirst"
            },
            "useSupervisors": false,
            "engine": "native"
        },
        "compactionConfig": {
            "dataSource": "wikipedia_hour",
            "taskPriority": 25,
            "inputSegmentSizeBytes": 100000000000000,
            "maxRowsPerSegment": null,
            "skipOffsetFromLatest": "PT0S",
            "tuningConfig": {
                "maxRowsInMemory": null,
                "appendableIndexSpec": null,
                "maxBytesInMemory": null,
                "maxTotalRows": null,
                "splitHintSpec": null,
                "partitionsSpec": {
                    "type": "dynamic",
                    "maxRowsPerSegment": 5000000,
                    "maxTotalRows": null
                },
                "indexSpec": null,
                "indexSpecForIntermediatePersists": null,
                "maxPendingPersists": null,
                "pushTimeout": null,
                "segmentWriteOutMediumFactory": null,
                "maxNumConcurrentSubTasks": null,
                "maxRetry": null,
                "taskStatusCheckPeriodMs": null,
                "chatHandlerTimeout": null,
                "chatHandlerNumRetries": null,
                "maxNumSegmentsToMerge": null,
                "totalNumMergeTasks": null,
                "maxColumnsToMerge": null,
                "type": "index_parallel",
                "forceGuaranteedRollup": false
            },
            "granularitySpec": {
                "segmentGranularity": "DAY",
                "queryGranularity": null,
                "rollup": null
            },
            "dimensionsSpec": null,
            "metricsSpec": null,
            "transformSpec": null,
            "ioConfig": null,
            "taskContext": null
        },
        "auditInfo": {
            "author": "",
            "comment": "",
            "ip": "127.0.0.1"
        },
        "auditTime": "2023-07-31T18:16:16.362Z"
    }
]

자동 컴팩션 상태 보기

컴팩션 대기 중인 세그먼트 가져오기

주어진 데이터소스에 대해 컴팩션을 기다리는 세그먼트의 총 크기를 반환합니다. 데이터소스에 자동 컴팩션이 활성화되어 있지 않으면 404 응답을 반환합니다.

URL

GET /druid/coordinator/v1/compaction/progress?dataSource={dataSource}

쿼리 파라미터
  • dataSource (필수) — 타입: String. 이 상태 정보를 위한 데이터소스의 이름.
응답
  • 200 SUCCESS — 컴팩션 대기 중인 세그먼트 크기를 성공적으로 조회함
  • 404 NOT FOUND — 알 수 없는 데이터소스 이름이거나 데이터소스에 자동 컴팩션이 활성화되어 있지 않음
샘플 요청

다음 예시는 wikipedia_hour 데이터소스에 대해 컴팩션될 남은 세그먼트를 조회합니다.

cURL

curl "http://ROUTER_IP:ROUTER_PORT/druid/coordinator/v1/compaction/progress?dataSource=wikipedia_hour"

HTTP

GET /druid/coordinator/v1/compaction/progress?dataSource=wikipedia_hour HTTP/1.1
Host: http://ROUTER_IP:ROUTER_PORT
샘플 응답
{
    "remainingSegmentSize": 7615837
}

컴팩션 상태와 통계 가져오기

자동 컴팩션이 활성화된 모든 데이터소스의 최신 자동 컴팩션 실행 상태와 통계를 나타내는 latestStatus 객체의 배열을 가져옵니다.

컴팩션 상태 응답

latestStatus 객체는 다음 속성을 가집니다.

  • dataSource: 이 상태 정보를 위한 데이터소스의 이름.
  • scheduleStatus: 자동 컴팩션 스케줄링 상태. 가능한 값은 NOT_ENABLED와 RUNNING입니다. 데이터소스에 활성화된 자동 컴팩션 구성이 제출되어 있으면 RUNNING을, 그렇지 않으면 NOT_ENABLED를 반환합니다.
  • bytesAwaitingCompaction: 자동 컴팩션이 컴팩션하기를 기다리는 이 데이터소스의 총 바이트 (자동 컴팩션 자격이 있는 간격/세그먼트만 고려).
  • bytesCompacted: 자동 컴팩션 구성에 설정된 스펙으로 이미 컴팩션된 이 데이터소스의 총 바이트.
  • bytesSkipped: 자동 컴팩션이 (자격이 없어) 건너뛴 이 데이터소스의 총 바이트.
  • segmentCountAwaitingCompaction: 자동 컴팩션이 컴팩션하기를 기다리는 이 데이터소스의 총 세그먼트 수 (자격이 있는 간격/세그먼트만 고려).
  • segmentCountCompacted: 자동 컴팩션 구성의 스펙으로 이미 컴팩션된 이 데이터소스의 총 세그먼트 수.
  • segmentCountSkipped: 자동 컴팩션이 건너뛴 이 데이터소스의 총 세그먼트 수.
  • intervalCountAwaitingCompaction: 자동 컴팩션이 컴팩션하기를 기다리는 이 데이터소스의 총 간격 수 (자격이 있는 간격/세그먼트만 고려).
  • intervalCountCompacted: 자동 컴팩션 구성의 스펙으로 이미 컴팩션된 이 데이터소스의 총 간격 수.
  • intervalCountSkipped: 자동 컴팩션이 건너뛴 이 데이터소스의 총 간격 수.
URL

GET /druid/coordinator/v1/compaction/status

쿼리 파라미터
  • dataSource (선택) — 타입: String. 특정 데이터소스의 이름으로 결과를 필터링합니다.
응답
  • 200 SUCCESS — latestStatus 객체를 성공적으로 조회함
샘플 요청

cURL

curl "http://ROUTER_IP:ROUTER_PORT/druid/coordinator/v1/compaction/status"

HTTP

GET /druid/coordinator/v1/compaction/status HTTP/1.1
Host: http://ROUTER_IP:ROUTER_PORT
샘플 응답
{
    "latestStatus": [
        {
            "dataSource": "wikipedia_api",
            "scheduleStatus": "RUNNING",
            "bytesAwaitingCompaction": 0,
            "bytesCompacted": 0,
            "bytesSkipped": 64133616,
            "segmentCountAwaitingCompaction": 0,
            "segmentCountCompacted": 0,
            "segmentCountSkipped": 8,
            "intervalCountAwaitingCompaction": 0,
            "intervalCountCompacted": 0,
            "intervalCountSkipped": 1
        },
        {
            "dataSource": "wikipedia_hour",
            "scheduleStatus": "RUNNING",
            "bytesAwaitingCompaction": 0,
            "bytesCompacted": 5998634,
            "bytesSkipped": 0,
            "segmentCountAwaitingCompaction": 0,
            "segmentCountCompacted": 1,
            "segmentCountSkipped": 0,
            "intervalCountAwaitingCompaction": 0,
            "intervalCountCompacted": 1,
            "intervalCountSkipped": 0
        }
    ]
}

[실험적] 통합 컴팩션 API (Unified Compaction APIs)

이 섹션은 컴팩션 동적 구성에서 컴팩션 supervisor가 활성화되어 있는지(useSupervisors가 true인지) 여부와 관계없이 사용할 수 있는 새로운 통합 컴팩션 API를 설명합니다.

컴팩션 supervisor가 비활성화되어 있으면, 이 API들은 위의 Coordinator 기반 컴팩션 API처럼 컴팩션 동적 구성을 읽거나 씁니다.

컴팩션 supervisor가 활성화되어 있으면, 이 API들은 해당 컴팩션 supervisor를 읽거나 씁니다. 아래 설명된 API와 함께, supervisor API도 컴팩션 supervisor를 읽거나 쓰는 데 사용할 수 있는데, supervisor API는 더 큰 유연성을 제공하고 supervisor 및 태스크 상태와 관련된 정보도 제공하기 때문입니다.

클러스터 수준 컴팩션 구성 업데이트

데이터소스 컴팩션 구성에서 명시적으로 오버라이드하지 않는 한 모든 데이터소스에 적용되는 컴팩션 태스크의 클러스터 수준 구성을 업데이트합니다. 여기에는 다음 필드가 포함됩니다.

구성 설명 기본값
compactionTaskSlotRatio 모든 워커의 전체 태스크 슬롯 수 대비 컴팩션 태스크가 차지하는 슬롯 수의 비율 0.1
maxCompactionTaskSlots 컴팩션 태스크와 하위 태스크가 차지할 수 있는 태스크 슬롯의 최대 개수. 컴팩션에 사용 가능한 태스크 슬롯의 최소 개수는 1입니다. MSQ 엔진이나 범위 파티셔닝이 있는 Native 엔진을 사용하면 단일 컴팩션 작업이 하나 이상의 태스크 슬롯을 차지합니다. 이 경우 최소값은 2여서, 클러스터에서 적어도 하나의 컴팩션 작업이 항상 실행될 수 있습니다. 2147483647 (즉, 전체 태스크 슬롯)
compactionPolicy 컴팩션용 간격을 선택하는 정책. 지원되는 정책은 Newest segment first, Most fragmented first, Fixed interval order입니다. Newest segment first
useSupervisors Coordinator duty 대신 supervisor를 사용해 Overlord에서 컴팩션을 실행할지 여부 false
engine 데이터소스 수준 컴팩션 구성에서 오버라이드하지 않는 한 컴팩션 태스크를 실행하는 데 사용되는 엔진. 가능한 값은 native와 msq입니다. msq 엔진은 useSupervisors가 true일 때만 컴팩션에 사용할 수 있습니다. native
storeCompactionStatePerSegment 이 구성은 useSupervisors가 true일 때만 적용됩니다. 세그먼트 메타데이터에 전체 컴팩션 상태를 유지할지 여부. true(기본값)이면 컴팩션 상태가 세그먼트 메타데이터와 indexing states 테이블 양쪽에 저장됩니다. 이것은 역사적으로 Druid가 동작해온 방식입니다. false이면 세그먼트 메타데이터에는 지문(fingerprint) 참조만 저장되어 segments 테이블의 저장 오버헤드를 줄입니다. 실제 컴팩션 상태는 indexing states 테이블에 저장되며 위에서 언급한 지문으로 참조할 수 있습니다. 결국 이 구성은 제거되고 모든 컴팩션은 지문 방식만 사용하게 됩니다. 이 구성은 운영자가 이 미래 패턴을 일찍 선택할 수 있도록 존재합니다. 경고: 이 값을 false로 설정하고 데이터를 컴팩션한 뒤, indexing state 지문화가 생기기 이전의 Druid 버전(< Druid 37)으로 롤백하면 컴팩션 상태가 누락되어 이미 컴팩션되었을 수 있는 세그먼트에서 컴팩션이 트리거될 수 있습니다. true
컴팩션 정책 newestSegmentFirst
필드 설명 기본값
type 반드시 newestSegmentFirst여야 함
priorityDatasource 컴팩션을 우선시할 데이터소스. 이 데이터소스의 간격이 다른 데이터소스의 간격보다 먼저 컴팩션되도록 선택됩니다. 이 데이터소스 내에서 간격은 선택된 컴팩션 정책에 따라 우선순위가 매겨집니다. None
컴팩션 정책 mostFragmentedFirst

이 실험적 정책은 작은 미컴팩트 세그먼트를 가장 많이 가진 간격의 컴팩션을 우선시합니다. 더 새로운 간격의 쿼리 성능보다 세그먼트 수를 줄여 클러스터 안정성을 선호합니다.

필드 설명 기본값
type 반드시 mostFragmentedFirst여야 함
priorityDatasource 컴팩션을 우선시할 데이터소스. 다른 데이터소스의 간격보다 먼저 선택됩니다. 이 데이터소스 내에서 간격은 선택된 컴팩션 정책에 따라 우선순위가 매겨집니다. None
minUncompactedCount 간격이 컴팩션 자격을 얻기 위해 그 간격에 존재해야 하는 미컴팩트 세그먼트의 최소 개수. 0보다 커야 합니다. 100
minUncompactedBytes 간격이 컴팩션 자격을 얻기 위해 그 간격에 존재해야 하는 미컴팩트 세그먼트의 최소 총 바이트. 사람이 읽기 좋은 byte 형식(예: "10MiB"). 10 MiB
maxAverageUncompactedBytesPerSegment 컴팩션 자격이 있는 간격의 미컴팩트 세그먼트 최대 평균 크기. 사람이 읽기 좋은 byte 형식(예: "2GiB"). 2 GiB
minUncompactedBytesPercentForFullCompaction 전체 컴팩션 대신 경미한(minor) 컴팩션이 자격을 얻는, 총 바이트 대비 미컴팩트 바이트의 임계 비율(0-100). 0
minUncompactedRowsPercentForFullCompaction 전체 컴팩션 대신 경미한 컴팩션이 자격을 얻는, 총 행 대비 미컴팩트 행의 임계 비율(0-100). 0
컴팩션 정책 fixedIntervalOrder

이 정책은 컴팩션 자격이 있는 데이터소스와 간격, 그리고 그 순서를 지정합니다. 주로 통합 테스트에 사용됩니다.

필드 설명 기본값
type 반드시 fixedIntervalOrder여야 함
eligibleCandidates 컴팩션 자격이 있는 데이터소스-간격 쌍의 목록. 각 항목은 datasource(string)와 interval(ISO-8601 interval) 필드를 포함합니다. 컴팩션은 지정된 순서대로 후보를 처리합니다. None
URL

POST /druid/indexer/v1/compaction/config/cluster

응답
  • 200 SUCCESS — 컴팩션 구성을 성공적으로 업데이트함
  • 404 NOT FOUND — 잘못된 max 값
샘플 요청

cURL

curl --request POST "http://ROUTER_IP:ROUTER_PORT/druid/coordinator/v1/config/compaction/cluster" \
--header 'Content-Type: application/json' \
--data '{
    "compactionTaskSlotRatio": 0.5,
    "maxCompactionTaskSlots": 1500,
    "compactionPolicy": {
        "type": "newestSegmentFirst",
        "priorityDatasource": "wikipedia"
    },
    "useSupervisors": true,
    "engine": "msq"
}'

HTTP

POST /druid/indexer/v1/compaction/config/cluster HTTP/1.1
Host: http://ROUTER_IP:ROUTER_PORT
Content-Type: application/json

{
    "compactionTaskSlotRatio": 0.5,
    "maxCompactionTaskSlots": 1500,
    "compactionPolicy": {
        "type": "newestSegmentFirst",
        "priorityDatasource": "wikipedia"
    },
    "useSupervisors": true,
    "engine": "msq"
}
샘플 응답

성공한 요청은 HTTP 200 OK 메시지 코드와 빈 응답 본문을 반환합니다.

클러스터 수준 컴팩션 구성 가져오기

데이터소스 컴팩션 구성에서 명시적으로 오버라이드하지 않는 한 모든 데이터소스에 적용되는 컴팩션 태스크의 클러스터 수준 구성을 가져옵니다. 여기에는 Update cluster-level compaction config에 나열된 모든 필드가 포함됩니다.

URL

GET /druid/indexer/v1/compaction/config/cluster

응답
  • 200 SUCCESS — 클러스터 컴팩션 구성을 성공적으로 조회함
샘플 요청

cURL

curl "http://ROUTER_IP:ROUTER_PORT/druid/indexer/v1/compaction/config/cluster"

HTTP

GET /druid/indexer/v1/compaction/config/cluster HTTP/1.1
Host: http://ROUTER_IP:ROUTER_PORT
샘플 응답
{
    "compactionTaskSlotRatio": 0.5,
    "maxCompactionTaskSlots": 1500,
    "compactionPolicy": {
        "type": "newestSegmentFirst",
        "priorityDatasource": "wikipedia"
    },
    "useSupervisors": true,
    "engine": "msq"
}

모든 데이터소스의 자동 컴팩션 구성 가져오기

모든 데이터소스 컴팩션 구성을 가져옵니다.

URL

GET /druid/indexer/v1/compaction/config/datasources

응답
  • 200 SUCCESS — 자동 컴팩션 구성을 성공적으로 조회함
샘플 요청

cURL

curl "http://ROUTER_IP:ROUTER_PORT/druid/indexer/v1/compaction/config/datasources"

HTTP

GET /druid/indexer/v1/compaction/config/datasources HTTP/1.1
Host: http://ROUTER_IP:ROUTER_PORT
샘플 응답
{
    "compactionConfigs": [
        {
            "dataSource": "wikipedia_hour",
            "taskPriority": 25,
            "inputSegmentSizeBytes": 100000000000000,
            "maxRowsPerSegment": null,
            "skipOffsetFromLatest": "PT0S",
            "tuningConfig": {
                "maxRowsInMemory": null,
                "appendableIndexSpec": null,
                "maxBytesInMemory": null,
                "maxTotalRows": null,
                "splitHintSpec": null,
                "partitionsSpec": {
                    "type": "dynamic",
                    "maxRowsPerSegment": 5000000,
                    "maxTotalRows": null
                },
                "indexSpec": null,
                "indexSpecForIntermediatePersists": null,
                "maxPendingPersists": null,
                "pushTimeout": null,
                "segmentWriteOutMediumFactory": null,
                "maxNumConcurrentSubTasks": null,
                "maxRetry": null,
                "taskStatusCheckPeriodMs": null,
                "chatHandlerTimeout": null,
                "chatHandlerNumRetries": null,
                "maxNumSegmentsToMerge": null,
                "totalNumMergeTasks": null,
                "maxColumnsToMerge": null,
                "type": "index_parallel",
                "forceGuaranteedRollup": false
            },
            "granularitySpec": {
                "segmentGranularity": "DAY",
                "queryGranularity": null,
                "rollup": null
            },
            "dimensionsSpec": null,
            "metricsSpec": null,
            "transformSpec": null,
            "ioConfig": null,
            "taskContext": null
        },
        {
            "dataSource": "wikipedia",
            "taskPriority": 25,
            "inputSegmentSizeBytes": 100000000000000,
            "maxRowsPerSegment": null,
            "skipOffsetFromLatest": "PT0S",
            "tuningConfig": {
                "maxRowsInMemory": null,
                "appendableIndexSpec": null,
                "maxBytesInMemory": null,
                "maxTotalRows": null,
                "splitHintSpec": null,
                "partitionsSpec": {
                    "type": "dynamic",
                    "maxRowsPerSegment": 5000000,
                    "maxTotalRows": null
                },
                "indexSpec": null,
                "indexSpecForIntermediatePersists": null,
                "maxPendingPersists": null,
                "pushTimeout": null,
                "segmentWriteOutMediumFactory": null,
                "maxNumConcurrentSubTasks": null,
                "maxRetry": null,
                "taskStatusCheckPeriodMs": null,
                "chatHandlerTimeout": null,
                "chatHandlerNumRetries": null,
                "maxNumSegmentsToMerge": null,
                "totalNumMergeTasks": null,
                "maxColumnsToMerge": null,
                "type": "index_parallel",
                "forceGuaranteedRollup": false
            },
            "granularitySpec": {
                "segmentGranularity": "DAY",
                "queryGranularity": null,
                "rollup": null
            },
            "dimensionsSpec": null,
            "metricsSpec": null,
            "transformSpec": null,
            "ioConfig": null,
            "taskContext": null
        }
    ]
}

데이터소스의 자동 컴팩션 구성 가져오기

데이터소스의 자동 컴팩션 구성을 가져옵니다.

URL

GET /druid/indexer/v1/compaction/config/datasources/{dataSource}

응답
  • 200 SUCCESS — 데이터소스의 구성을 성공적으로 조회함
  • 404 NOT FOUND — 잘못된 데이터소스이거나 데이터소스에 자동 컴팩션이 활성화되어 있지 않음
샘플 요청

다음 예시는 wikipedia_hour 데이터소스의 자동 컴팩션 구성을 조회합니다.

cURL

curl "http://ROUTER_IP:ROUTER_PORT/druid/indexer/v1/compaction/config/datasources/wikipedia_hour"

HTTP

GET /druid/indexer/v1/compaction/config/datasources/wikipedia_hour HTTP/1.1
Host: http://ROUTER_IP:ROUTER_PORT
샘플 응답
{
    "dataSource": "wikipedia_hour",
    "taskPriority": 25,
    "inputSegmentSizeBytes": 100000000000000,
    "maxRowsPerSegment": null,
    "skipOffsetFromLatest": "PT0S",
    "tuningConfig": {
        "maxRowsInMemory": null,
        "appendableIndexSpec": null,
        "maxBytesInMemory": null,
        "maxTotalRows": null,
        "splitHintSpec": null,
        "partitionsSpec": {
            "type": "dynamic",
            "maxRowsPerSegment": 5000000,
            "maxTotalRows": null
        },
        "indexSpec": null,
        "indexSpecForIntermediatePersists": null,
        "maxPendingPersists": null,
        "pushTimeout": null,
        "segmentWriteOutMediumFactory": null,
        "maxNumConcurrentSubTasks": null,
        "maxRetry": null,
        "taskStatusCheckPeriodMs": null,
        "chatHandlerTimeout": null,
        "chatHandlerNumRetries": null,
        "maxNumSegmentsToMerge": null,
        "totalNumMergeTasks": null,
        "maxColumnsToMerge": null,
        "type": "index_parallel",
        "forceGuaranteedRollup": false
    },
    "granularitySpec": {
        "segmentGranularity": "DAY",
        "queryGranularity": null,
        "rollup": null
    },
    "dimensionsSpec": null,
    "metricsSpec": null,
    "transformSpec": null,
    "ioConfig": null,
    "taskContext": null
}

데이터소스의 자동 컴팩션 구성 생성 또는 업데이트

데이터소스의 자동 컴팩션 구성을 생성하거나 업데이트합니다. 자동 컴팩션을 요청 본문의 JSON 객체로 전달하세요.

자동 컴팩션 구성은 dataSource 속성만 있으면 됩니다. Druid는 지정되지 않은 다른 모든 속성을 기본값으로 채워요. 구성 세부 사항은 Automatic compaction dynamic configuration을 참고하세요.

이 엔드포인트는 데이터소스 이름이 존재하지 않아도 HTTP 200 OK 메시지 코드를 반환합니다.

URL

POST /druid/indexer/v1/compaction/config/datasources/wikipedia_hour

응답
  • 200 SUCCESS — 자동 컴팩션 구성을 성공적으로 제출함
샘플 요청

다음 예시는 HOUR 세그먼트 세분성으로 수집된 wikipedia_hour 데이터소스의 자동 컴팩션 구성을 생성합니다. 이 자동 컴팩션 구성은 wikipedia_hour에 컴팩션을 수행해 하루 간격의 데이터를 나타내는 컴팩트된 세그먼트를 만듭니다.

이 예시에서:

  • wikipedia_hour는 HOUR 세그먼트 세분성을 가진 데이터소스입니다.
  • skipOffsetFromLatest가 PT0S로 설정되어, 건너뛰는 데이터가 없음을 뜻합니다.
  • partitionsSpec이 기본값인 dynamic으로 설정되어, Druid가 최적의 파티셔닝 전략을 동적으로 결정합니다.
  • type이 index_parallel로 설정되어, 병렬 인덱싱을 사용함을 뜻합니다.
  • segmentGranularity가 DAY로 설정되어, 각 컴팩트된 세그먼트가 하루의 데이터임을 뜻합니다.

cURL

curl "http://ROUTER_IP:ROUTER_PORT/druid/indexer/v1/compaction/config/datasources/wikipedia_hour"\
--header 'Content-Type: application/json' \
--data '{
    "dataSource": "wikipedia_hour",
    "skipOffsetFromLatest": "PT0S",
    "tuningConfig": {
        "partitionsSpec": {
            "type": "dynamic"
        },
        "type": "index_parallel"
    },
    "granularitySpec": {
        "segmentGranularity": "DAY"
    }
}'

HTTP

POST /druid/indexer/v1/compaction/config/datasources/wikipedia_hour HTTP/1.1
Host: http://ROUTER_IP:ROUTER_PORT
Content-Type: application/json
Content-Length: 281

{
    "dataSource": "wikipedia_hour",
    "skipOffsetFromLatest": "PT0S",
    "tuningConfig": {
        "partitionsSpec": {
            "type": "dynamic"
        },
        "type": "index_parallel"
    },
    "granularitySpec": {
        "segmentGranularity": "DAY"
    }
}
샘플 응답

성공한 요청은 HTTP 200 OK 메시지 코드와 빈 응답 본문을 반환합니다.

데이터소스의 자동 컴팩션 구성 삭제

데이터소스의 자동 컴팩션 구성을 제거합니다. 이는 데이터소스의 컴팩션 상태를 "Not enabled"로 업데이트합니다.

URL

DELETE /druid/indexer/v1/compaction/config/datasources/{dataSource}

응답
  • 200 SUCCESS — 자동 컴팩션 구성을 성공적으로 삭제함
  • 404 NOT FOUND — 데이터소스에 자동 컴팩션이 없거나 데이터소스 이름이 잘못됨
샘플 요청

cURL

curl --request DELETE "http://ROUTER_IP:ROUTER_PORT/druid/indexer/v1/compaction/config/datasources/wikipedia_hour"

HTTP

DELETE /druid/indexer/v1/compaction/config/wikipedia_hour HTTP/1.1
Host: http://ROUTER_IP:ROUTER_PORT
샘플 응답

성공한 요청은 HTTP 200 OK 메시지 코드와 빈 응답 본문을 반환합니다.

모든 데이터소스의 컴팩션 상태 가져오기

사용자가 읽기 접근 권한을 가진 모든 데이터소스의 최신 자동 컴팩션 실행 상태와 통계를 나타내는 latestStatus 객체의 배열을 가져옵니다. 응답 페이로드 형식은 Compaction status response와 동일합니다.

URL

GET /druid/indexer/v1/compaction/status/datasources

응답
  • 200 SUCCESS — latestStatus 객체를 성공적으로 조회함
샘플 요청

cURL

curl "http://ROUTER_IP:ROUTER_PORT/druid/indexer/v1/compaction/status/datasources"

HTTP

GET /druid/indexer/v1/compaction/status/datasources HTTP/1.1
Host: http://ROUTER_IP:ROUTER_PORT
샘플 응답
{
    "latestStatus": [
        {
            "dataSource": "wikipedia_api",
            "scheduleStatus": "RUNNING",
            "bytesAwaitingCompaction": 0,
            "bytesCompacted": 0,
            "bytesSkipped": 64133616,
            "segmentCountAwaitingCompaction": 0,
            "segmentCountCompacted": 0,
            "segmentCountSkipped": 8,
            "intervalCountAwaitingCompaction": 0,
            "intervalCountCompacted": 0,
            "intervalCountSkipped": 1
        },
        {
            "dataSource": "wikipedia_hour",
            "scheduleStatus": "RUNNING",
            "bytesAwaitingCompaction": 0,
            "bytesCompacted": 5998634,
            "bytesSkipped": 0,
            "segmentCountAwaitingCompaction": 0,
            "segmentCountCompacted": 1,
            "segmentCountSkipped": 0,
            "intervalCountAwaitingCompaction": 0,
            "intervalCountCompacted": 1,
            "intervalCountSkipped": 0
        }
    ]
}

단일 데이터소스의 컴팩션 상태 가져오기

데이터소스의 최신 자동 컴팩션 실행에서의 최신 상태를 가져옵니다. 응답 페이로드 형식은 Compaction status response와 동일하며 0개 또는 1개의 항목을 가집니다.

URL

GET /druid/indexer/v1/compaction/status/datasources/{dataSource}

응답
  • 200 SUCCESS — latestStatus 객체를 성공적으로 조회함
샘플 요청

cURL

curl "http://ROUTER_IP:ROUTER_PORT/druid/indexer/v1/compaction/status/datasources/wikipedia_hour"

HTTP

GET /druid/indexer/v1/compaction/status/datasources/wikipedia_hour HTTP/1.1
Host: http://ROUTER_IP:ROUTER_PORT
샘플 응답
{
    "latestStatus": [
        {
            "dataSource": "wikipedia_hour",
            "scheduleStatus": "RUNNING",
            "bytesAwaitingCompaction": 0,
            "bytesCompacted": 5998634,
            "bytesSkipped": 0,
            "segmentCountAwaitingCompaction": 0,
            "segmentCountCompacted": 1,
            "segmentCountSkipped": 0,
            "intervalCountAwaitingCompaction": 0,
            "intervalCountCompacted": 1,
            "intervalCountSkipped": 0
        }
    ]
}

더 알아보기 (Learn more)

  • 자동 컴팩션의 전체 개념은 automatic compaction 문서를 참고하세요.
  • 컴팩션 supervisor를 사용하려면 supervisor API 문서를 확인해 보세요.