Mohammad Siavashi
Mohammad Siavashi

Reputation: 1262

How to config App Engine warmup requests for React.js project

I deployed a React frontend project on GCP App Engine. To keep the instance alive, a warmup request configuration should be done. However, to config the warmup request a route must be added in the web server. We did this for our backend services and it significantly improved performance, however, a React project does not have a web server to add the route to. The App Engine itself serves the bundle.

How can I config the warmup request for a React project on GCP App Engine?

EDIT:

app.yaml file:

runtime: nodejs16
handlers:
  - url: /(.*\..+)$
    static_files: build/\1
    upload: build/(.*\..+)$
  - url: /.*
    secure: always
    redirect_http_response_code: 301
    static_files: build/index.html
    upload: build/index.html

Upvotes: 0

Views: 237

Answers (1)

Mohammad Siavashi
Mohammad Siavashi

Reputation: 1262

One way that I could find this is that adding a route in the app.yaml file to serve any static file.

Here is the app.yaml after changes:

runtime: nodejs16

handlers:

  - url: /(.*\..+)$

    static_files: build/\1

    upload: build/(.*\..+)$

  - url: /.*

    secure: always

    redirect_http_response_code: 301

    static_files: build/index.html

    upload: build/index.html

  - url: /_ah/warmup

    static_files: build/index.html

    upload: build/index.html

inbound_services:

- warmup  

automatic_scaling:

  min_instances: 1

The route is necessary only if you don't want to see those 404 errors in your logs.

Upvotes: 1

Related Questions