P_impl55
P_impl55

Reputation: 148

Spring Boot app behavior differs wildely depending on App Engine configs/deploy

I have a simple Java 11 Spring Boot application with Spring Security and mere login/logout/register functionality. It works now but only after dumb luck searching around for different configurations, which is why I was hoping someone could help me understand the before and after changes and why they worked.

The app is very trivial so it boots within a couple of seconds and runs within 200MB of RAM locally. But when I first deployed to App Engine it couldn't even launch a page. The app would start--sort of--but then get stuck in a restart loop. It couldn't even serve a simple 200 OK test page.

My app.yml config looked like this:

runtime: java11
env: standard
instance_class: F1

I went with standard since I wasn't using containers/k8s. I also deployed the app like this as shown by the official docs: gcloud app deploy

Nothing worked. Spring kept restarting and a single page wouldn't render (I'd get a 30 second timeout error). Given the endless restarts I decided to up the instance size/RAM until it worked. The following app.yml worked...sort of:

runtime: java11
env: standard
instance_class: F4_1G

Having to use an F4_1G is absurd but at least a page would finally load! At least 50% of the time. Looking at the logs about half the pages spent 5-10 seconds to load because Spring kept restarting. I was lost.

Finally, after searching I found an example with a configuration like this:

runtime: java11
instance_class: F2

And once I had the appengine-maven-plugin in my pom.xml I could launch the site like this: mvn -DskipTests package appengine:deploy It worked! It took a few seconds to boot but then it was instant on the page loads, with no extraneous Spring restarts. All of this with a much less powerful F2 instance.

So my question, what happened? By omitting env:standard am I defaulting to flex? And how does: gcloud app deploy differ from: mvn -DskipTests package appengine:deploy?

The change was night and day and somehow my app started working extremely well. Thanks in advance if someone can help explain what's going on.

Upvotes: 0

Views: 282

Answers (1)

gso_gabriel
gso_gabriel

Reputation: 4670

Answering your question, omitting env:standard doesn't default it to flex, actually, the default is the Standard. For flex, you would need to use env: flex.

Regarding the difference between gcloud app deploy and mvn -DskipTests package appengine:deploy, it's be cause the first one is the general command for deploying an application in App Engine, while the second one is to when you are deploying an application with the Maven App Engine Plugin.

As clarified in this tutorial from Google, you can either deploy your Java Server application with the Maven App Engine plugin or with the Gradle App Engine plugin. So, you will be running a command that it's not the general one.

Let me know if the information helped you!

Upvotes: 1

Related Questions