management¶
/usr/local/m2/setting.json 다음 영역에 대해 기술한다.
{
"env": {
"management": {
...
}
}
}
api¶
API 호출 접근제어를 설정한다.
"api": {
"port": 10040,
"defaultRole": "admin",
"multipartName": "settingFile",
"allowList": [
{
"addr": "192.168.1.1"
},
{
"role": "admin",
"addr": "192.168.2.1-255"
},
{
"role": "user",
"addr": "192.168.3.0/24"
}
]
}
port (기본: 10040)관리 API 포트
defaultRole (기본: admin)기본 접근권한을 설정한다. 접근권한이 없는 요청에 대해서는
401 Unauthorized로 응답한다.역할(role)은 roles 에서 설정한다.
allowList[].role설정을 명시적으로 선언하지 않을 경우defaultRole을 참조한다.
multipartName (기본: settingFile)설정 업로드 에서 사용할 Multipart 이름
allowList접근제어 목록
role접근권한
addr접근 IP 허가
# IP 192.168.1.1 # IP Range 192.168.2.1-255 # IP Bitmask 192.168.3.0/24 # IP Subnet 192.168.4.0/255.255.255.0
roles¶
API 호출 역할/권한을 설정한다.
다음은 최초 배포되는 setting.json 의 기본 설정이다.
"roles": [
{
"name": "admin",
"permissions": {
"enableSetting": true,
"enablePurge": true,
"enableMetric": true,
"enableGraph": true,
"enableMonitoring": true,
"enableInstall": false,
"enableRestart": false,
"enableGet": true,
"enableCluster": true
}
},
{
"name": "user",
"permissions": {
"enableMetric": true,
"enableGraph": true
"enableMonitoring": true,
"enableGet": true
}
}
]
nameRole 명칭
permissionsAPI 호출 권한
enableSetting (기본: false)/setting API 호출 권한
enablePurge (기본: false)캐싱콘텐츠 무효화 API 호출 권한
enableMetric (기본: false)/metrics API 호출 권한
enableGraph (기본: false)/graph API 호출 권한
enableMonitoring (기본: false)서비스 모니터링 API , 기타 조회 API 호출 권한
enableInstall (기본: false)패키지 업데이트/재설치 API 호출 권한
enableRestart (기본: false)패키지 재구동/중지 API 호출 권한
enableGet (기본: true)/get API alpha 호출 권한
enableCluster (기본: false)m2 cluster 호출 권한
server¶
독립적으로 가동되는 개별 노드를 중앙집중형으로 관리하는 설정을 기술한다.
{
"env": {
"management": {
"server": {
"enable": false,
"features": { ... },
"events": { ... }
}
}
}
}
enable (기본: false)
false (기본)기능이 비활성화된다.
true기능이 활성화된다.
connection¶
features , events 에서 공통으로 사용할 연결정보를 관리한다.
{
"env": {
"management": {
"server": {
"connection": [
{
"name": "myKafka",
"type": "kafka",
"info": {
"clientId": "my-app",
"brokers": [
"b-1.msk-prod-seoul-so.kafka.ap-northeast-2.amazonaws.com:9092",
"b-2.msk-prod-seoul-so.kafka.ap-northeast-2.amazonaws.com:9092",
"b-3.msk-prod-seoul-so.kafka.ap-northeast-2.amazonaws.com:9092"
]
}
},
{
"name": "myFirebase",
"type": "firebasePubsub",
"info": {
"apiKey": "4JVGwsyDDLFgv6PQnLAIza5jZeTASyvdknDiGTB",
"authDomain": "test-api.firebaseapp.com",
"databaseUrl": "https://test-api.firebaseio.com",
"projectId": "test-api",
"storageBucket": "test-api.appspot.com",
"messagingSenderId": "374667268081",
"appId": "1:370817000000:web:d8546f78b2330000000000"
}
},
{
"name": "myAws",
"type": "httpAwsSig4",
"info": {
"accessKeyId": "key",
"secretAccessKey": "key",
"region": "region",
"bucket": ""
}
},
{
"name": "myAwsSdk",
"type": "awssdk3",
"info": {
"accessKeyId": "key",
"secretAccessKey": "key",
"region": "us-east-1"
}
},
{
"name": "myOci",
"type": "oci",
"info": {
"tenancyId": "ocid1.tenancy.oc1..aaaaaaa",
"userId": "ocid1.user.oc1..aaaaaaa",
"compartmentId": "ocid1.compartment.oc1..aaaaaaaaxxxxxx",
"fingerprint": "fingerprint",
"privateKey": "key.pem",
"region": "us-phoenix-1"
}
}
]
}
}
}
}
name연결 이름. 중복될 수 없다.
type
kafka- kafka 연결
firebasePubsub- firebasePubsub 연결
httpAwsSig4- httpAwsSig4 인증
awssdk3- awssdk3 인증
oci- oci 인증
kafka 연결¶
type: kafka 연결에 대해 설정한다.
"info": {
"clientId": "my-app",
"brokers": [
"b-2.msk-prod-seoul-so.rmq7bb.c2.kafka.ap-northeast-2.amazonaws.com:9092",
"b-5.msk-prod-seoul-so.rmq7bb.c2.kafka.ap-northeast-2.amazonaws.com:9092",
"b-1.msk-prod-seoul-so.rmq7bb.c2.kafka.ap-northeast-2.amazonaws.com:9092"
]
}
infoKafka 연결정보
firebasePubsub 연결¶
type: firebasePubsub 트리거 연결에 대해 설정한다.
"info": {
"apiKey": "4JVGwsyDDLFgv6PQnLAIza5jZeTASyvdknDiGTB",
"authDomain": "test-api.firebaseapp.com",
"databaseUrl": "https://test-api.firebaseio.com",
"projectId": "test-api",
"storageBucket": "test-api.appspot.com",
"messagingSenderId": "374667268081",
"appId": "1:370817000000:web:d8546f78b2330000000000"
}
httpAwsSig4 인증¶
type: httpAwsSig4 연결에 대해 설정한다.
"info": {
"accessKeyId": "...",
"secretAccessKey": " ",
"region": "...",
"bucket": "..."
}
accessKeyIdAWS 액세스 키
secretAccessKeyAWS 보안 액세스 키
regionAWS 리젼
bucketAWS 버킷 (단순 인증용이라면 비어있어도 된다.)
awssdk3 인증¶
AWS SDK for JavaScript v3 를 사용하는 type: awssdk3 연결에 대해 설정한다.
"info": {
"accessKeyId": "...",
"secretAccessKey": " ",
"region": "..."
}
accessKeyIdAWS 액세스 키
secretAccessKeyAWS 보안 액세스 키
regionAWS 리젼
oci 인증¶
OCI SDK 를 사용하는 type: oci 연결에 대해 설정한다.
"info": {
"tenancyId": "ocid1.tenancy.oc1..aaaaaaa",
"userId": "ocid1.user.oc1..aaaaaaa",
"compartmentId": "ocid1.compartment.oc1..aaaaaaaaxxxxxx",
"fingerprint": "fingerprint",
"privateKey": "key.pem",
"region": "us-phoenix-1"
}
tenancyIdOCI 테넌시 ID
userIdOCI 사용자 ID
compartmentIdOCI compartment ID
fingerprintOCI fingerprint
privateKeyOCI key 파일
regionOCI 리전
features¶
기능별로 동기화 구성을 진행한다.
{
"env": {
"management": {
"server": {
"features": {
...
}
}
}
}
}
Note
모든 polling 방식은 변경지점 보고를 위해 다음과 같이 동작한다.
feedUrl에서 응답한Last-Modified헤더를 기억한다.현재 로딩된
setting.json의meta.version값을 기억한다.polling 시마다 다음과 같이 헤더를 명시한다.
GET /setting/deploy HTTP/1.1 If-Modified-Since: {이전 Last-Modified 헤더 값} X-M2-Setting-Meta-Version: {현재 meta.version의 값}
setting¶
설정동기화를 구성한다.
"setting": {
"enable": false,
"feed": {
"type": "",
"info": { }
},
"feedback": {
"type": "",
"info": { },
"uploadSetting": true
}
}
enable (기본: false)설정동기화 활성화
feed설정동기화 감지
type설정동기화 감지타입. ( setting.feed 포맷 참조)
apiPollingAPI를GET메소드로 polling 한다."info": { "url": "https://example.com/setting/deploy", "schedule": "*/15 * * * * *", "timeout": 5 }
urlpolling URLschedulepolling 스케쥴. cron 형식timeoutHTTP 트랜잭션 타임아웃
tgzPolling설정패키지를GET메소드로 폴링한다."info": { "url": "https://example.com/setting/setting.tgz", "schedule": "*/15 * * * * *", "timeout": 5 }
urlpolling URLWarning
서버는 응답 데이터로 설정패키지
tgz파일을 전송해야 한다.schedulepolling 스케쥴. cron 형식timeoutHTTP 트랜잭션 타임아웃
kafkaSubKafka 이벤트를 subscribe 한다."info": { "connect": "myKafka", "groupId": "prd.itemimg.consumer.grp", "subscribe": { "topic": "prd.m2.event.changed", "fromBeginning": true } }
connectkafka 연결명. connection 중type: kafka인name만 가능하다.groupIdkafka 그룹IDsubscribekafka 수신정보
firestorefirestore 로부터 이벤트를 subscribe 한다."info": { "connect": "myFirebase", "doc": "m2nodes/4FD30000-5B00-1100-8200-5404A600000/events" }
connectfirestore 연결명. connection 중type: firebasePubsub인name만 가능하다.doc수신(listen) 할 document
Note
M2Live에 연결된 노드라면
#m2live.nodeId키워드로 개별노드 이벤트를 수신할 수 있다."info": { "connect": "myFirebase", "doc": "m2nodes/#m2live.nodeId/events" }
info설정동기화 감지정보
feedback설정동기화 결과 피드백. ( setting.feedback 포맷 참조)
type설정동기화 결과 피드백 타입
apiAPI를POST메소드로 호출한다."info": { "url": "https://example.com/setting/feedback", "timeout": 5 }
url설정동기화 후 호출할 URLtimeoutHTTP 트랜잭션 타임아웃
kafkaPubKafka로 publish한다."info": { "connect": "myKafka", "topic": "prd.m2.awscdn.event.changed" }
connectkafka 연결명. connection 중type: kafka인name만 가능하다.topickafka topic
firestorefirestore로 피드백 한다."info": { "connect": "myFirebase", "doc": "m2nodes/4FD30000-5B00-1100-8200-5404A600000/events" }
connectfirestore 연결명. connection 중type: firebasePubsub인name만 가능하다.docfeedback을 기록할 document
info설정동기화 결과 피드백
uploadSetting (기본: true)false라면 설정변경 후 피드백 시점에setting.json을 같이 보고한다.
purge¶
캐싱콘텐츠 무효화 API 를 구성한다.
"purge": {
"enable": false,
"workerCount": 2
"feed": {
"type": "",
"info": { }
},
"feedback": {
"type": "",
"info": { }
}
}
enable (기본: false)콘텐츠무효화 활성화
workerCount (기본: 2)worker 수.
0으로 설정할 경우 CPU 개수만큼 생성된다.feed콘텐츠무효화 감지 ( purge.feed 포맷 참조)
type콘텐츠무효화 감지타입
apiPollingAPI를GET메소드로 polling 한다."info": { "url": "https://example.com/purge", "schedule": "*/15 * * * * *", "timeout": 5 }
urlpolling URLschedulepolling 스케쥴. cron 형식timeoutHTTP 트랜잭션 타임아웃
kafkaSubKafka 이벤트를 subscribe 한다."info": { "connect": "myKafka", "groupId": "prd.itemimg.consumer.grp", "subscribe": { "topic": "prd.m2.event.changed", "fromBeginning": true } }
connectkafka 연결명. connection 중type: kafka인name만 가능하다.groupIdkafka 그룹IDsubscribekafka 수신정보
info콘텐츠무효화 감지정보
feedback콘텐츠무효화 결과 피드백
type콘텐츠무효화 결과 피드백 타입 ( purge.feedback 포맷 참조)
apiAPI를POST메소드로 호출한다."info": { "url": "https://example.com/setting/feedback", "timeout": 5 }
url설정동기화 후timeoutHTTP 트랜잭션 타임아웃
kafkaPubKafka로 publish한다."info": { "connect": "myKafka", "topic": "prd.m2.awscdn.event.changed" }
connectkafka 연결명. connection 중type: kafka인name만 가능하다.topickafka topic
heartbeat¶
일정주기마다 heartbeat 를 전송한다.
"heartbeat": {
"enable": false,
"feedback": {
"type": "",
"info": { }
}
}
enable (기본: false)heartbeat 활성화
feedbackheartbeat 보고방법
typeheartbeat 타입 ( heartbeat.feedback 포맷 참조)
apiPolling대상 API를 주기적으로POST메소드로 호출한다."info": { "url": "https://example.com/heartbeat/feedback", "timeout": 5, "schedule": "*/15 * * * * *" }
url보고 URLtimeoutHTTP 트랜잭션 타임아웃scheduleheartbeat 스케쥴. cron 형식
kafkaPubKafka로 publish한다."info": { "connect": "myKafka", "topic": "prd.m2.awscdn.event.changed", "schedule": "*/15 * * * * *" }
connectkafka 연결명. connection 중type: kafka인name만 가능하다.topickafka topic
firestorefirestore로 피드백 한다."info": { "connect": "myFirebase", "doc": "m2nodes/4FD30000-5B00-1100-8200-5404A600000/events", "schedule": "*/15 * * * * *" }
connectfirestore 연결명. connection 중type: firebasePubsub인name만 가능하다.docfeedback을 기록할 document
클라우드 자원 연결¶
connection 을 이용하여 다음 기능에 대해 클라우드 동적자원 연결을 지원한다.
See also
표기 |
설정 |
|---|---|
|
|
|
# tag된 vm목록
aws:vm:tag=test_farm
oci:vm:tag=test_farm
# tag된 vvip
aws:vip:tag=test_farm_lb
oci:vip:tag=test_farm_lb
획득된 동적 IP등에 특정 포트를 연결하고 싶다면 뒤에 # 를 추가한 후 설정한다.
#aws:vm:tag=test_farm#:8080
nodelist deprecated¶
동적노드 리스트 변경을 감지한다.
"nodelist": {
"enable": false,
"feed": {
"type": "",
"info": { }
},
"feedback": {
"type": "",
"info": { }
}
}
enable (기본: false)동적노드 리스트 활성화
feed동적노드 리스트 감지
type동적노드 리스트 감지타입
awssdk3DescribeInstancesCommand 를 사용하여 인스턴스 목록을 조회한다.ociOCI SDK 를 사용하여 인스턴스 목록을 조회한다.
info동적노드 리스트 감지 정보
type이awssdk3인 경우"info": { "connect": "myAwsSdk", "tag": "type=parent;type=child;", "schedule": "*/15 * * * * *" }
connectAWS SDK for JavaScript v3 연결명. connection 중type: awssdk3인name만 가능하다.tag필터링할 태그목록. 키와 값이 모두 존재한다면키=값;또는 키만 존재한다면키=;를 설정한다.
Note
아래 정책을 모두 만족하는 인스턴스를 사용한다.
Reservations[].Instances[].Tags[]의 값이tag목록 중 하나와 일치Reservations[].Instances[].State.Code의 값이16Reservations[].Instances[].State.Name의 값이RunningReservations[].Instances[].PrivateIpAddress값
Warning
인스턴스 재기동으로 인한 노드 중단은 DescribeInstancesCommand 로 정확히 감지가 어렵다. exclusion 기능을 통해 중단된 서버가 자동 배제/복구되긴 하지만 가급적 재부팅 전후에
Tag제거/복구 작업을 병행하도록 권장한다.schedulepolling 스케쥴. cron 형식
type이oci인 경우"info": { "connect": "myOci", "tag": "type=parent;type=child;", "schedule": "*/15 * * * * *" }
connectOCI SDK 연결명. connection 중type: oci인name만 가능하다.tag필터링할 태그목록. 키와 값이 모두 존재한다면키=값;또는 키만 존재한다면키=;를 설정한다.
Note
아래 정책을 모두 만족하는 인스턴스를 사용한다.
Instances[].FreeFormTags[]의 값이tag목록 중 하나와 일치Instances[].LifecycleState의 값이RUNNING
feedback동적노드 리스트 피드백
type동적노드 리스트 피드백 타입
setting설정을 변경한다.apiAPI를POST메소드로 호출한다.
Note
설정변경 후 API호출을 동시에 진행하고 싶다면 다음과 같이 결합하여 설정한다.
"type": "setting;api;"
info동적노드 리스트 피드백 정보
type이setting인 경우"info": { "hosting": [ { "name": "foo.com", "field": "origin.address" }, { "name": "bar.com", "field": "origin.address" } ] }
setting.json형상을 변경하는 것이 아니라 구동되는 가상호스트 런타임 정보만을 수정한다.hosting[].name설정을 변경할 가상호스트hosting[].field설정필드. 현재는origin.address만 지원한다.
type이api인 경우 ( nodelist.feedback 포맷 포맷 참조)"info": { "url": "https://example.com/nodelist/feedback", "timeout": 5 }
events¶
특정 이벤트가 발생하는 시점에 약속된 동작을 수행한다.
{
"env": {
"management": {
"server": {
"events": {
...
}
}
}
}
}
onSettingLoad¶
설정변경 이벤트가 발생할 경우 설정패키지를 백업한다.
"onSettingLoad": {
"backup": {
"enable": false,
"hostname": "",
"auto": true,
"connect": "myStorage",
"path": "",
"timeout": 30
}
}
backup백업 정책.
Note
모든 설정을
tgz파일로 압축하고 파일명을ISO8601형식(특수문자 제거)으로 변경한다.setting_20220713T141030000Z.tgz
tgz파일을{bucket}의 다음 경로로 업로드한다./{path}/settings/{yyyy}/{mm}/setting_20220713T141030000Z.tgz
setting.feed 포맷 파일을 다음 경로로 업로드한다.
/{path}/feed.json
enable (기본: false)AWS S3 백업기능 활성화
hostname동일한 hostname에서만 동작한다.
Warning
이 값을 지정하지 않고 설정이 동기화된다면 모든 노드가 설정을 백업하게 되므로 주의해야 한다.
auto (기본: true)모든 설정변경 후 자동으로 설정을 백업한다.
connecthttpAwsSig4 인증 연결명
path설정업로드 경로
timeout (기본: 30초)타임아웃. 트랜잭션이 실패하면 설정을 백업하기 위해 계속 시도한다.
onPurgeRequest¶
캐싱콘텐츠 무효화 API 호출을 받은 경우 API를 전파한다.
"onPurgeRequest": {
"propagation": {
"enable": false,
"nodelist": [ "1.1.1.1", "1.1.1.2" ]
}
}
Warning
이 기능은 소규모 서비스 용도로 최대 8기 까지만 구성이 가능하다.
전파시점은 API 요청이 인지되는 시점으로 실행 이전이다.
단 1회만 전파된다.
내 IP로는 전파되지 않는다.
대상서버의 수신을 보장하지 않는다.
propagation캐싱콘텐츠 무효화 API 전파설정
enable캐싱콘텐츠 무효화 API 전파를 활성화한다.
nodelist (최대 8개)자신을 포함한 전파대상 노드 리스트
메시지 포맷 v1¶
동기화 과정에서 사용되는 메시지 포맷에 대해 기술한다. 메시지 포맷은 공통규격을 가진다.
{
"messageVer": "1",
"timestamp": "2022-07-13T14:10:30.000Z",
"node": {
"productVer": "2.8.1",
"settingVer": "2022-06-21-A",
"hostname": "test",
"iplist": ["10.10.10.1", "10.10.10.2"]
},
"userdata": null,
"action": {
"api": "",
"event": ""
},
"parameters": [ ]
}
messageVer (기본: "1")버전. 항상 1이다.
timestamp응답시점의 서버 타임스탬프
ISO Date형식이다.node(피드백 메시지에만 명시) 메시지를 수신한 노드 정보
productVer (기본: "1")M2 제품버전
settingVersetting 버전 버전. 항상 1이다.
hostname노드 호스트네임
iplistIP 리스트
userdata유저 데이터. 수신받은
userdata는feedback호출 메시지에 그대로 포함된다.action노드에 전달할 행위
api호출할 M2 API
event(피드백 메시지에만 명시)
action이 수행된 이벤트.event종류는 다음과 같다.action.event설명
/env/management/server/apiPolling/{name}중앙서버로부터 api polling
/env/management/server/tgzPolling/{name}중앙서버로부터 tgz polling
/env/management/server/kafkaSub/{name}중앙서버로부터 kafka subscribe
/_api_/{api}API 직접호출
/_sys_/bootup서비스 재기동
/_sys_/cli/{command}CLI 호출 (구분자는
.)
parametersapi의 파라미터 리스트로 수행된 결과는 각 배열의 아이템에result로 추가된다.
setting.feed 포맷¶
feed 포맷은 다음과 같다.
{
"messageVer": "1",
"userdata": null,
"action": {
"api": "/setting/upload"
},
"timestamp": "2022-07-13T14:10:30.000Z",
"parameters": [
{
"url": "http://www.example.com/m2pkg_v10.tgz",
}
]
}
actionapi/setting/upload를 사용한다.
parameters[].url다운로드 받을 설정패키지 URL.
setting.feed 포맷 deploy checkout¶
git 리파지토리가 연결된 상태라면, /setting/deploy/checkout API를 이용해 설정동기화를 진행한다.
{
"messageVer": "1",
"timestamp": "2022-07-13T14:10:30.000Z",
"userdata": null,
"action": {
"api": "/setting/deploy/checkout"
}
}
이 경우 setting.feed 는 Notification으로만 사용되며, setting.feedback 은 동일하다.
setting.feedback 포맷¶
Note
feedback.type 이 api 인 경우 POST 메소드로 다음과 같이 요청한다.
POST /{env.management.server.featrues.setting.feedback.info.url} HTTP/1.1
Content-Type: application/json
Host: example.com
Connection: keep-alive
Content-Length: 645
업로드되는 메시지 규격은 다음과 같다.
{
"messageVer": "1",
"node": {
"productVer": "2.8.1",
"settingVer": "2022-06-21-A",
"licenseId": "KR200099999",
"hostname": "test",
"iplist": ["10.10.10.1", "10.10.10.2"]
},
"userdata": null,
"action": {
"api": "/setting/upload",
"event": "/env/management/server/kafkaSub/myKafka"
},
"parameters": [
{
"url": "http://www.example.com/m2pkg_v10.tgz",
"result": {
"version": "22.02.0",
"method": "deploy",
"status": "ok",
"lastModified": "Tue, 15 Oct 2022 12:45:26 GMT",
"version": 10
}
}
],
"setting": null
}
actionevent설정변경 이벤트 시점
/_sys_/bootup솔루션 재기동 시점/env/management/server/{type}/{name}최초 연결 또는 feed 수신 시점
result수행결과
versionM2 버전
methodM2 실행모듈명
status성공인 경우
ok, 이외엔 실패 이유lastModified설정패키지의
Last-Modified헤더 값version반영된
setting.json의meta.version값
Note
setting .feedback.uploadSetting 설정이 true 라면 다음과 같이 로딩된 setting.json 이 메시지에 추가된다.
{
"messageVer": "1",
... (생략) ...
"setting": {
"meta": ...,
...
"hosting": [
...
]
}
}
purge.feed 포맷¶
feed 메시지 규격은 다음과 같다.
{
"messageVer": "1",
"timestamp": "2022-07-13T14:10:30.000Z",
"userdata": null,
"action": {
"api": "/command/purge",
},
"parameters": [
{
"url": "http://www.site1.com/image.jpg",
},
{
"url": "www.site1.com/image/*.bmp"
},
{
"url": "www.site2.com/page/*.html"
}
]
}
purge.feedback 포맷¶
Note
feedback.type 이 api 인 경우 POST 메소드로 다음과 같이 요청한다.
POST /{env.management.server.featrues.purge.feedback.info.url} HTTP/1.1
Content-Type: application/json
Host: example.com
Connection: keep-alive
Content-Length: 457
feedback 은 메시지 포맷은 다음과 같다.
{
"messageVer": "1",
"node": {
"productVer": "2.8.1",
"settingVer": "2022-06-21-A",
"licenseId": "KR200099999",
"hostname": "test",
"iplist": ["10.10.10.1", "10.10.10.2"]
},
"userdata": null,
"action": {
"api": "/command/purge",
"event": "/env/management/server/kafkaSub/myKafka"
},
"parameters": [
{
"url": "http://www.site1.com/image.jpg",
"result": {
"version": "22.02.0",
"method": "purge",
"status": "OK",
"result": {
"count": 3,
"size": 77656899,
"time": 12
}
}
},
{
"url": "www.site1.com/image/*.bmp",
"result": {
"version": "22.02.0",
"method": "purge",
"status": "Bad Gateway",
"result": {
"count": 1,
"size": 1024,
"time": 1
}
}
},
{
"url": "www.site2.com/page/*.html",
"result": {
"version": "22.02.0",
"method": "purge",
"status": "OK",
"result": {
"count": 0,
"size": 0,
"time": 0
}
}
}
]
}
heartbeat.feedback 포맷¶
Note
feedback.type 이 api 인 경우 POST 메소드로 다음과 같이 요청한다.
POST /{env.management.server.featrues.heartbeat.feedback.info.url} HTTP/1.1
Content-Type: application/json
Host: example.com
Connection: keep-alive
Content-Length: 210
feedback 포맷은 다음과 같다.
{
"messageVer": "1",
"node": {
"productVer": "2.8.1",
"settingVer": "2022-06-21-A",
"licenseId": "KR200099999",
"hostname": "test",
"iplist": ["10.10.10.1", "10.10.10.2"]
}
}
nodelist.feedback 포맷¶
Note
feedback.type 이 api 인 경우 POST 메소드로 다음과 같이 요청한다.
POST /{env.management.server.featrues.nodelist.feedback.info.url} HTTP/1.1
Content-Type: application/json
Host: example.com
Connection: keep-alive
Content-Length: 457
feedback 은 메시지 포맷은 다음과 같다. hosting[].updated.values 의 값이 nodelist 값으로 일괄 변경된다.
{
"messageVer": "1",
"node": {
"productVer": "2.8.1",
"settingVer": "2022-06-21-A",
"licenseId": "KR200099999",
"hostname": "test",
"iplist": ["10.10.10.1", "10.10.10.2"]
},
"nodelist": [ "5.5.5.5", "6.6.6.6", "7.7.7.7" ];
"hosting": [
{
"name": "foo.com",
"updated": {
"field": "origin.address",
"values": [ "10.10.10.10", "10.10.10.11" ]
}
},
{
"name": "bar.com",
"updated": {
"field": "origin.address",
"values": [ "10.10.10.11", "10.10.10.12" ]
}
}
]
}
cluster¶
동일한 목적의 노드를 클러스터로 구성, 관리하는 방법에 대해 기술한다.
meta¶
"meta": {
"enable": false,
"baseHostingPort": 9000
}
enable (기본: false)클러스터링 기능을 활성화한다.
baseHostingPort (기본: 9000)클러스터링 기능이 활성화되면 hosting 은 지정된 포트를 기준으로
listen포트를 사용한다.
discover¶
"discover": {
"port": 9900,
"members": [ "50.116.40.137", "172.105.158.148" ]
}
port (기본: 9900)클러스터링 관리포트
members (기본: null)null이라면 broadcast로 멤버를 찾으며, IP가 지정되면 unicast로 멤버와 통신한다.
클라우드 환경이라면 멤버를 동적으로 구성할 수 있다.
"discover": {
"port": 9900,
"members": [ "#oci:vm:tag=mystyle" ]
}
특정 포트등을 명시하고 싶다면 아래와 같이 표현한다.
"discover": {
"port": 9900,
"members": [ "#oci:vm:tag=mystyle#:9900" ]
}
문쟈열 치환방식으로 동작한다.
See also
balance¶
"balance": {
"mode": "rr",
"luaPath": "/usr/local/m2/script.lua",
"urlIgnoreList": [
"proxy",
"#FUNCTION"
]
}
mode (기본: rr)클러스터 멤버간 요청 분산을 위한 로드밸런싱 방식을 설정한다.
rr라운드로빈 방식으로 로드밸런싱한다.hash요청 URL을 해시하여 노드를 선택한다.
luaPath (기본: null)mode가hash모드일 떄 Lua 스크립트를 사용하여 hash를 수행한다. 값이 없을 경우, URL 기반으로 hash를 수행한다.urlIgnoreList (기본: ["#FUNCTION"])mode가hash모드일 때 매칭되는 URL 영역부터 hash 정책에서 무시한다.#FUNCTION키워드를 사용하면 URL에 추가된 함수체인 키워드를 무시하고 원본 URL로 hash를 수행한다.
stats¶
"stats": {
"enable": true,
"listen": "127.0.0.1:10038"
}
enable (기본: true)클러스터 통계 정보를 수집한다.
listen (기본: 127.0.0.1:10038)클러스터 통계 정보를 수집하기 위한 리스닝 주소와 포트를 설정한다.
함수기반 라우팅¶
클러스터 내에서 함수단위로 라우팅을 지원한다. 다음과 같은 상황을 가정한다.
이미지/비디오 서비스 도메인등이 메인 트래픽(www, m)과 통합되어 있다.
로드밸런서가 M2Live 클러스터로 트래픽을 RR 분산한다.
PageSpeed,PageFx엔진의 처리성능을 보장하고 싶다.
1, 2번 노드는 PageSpeed, 3, 4번 노드는 나머지 함수를 수행한다.¶
이런 경우는 discover 의 .members 를 그룹으로 구성한다.
"discover": {
"port": 9900,
"members": [
{
"functions": [ "all" ]
"nodes": [ "10.10.10.1", "10.10.10.2" ]
},
{
"nodes": [ "10.10.10.3", "10.10.10.4" ],
"balance": {
"mode": "hash"
}
}
]
}
functions (기본: null)라우팅하고 싶은 함수의 고유 이름을 배열로 선언한다.
"all"은 모든 함수를 의미한다.null은 어떤 함수도 매칭되지 않음을 의미한다.
nodesIP 주소 배열
balancebalance 설정을 오버라이딩할 수 있다.
mode만 가능하다.
위 구성에 의하면 모든 함수체인 호출은 [ "10.10.10.1", "10.10.10.2" ] 로 라우팅되며, 함수체인이 명시되지 않은 요청은 [ "10.10.10.3", "10.10.10.4" ] 로 라우팅된다.
Warning
만약 위 설정에서 아래 필드가 선언되어 있지 않다면, 트래픽이 유입된 노드에서 처리한다.
{
"nodes": [ "10.10.10.3", "10.10.10.4" ]
}
라우팅은 선언된 순서대로 매칭된다.
"discover": {
"port": 9900,
"members": [
{
"functions": [ "hyperdims" ]
"nodes": [ "10.10.10.1", "10.10.10.2" ]
},
{
"functions": [ "transcoder" ]
"nodes": [ "10.10.10.3", "10.10.10.4" ]
}
]
}
위 설정 상태에서 /sample.mp4/xcdr/capture/0.0/hdims/resize/100 호출은 hyperdims 함수에 먼저 매칭되었기에 1, 2번기로 라우팅된다.
다음 아래 사니리오를 가정한 복잡한 예시이다.
hyperdims만 1, 2번기가 RR로 처리한다.transcoder,render만 3, 4번기가 HASH 분산한다.그 외 모든 함수는 5, 6번 기가 처리한다.
위 시나리오에서 매칭되지 않은 요청은 현재 노드에서 처리한다.
"discover": {
"port": 9900,
"members": [
{
"functions": [ "hyperdims" ]
"nodes": [ "10.10.10.1", "10.10.10.2" ],
"balance": {
"mode": "rr"
}
},
{
"functions": [ "transcoder", "render" ]
"nodes": [ "10.10.10.3", "10.10.10.4" ],
"balance": {
"mode": "hash"
}
},
{
"functions": [ "all" ]
"nodes": [ "10.10.10.5", "10.10.10.6" ],
}
]
}