참고: Go 1.11은 2024년 1월 30일 지원 종료되었습니다. 기존 Go 1.11 애플리케이션을 계속 실행하고 트래픽을 수신합니다. 그러나 지원 종료 날짜 이후에는 해당 런타임을 사용하는 애플리케이션의 재배포를 App Engine에서 차단할 수 있습니다.
지원되는 최신 Go 버전으로 마이그레이션하는 것이 좋습니다.
임대 요청 시 임대할 작업 수(최대 1,000개 작업)와 임대 기간(초 단위, 최대 1주)을 지정합니다. 임대 기간이 만료되기 전에 가장 느린 태스크를 마칠 수 있을 만큼 임대 기간이 길어야 합니다. taskqueue.ModifyLease를 사용하여 태스크 임대를 수정할 수 있습니다.
태스크를 임대하면 다른 작업자가 이 태스크를 처리할 수 없으며 임대가 만료될 때까지 계속 사용할 수 없습니다.
여러 태스크를 서로 구분하기 위해 코드에서 태스크에 '태그'를 지정한 후 태그를 사용하여 임대할 태스크를 선택할 수 있습니다. 태그는 필터로 동작합니다. 다음 코드 샘플은 작업을 태그한 후 태그별로 임대하는 방법을 보여 줍니다.
_,err=taskqueue.Add(ctx,&taskqueue.Task{Payload:[]byte("parse"),Method:"PULL",Tag:"parse",},"pull-queue")_,err=taskqueue.Add(ctx,&taskqueue.Task{Payload:[]byte("render"),Method:"PULL",Tag:"render",},"pull-queue")// leases render tasks, but not parsetasks,err=taskqueue.LeaseByTag(ctx,100,"pull-queue",3600,"render")// Leases up to 100 tasks that have same tag.// Tag is that of "oldest" task by ETA.tasks,err=taskqueue.LeaseByTag(ctx,100,"pull-queue",3600,"")
폴링 속도 조절
임대할 태스크의 큐를 폴링하는 작업자는 큐가 공급할 수 있는 것보다 더 빠르게 태스크를 임대하려 하는지 감지해야 합니다. 이 오류가 발생하면 백오프 오류가 taskqueue.Lease에서 반환됩니다.
코드는 이러한 오류를 처리하고 taskqueue.Lease 호출을 보류한 후 나중에 다시 시도해야 합니다. 이 문제를 방지하려면. taskqueue.Lease를 호출할 때 더 높은 RPC 최종 기한을 설정하는 것이 좋습니다. 또한 임대 요청이 빈 태스크 목록을 반환하면 백오프해야 합니다.
큐별로 LeaseTasks 요청을 초당 10개를 초과 생성하면 처음 10개의 요청만 결과를 반환합니다. 요청이 이 한도를 초과하면 결과 없이 OK가 반환됩니다.
Google Cloud 콘솔에서 태스크 모니터링
애플리케이션의 모든 태스크와 큐에 대한 정보를 확인하는 방법은 다음과 같습니다.
Google Cloud 콘솔에서 Cloud Tasks 페이지를 열고 유형 열에서 가져오기 값을 찾습니다.
[[["이해하기 쉬움","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-03-06(UTC)"],[[["Workers can lease tasks from a pull queue, which temporarily makes them unavailable to other workers for processing, until the lease expires."],["After processing, the worker must delete the task from the queue to ensure it's not processed again."],["Tasks can be tagged, allowing workers to lease specific tasks based on their tag using the `LeaseByTag` method."],["When polling for tasks, workers should handle back-off errors returned from `taskqueue.Lease` and avoid exceeding 10 LeaseTasks requests per queue per second, to prevent issues with task availability."],["The task queue API discussed is supported for first-generation runtimes, and the page provides information on upgrading to corresponding second-generation runtimes."]]],[]]