Google App engine + Spring = slow startup? - java

I read that Google App Engine (GAE) will shut down your application if it goes idle, and startup/boot everything again when it gets a request. And i know that Spring startup is slow, like 2-3 seconds even for a small web app. Is working on GAE using Spring really suffer from this badly?
Thanks in advance.

It's really not that bad but considering your instances are being shutdown and started constantly, you should work on getting your startup as fast as possible. A few pointers to consider:
Enable warmup requests
Enable resident instances
Optimize Spring config (There are great suggestions in this article)

Related

High response time because of GC in spring boot app

I have a spring boot application which I'm running inside docker containers in an openshift cluster. In steady state, there are N instances of the application (say N=5) and requests are load balanced to these N instances. Everything runs fine and response time is low (~5ms with total throughput of ~60k).
Whenever I add a new instance, response time goes up briefly (upto ~70ms) and then comes back to normal.
I checked NewRelic JVM stats.
As you can see, whenever the app starts, there is GC-MarkSweep which I think is probably related to the initial high response time.
How can I avoid this? I'm using Java 8. Will using a different GC (G1) help or can I somehow tune my GC settings?
JVM itself requires quite a work when starting, and Spring Boot is also adding a lot of it's own work and classes. Try to remove/switch off all unused features, since autoconfiguration magic can cause a lot of unnecessary overhead.

Spring Boot with embedded Tomcat uses loads of CPU after startup

I have a Spring Boot application that works with an embedded Tomcat web server. The application uses a H2 db over JPA. The front end is a single page application that communicates over a REST interface with the Spring back end, that only contains a Business layer and a Domain layer. Nothing complex.
As the application is a prototype for a future product that will run on a minimalistic system, therefore I was measuring the CPU load and memory usage.
That's when I found an odd behaviour, which I currently cannot explain.
During the start up, the app uses about 3/4 of the CPU which is okay as the whole framework gets initialized.
But after the app has started (Log message "Started Application in XX seconds" has appeared) it still uses about 50% of the CPU, slowly decreasing until it finally reaches 15% after about 2 or 3 minutes, although my implementation is not doing anything active. It's pretty much only waiting for a request over the REST interface.
It appears to me that Spring or the embedded Tomcat is doing something, which I don't know of.
Has anybody already experienced the same issue and/or maybe knows what could be going on?

WebLogic Cluster - Restarting all app server instances on a weekly basis?

We are implementing a bespoke 3rd party J2EE application on a 6 server weblogic cluster (latest versions of Oracle products - running on SuSE). The supplier is suggesting to me that we schedule a restart of each WebLogic instance every week on a Monday morning at 3am.
I'm no weblogic expert and I can't seem to track down any best practice guidelines on the subject of regular restarts, but I'm used to working in environments where other clustered app server instances have uptime is measured in much longer periods than 7 days...
My concern is that this is intended to mask issues in the J2EE app itself. Can anyone point me towards best practice guidance related to Weblogic which I may have missed, or confirm that this may be a legitimate suggestion from the application vendor?
We don't always get perfect codes, no-wrong applications, and best programmers to work with you, in fact, many codes are written by junior programmers with low cost. So it is reasonable there are some bugs in these J2EE applications (depend on OS patch level, java version, application itself, etc). Memory leak is one of the problem to ask regular restart to avoid the applications go down at business time. Some other problems are hide in and can't be easily found out.
That's the reason to recommend to restart the application fortnight, weekly, or daily (I DO see some business java application restart every night).
If you really want to troubleshooting the application, maybe you can install some APM (application performance management) application to help you to find out why the application have memory leak, unstable behavior, etc.
You can search in google or read this URL for a starting : http://en.wikipedia.org/wiki/Application_performance_management

Hibernate+JPA+Spring Memory Leak

I am deveoloping a web application with Hibernate, JPA, Spring and Struts2. When I run the application for a few hours in my web server (VPS Tomcat) the OS send a SIGKILL to tomcat because of the memory usage. My server has 288Mb, tomcat gets killed when it reaches 200Mb aprox. Someone has told me that I need more memory but my application is small and doesn´t have too much traffic, it is not in production yet. I am using postgresql and my database is about 150Mb, it has many images. I have tried to use a memory profiler with netbeans, but the IDE becomes to slow and I have not been able to find anything.
I'll appreciate any help.
Do you close properly your connections in a finally block ?
It's hard to reply without the code with only theses informations
i have used JProfiler and yourkit but i am not satisfied with output for actual performance tuning and memory usage currently we have been switched to java melody. This not only help performance optimization in dev but also in production system. Java melody is very easy to integrate and configure and in production you can enable or disable by just updating web.xml

Timeout with GAE Java

I am having some issues with an app I have deployed on GAE. Specifically, I am intermittently running into the DeadlineExceededException where the server is not responding within the 30 seconds required.
What is odd is that the code is not overly complex, it should run in milliseconds. My guess is that the delay is in dealing with the persistence manager and accessing the datastore.
2 questions:
1) What is the best way to track where all of the CPU time on the server is being used up? Log files do not seem helpful and to make things more complicated the code runs very fast when I am running it locally
2) Any tips / best practices in dealing with the 30 second exception? What are the biggest drivers of this? Datastore? HTTP requests / responses?
Thanks
These SO threads might be helpful,
How is DeadlineExceededException implemented in Google App Engine for Java?
Techniques to avoid DeadlineExceededException in GAE/J?
The Google App engine blog covers this exception in the entry about the 1.2.8 release (current release is 1.3.0) of GAE:
Request performance in Java
The new class-loading aptimization option reduces the length of loading requests, which occur when App Engine is preparing a new instance of your code to respond an incoming request:
First, we're introducing a new
class-loading optimization in 1.2.8
called precompilation. Precompilation
makes loading requests faster by doing
class-loading work ahead of time in
the App Engine environment.

Categories

Resources