Error while deploy nextjs in firebase hosting - Invalid value specified for cpu
Asked Answered
J

3

6

I am getting error while deploying nextjs 13 in firebase hosting through firebase-tools.

error - HTTP Error: 400, Could not create Cloud Run service ssrlyeanabot. spec.template.spec.containers.resources.limits.cpu: Invalid value specified for cpu. For the specified value, maxScale may not exceed 30.\nConsider running your workload in a region with greater capacity, decreasing your requested cpu-per-instance, or requesting an increase in quota for this region if you are seeing sustained usage near this limit, see https://cloud.google.com/run/quotas. Your project may gain access to further scaling by adding billing information to your account."

 Error: Failed to create function ssrlyeanabot in region us-central1

package.json -

{
  "name": "testing",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "eslint": "8.36.0",
    "eslint-config-next": "13.2.4",
    "next": "13.2.4",
    "react": "18.2.0",
    "react-dom": "18.2.0"
  }
}

firebase.json

{
  "hosting": {
    "source": ".",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "frameworksBackend": {
      "region": "us-central1"
    }
  }
}

firebase tools version - 11.25.1

STEP TO REPRODUCE THIS PROBLEM

  1. npx create-next-app@latest
  2. firebase experiments:enable webframeworks
  3. firebase init hosting
  4. firebase deploy [done] IMP -> enable billing.

Please let me know, What should I do.

Ja answered 24/3, 2023 at 16:33 Comment(0)
B
7

Add key maxInstances: <some number less 30> to frameworksBackend section of firebase.json file

{
  "hosting": {
    "source": ".",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "frameworksBackend": {
      "region": "us-central1",
      "maxInstances": 2
    }
  }
}

Explanation:

deployment is failing when Firebase CLI is trying to create a cloud function to support Nextjs Framework.

using firebase --debug deploy it seems CLI is not passing maxInstance parameter to create cloud function which results in error.

set maxInstances to specify maximum number of instance you need for this function ( should be less than your project quota - 30 )

schema for firebase.json

Byrn answered 24/3, 2023 at 20:38 Comment(2)
Now, I get it. Earlier it used to be pre-set.Ja
I tried setting it to 20 with no luck, but at 10, which is what they recommend, it worked.Sappy
S
1

Was running through the Getting Started with Firebase and NextJs App and ran into this. For me I needed to setup runConfig in apphosting.yaml.

runConfig:
  minInstances: 2
  maxInstances: 2
  concurrency: 10
  cpu: 2
  memoryMiB: 1024
Sayres answered 25/7 at 21:16 Comment(0)
N
0

I am using Firebase App Hosting, which is different from Firebase Hosting as it can deploy from your GitHub repo each time you push a new commit. I noticed in the logs that it was assigning more than 10 maxInstances:

INFO 2024-08-03T17:09:38.003483886Z Step #3: runConfig:

INFO 2024-08-03T17:09:38.003485352Z Step #3: cpu: 1

INFO 2024-08-03T17:09:38.003486074Z Step #3: memoryMiB: 512

INFO 2024-08-03T17:09:38.003486968Z Step #3: concurrency: 80

INFO 2024-08-03T17:09:38.003487545Z Step #3: maxInstances: 100

INFO 2024-08-03T17:09:38.003488121Z Step #3: minInstances: 0

To address this, I added the following to my apphosting.yaml:

runConfig:
  cpu: 1
  memoryMiB: 512
  concurrency: 80
  maxInstances: 2
  minInstances: 0
Nevanevada answered 3/8 at 17:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.