Java Web application seems sleep - java

Our application is based on Spring boot(the latest version), everything works as expected after deployed at the server.
However we found that for a certain period(maybe 30 minutes) during which there are no visitors, it will response very slow when you visit the page again. And after the re-first visit, the subsequent requests will response normally. Looks like the embedded tomcat or jvm slept.
What's going on? How to fix that?

Related

Timeout a long running SQL Server query in a java application running inside tomcat server

I have a java web app that is running inside tomcat and the application has a page (JSP) where users clicks (some buttons on that web page) which results in hitting a query behind the page and reloads it with new information and sometimes that query takes longer than expected and I want to kill the query automatically if it runs longer than x minutes. How can I achieve that at tomcat side, is that even possible with any tomcat server configurations like timeout or anything, if so could someone please guide me or show an example configuration or setting change I can try? Thanks
I think you are looking for Statement.setQueryTimeout which is a feature of JDBC, not of any specific application server, etc. You will want to call that method and set an appropriate timeout. Your queries will throw SQLTimeoutException if the timeout elapses and your application will have to decide what to do next.

Consistent 2 minute delay for multipart/form-data POSTs using Tomcat 8

I'm trying to get a server up and running on EC2 using Amazon Linux AMI 2017.09.0.2017. I've been able to set up a reverse proxy using Nginx at first and then just now Apache, and everything has been working fine except that something is causing a consistent 2-minute delay when I try to POST a multipart form. Everything goes through and works after 2 minutes, but it always takes 2 minutes for the server to do SOMETHING, what it is I don't know:
https://i.stack.imgur.com/YCpjV.png
I'm willing to be proven wrong, but I'm fairly certain that neither my nginx configuration nor my apache httpd configuration is at fault because I tested both of them individually and it happened under both of them, pointing to a problem with my Tomcat 8, SSL certificate, or possibly AWS configuration. I'm also confident that there isn't a problem with my javascript code that does the POST, because it works fine on an elastic beanstalk environment tomcat build.
This only seems to occur with multi-part form data POSTs, but that's not to say I know that nothing else is affected. I've tried monitoring TCP traffic and looking at error logs and nothing seems out of place, there's just a 2 minute delay that occurs before my java controller receives the form and I'm baffled.
Anyone have any idea what might be happening? Any ideas, vague or not, about leads or suggestions of things to do would be greatly appreciated.

Tomcat shutsdown at load test

On Ubuntu 12 server and Tomcat 7, I load test my spring mvc application for one specific REST get method. (using an online load test tool)
For 1 user per second and over a minute it works fine. But when I load test 50 users per second, after a short while tomcat shutsdown, so I have to restart it again. I checked logs but no error was there.
Where can I start to find the problem? Becoming slow, or unresponsive could be something that I could understand, but shuting down dont make sense.

GWT RPC call gets repeated after 30 seconds

I am experiencing a weird problem in a GWT application. I have multiple RPC calls which work correctly, however if one of them takes longer than 30 seconds on the server side (for example a database or web service call took a long time), the server side code gets repeated (literally; the code get executed again).
I do not experience this in my develompent environment, however when I deploy the application (container is Jetty 6.1.24 on Ubuntu 12.04 LTS) and connect to it from a browser (regardless of the type), the problem starts to exist.
Since I do not think this a designed GWT behaviour (but I might be wrong ofcourse) I am basically looking for ways to debug this and find out the reason for it. Thanks in advance!
Some more information would be great to understand what is going on, but I would start the investigation by first narrowing down whether the erroneous GWT-RPC call is triggered on the client or server.
To see if the extra GWT-RPC request originates from the browser, in Google Chrome, go to View->Developer->Developer Tools.. Click on the Network Tab.
As you reproduce your steps, the Network Tab will show you every request sent to the server.
If you see the erroneous GWT-RPC request logged in this Network Tab View, then the request is fired off from the GWT-compiled Javascript in the application. With SuperDevMode, you can then set debug breakpoints in the browser and see what is triggering the request.
If the erroneous GWT-RPC is not shown in the Network Tab View, then the server-side method is somehow triggered by your server code/configuration. Set some debug breakpoints on your server code, and drill down the call stack to see what is calling the method.
Hope that helps to get started on the investigation.

What happens to grails project on start if database is not running?

I have a grails project with mysql for GORM support. When i start project without mysql running, it gives me series of exception message. This is fine and expected. But, what is problem is that there is no way to handle that so that i can catch them and report to user that there is issue with system and they need to wait till it gets fixed.
There are two cases for this problem.
First one is when a currently running project (deployed inside tomcat and running) get its mysql connection killed by say stopping mysql service. In this case, it keeps on throwing database exception without any grace. The error catching mechanism fails for me. I have mapped 500 to a error page but it also does not gets rendered. Nginx which acts as reverse proxy at last displays its own timeout page.
Second case is when project start loading (say tomcat container is started) and mysql service is already down. In this case, the project startup seems to be effected to a level that startup fails though tomcat reports in log that war is running but when accessed it just throws black page (saying 404) which still is mysterious because i have mapped 404 to a error page which is also not in work.
Thanks.
If there is no db at start up the war will not be loaded into tomcat at all. So you will get default 404 error pages at that point. There are errors thrown to the log in this case but not much else. So your users are hosting their own instances of their app it sounds like, what I like to do is expose a health page.
The health page can be at a known URL and in the case of no db you will get a 404 but you can document that any non 200 status code is an error and provide info on how to fix. Also if you are automating deployment this check is great for reporting status of the deployment.

Categories