최소 인스턴스 수를 설정하면 애플리케이션의 콜드 스타트를 방지하고 애플리케이션 지연 시간을 줄일 수 있습니다.
Cloud Run Functions는 함수의 새 인스턴스를 만들어 확장합니다.
이러한 각 인스턴스는 한 번에 하나의 요청만 처리할 수 있으므로 요청 볼륨이 급증하면 수요를 처리하기 위해 새 인스턴스가 생성되어 대기 시간이 길어지는 경우가 많습니다.
함수는 스테이트리스(Stateless) 방식이므로 종종 실행 환경을 처음부터 초기화하는 경우가 있는데 이러한 과정을 콜드 스타트라고 합니다. 콜드 스타트는 완료하는 데 시간이 오래 걸릴 수 있으므로 애플리케이션이 지연 시간에 민감한 경우 Cloud Run Functions 인스턴스 수를 최소한으로 설정하는 것이 좋습니다.
유휴 인스턴스 및 콜드 스타트
콜드 스타트의 영향을 최소화하기 위해 Cloud Run Functions는 요청을 처리한 후 지정되지 않은 시간 동안 함수 인스턴스를 유휴 상태로 유지하려고 합니다. 이 유휴 시간 동안 다른 요청을 처리해야 하는 경우에 대비하여 열린 데이터베이스 연결과 같은 리소스가 지속될 수 있습니다. 이 방식으로 유휴 상태가 유지되는 인스턴스는 함수의 최대 인스턴스 한도에 포함되지만 이 유휴 시간에 대해서는 요금이 청구되지 않습니다.
이 기본 제공 동작은 특히 지연 시간에 민감한 애플리케이션의 경우 충분하지 않을 수 있습니다. 최소 인스턴스 수를 명시적으로 설정하면 콜드 스타트를 방지하고 애플리케이션 지연 시간을 줄이는 데 도움이 될 수 있습니다.
최소 인스턴스 수가 설정되어 인스턴스가 유휴 상태로 유지되는 경우 이러한 인스턴스는 최근에 트래픽을 처리한 적이 없는 한 활성 상태로 간주되지 않습니다. 예를 들어 함수에서 최근에 트래픽을 처리하지 않은 경우 최소 인스턴스 값이 설정되어 있더라도 '활성 인스턴스' 측정항목에 활성 인스턴스가 없는 것으로 표시될 수 있습니다.
또한 참고로 최소 인스턴스 수를 설정하면 해당 인스턴스의 유휴 시간에 대한 요금이 청구됩니다(가격 책정 참조).
최소 인스턴스 한도 설정 및 삭제
배포 중에 함수에 대한 최소 인스턴스 수를 설정할 수 있습니다. 함수마다 고유한 최소 인스턴스 설정이 있습니다.
최소 인스턴스 한도 설정
Google Cloud CLI 또는 Google Cloud 콘솔을 사용하여 최소 인스턴스 한도를 설정할 수 있습니다.
[[["이해하기 쉬움","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-11(UTC)"],[[["\u003cp\u003eSetting a minimum number of instances for Cloud Run functions helps avoid cold starts and reduces latency for latency-sensitive applications.\u003c/p\u003e\n"],["\u003cp\u003eCold starts occur when a function initializes its execution environment from scratch, which can take a noticeable amount of time.\u003c/p\u003e\n"],["\u003cp\u003eWhile Cloud Run functions keep instances idle for a period after handling requests, explicitly setting minimum instances can further reduce cold starts.\u003c/p\u003e\n"],["\u003cp\u003eYou can configure minimum instance limits during function deployment or by modifying an existing function via the Google Cloud console or the \u003ccode\u003egcloud\u003c/code\u003e command-line tool.\u003c/p\u003e\n"],["\u003cp\u003eSetting a minimum number of instances will incur costs, as you are billed for the idle time of those instances, and the Recommender service can provide recommendations for setting minimum instances for functions.\u003c/p\u003e\n"]]],[],null,["# Configure minimum instances (1st gen)\n=====================================\n\nYou can avoid cold starts for your application and reduce application latency by\nsetting a minimum number of instances.\n\nCloud Run functions scales by creating new instances of your function.\nEach of these instances can handle only one request at a time, so large spikes\nin request volume often cause longer wait times as new instances are created to\nhandle the demand.\n\nBecause functions are stateless, your function sometimes initializes the\nexecution environment from scratch, which is called a *cold start*. Cold starts\ncan take significant amounts of time to complete, so we recommend setting a\nminimum number of Cloud Run functions instances if your application is\nlatency-sensitive.\n| **Note:** Setting a minimum number of instances incurs cost. For details, see the [Pricing](/functions/pricing) page.\n\n### Idle instances and cold starts\n\nTo minimize the impact of\n[cold starts](/functions/1stgendocs/concepts/execution-environment#cold-starts),\nCloud Run functions attempts to keep function instances idle for an unspecified\namount of time after handling a request. During this idle time, resources such\nas open database connections might be persisted in case another request needs\nto be handled. Instances kept idle in this way count toward the maximum\ninstances limit for your function, but you are not billed for this idle time.\n\nThis built-in behavior might not be sufficient for your application,\nparticularly if it is latency-sensitive. Explicitly setting a minimum number of\ninstances can further help you avoid cold starts and reduce application latency.\n\nNote that when instances are kept idle because a minimum number of instances has\nbeen set, these instances are not considered active unless they have served\ntraffic recently. For example, this means that if a function has not recently\nserved traffic, the \"Active Instances\" metric may show no instances are active,\neven if a value for minimum instances has been set.\n\nNote also that when you set a minimum number of instances, you *are* billed for\nthe idle time of those instances---see [Pricing](/functions/pricing).\n\nSetting and clearing minimum instance limits\n--------------------------------------------\n\nYou can set a minimum number of instances for a function during deployment. Each\nfunction has its own minimum instances setting.\n\n### Setting minimum instance limits\n\nYou can set a minimum instance limit using either the Google Cloud CLI\nor the Google Cloud console. \n\n### Console\n\nTo set a minimum instance limit for a new function:\n\n1. To create a new function, go to the Cloud Run functions page in the\n Google Cloud console: \n\n [Go to the Cloud Run functions page](https://console.cloud.google.com/functions)\n\n2. Click **Create function**.\n\n3. Fill in the required fields for your function.\n\n4. Expand the **Runtime, build...** section at the end of the page and click\n the **Runtime** tab.\n\n5. In the **Minimum number of instances** field in the **Autoscaling**\n section, enter a number greater than or equal to 1.\n\n6. Click **Next**.\n\n7. Click **Deploy**.\n\nTo set a minimum instance limit for an existing function:\n\n1. Go to the Cloud Run functions page in the Google Cloud console: \n\n [Go to the Cloud Run functions page](https://console.cloud.google.com/functions)\n\n2. Click the name of an existing function to be taken to its\n **Function details** page.\n\n3. Click **Edit**.\n\n4. Expand the **Runtime, build...** section at the end of the page and click\n the **Runtime** tab.\n\n5. In the **Minimum number of instances** field in the **Autoscaling**\n section, enter a number greater than or equal to 1.\n\n6. Click **Next**.\n\n7. Click **Deploy**.\n\n### gcloud\n\nTo set a minimum instance limit, run the following command: \n\n gcloud functions deploy \u003cvar translate=\"no\"\u003eFUNCTION_NAME\u003c/var\u003e \\\n --no-gen2 \\\n --min-instances \u003cvar translate=\"no\"\u003eMIN_INSTANCE_LIMIT\u003c/var\u003e\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eFUNCTION_NAME\u003c/var\u003e: The name of your function.\n\n- \u003cvar translate=\"no\"\u003eMIN_INSTANCE_LIMIT\u003c/var\u003e: The number to set as the minimum instance\n limit, cannot exceed 1000.\n\nThe function's minimum instance limit is set.\n\n### Clearing minimum instance limits\n\nYou can clear or remove a minimum instance limit using either the\nGoogle Cloud CLI or the Google Cloud console. \n\n### Console\n\nTo clear a function's minimum instance limit:\n\n1. Go to the Cloud Run functions page in the\n Google Cloud console: \n [Go to the Cloud Run functions page](https://console.cloud.google.com/functions)\n\n2. Click the name of an existing function to be taken to its\n **Function details** page.\n\n3. Click **Edit**.\n\n4. Expand the **Runtime, build...** section at the end of the page and click\n the **Runtime** tab.\n\n5. In the **Minimum number of instances** field in the **Autoscaling**\n section, enter 0.\n\n6. Click **Next**.\n\n7. Click **Deploy**.\n\n### gcloud\n\nUse the `--clear-min-instances` flag at deploy time: \n\n gcloud functions deploy \u003cvar translate=\"no\"\u003eFUNCTION_NAME\u003c/var\u003e --clear-min-instances\n\nThe function's minimum instance limit is cleared.\n\nGetting recommendations to set minimum instances\n------------------------------------------------\n\nThe [Recommender service](/functions/1stgendocs/configuring/recommender) automatically\nsupplies recommendations for deployed functions that could benefit from\nhaving minimum instances set."]]