Blank page when loading large web app

I have a fairly large military web application. When I load it, Tomcat will immediately allow connections even if the application has not loaded. Because of this, users receive a blank page until the application is loaded.

I have seen some web applications where they display the "Web application is starting, please wait" page while the application is loading. Is there an easy way to use Java applications?

+2


source to share


2 answers


I suspect your servlets are doing a lot of initialization in the method init()

. Can you offload this to a separate thread and record when that thread is finished? You can provide a servlet filter that checks the progress of this thread and interrupt requests (with a "please wait" message) until the initialization thread completes.



+1


source


When you are working on a complex system, it is very difficult to avoid a long wait during the initialization or reboot phase. You must solve this problem from all sides.

Here are some tips from my own experience,



  • Do not perform on-demand initialization, such as connecting to a database on the first request. Do everything ahead when starting the server.
  • There is no gray status. This is either up or initialized. Kill the server if it is partially running, so load balancing can do its job. Just send "please wait" if the status is not UP.
  • Initialize in the ContextListener if you can. Servlet.init () should only be used for things specific to one servlet.
  • Tomcat suspends requests during startup. Therefore, you need to execute long init tasks on a different thread so that Tomcat can mark the context as UP and you can send a "please wait" message. We also reduce the size of the connector queue.
  • Load-balancer / switch should be configured for a static page "Wait" if the server is down or everyone is too busy.
+1


source







All Articles