GWT low performance - java

as an introduction: I am new to GWT and coding, so my questions may appear basic.
I made web app using GWT, Maven, Hibernate, IntelliJ IDEA. I deployed app on my own Tomcat server (I have separate computer for this: HP ProLiant ML310e Gen8 v2 4-Core 3.1GHz 4GB DDR3 + HDD 2x1TB SATA).
It is simple page with 5 tabs, and it has one .png 48 Kb image as header. The view that is loaded initially has:
2 Labels with few words,
CellTable containing 20 rows (content is obtained from database through RPC, from database)
4 Buttons (for table paging)
This view has almost no content, it has following panels just for exact layout I want:
3 VerticalPanels, 6 HorizontalPanels, 1 Tree and 1 Grid
The problem is: . When I run URL first time, it takes 1:09 min to load anything. And every next time I paste URL it takes about second to display app.
(after page loading everything goes smoothly, just a second to display widget)
I read this article: http://blog.trifork.com/2007/11/30/optimizing-startup-time-for-gwt-hosted-mode/ , but server runs the app in production mode (GWT.getScript() returns true). I also ran through a few topics on stackoverflow, but I don't see what loading time is "normal" for small size apps.
If time above 30 seconds is required to run anything, then GWT appears unacceptable for typical user, who may think that the link is broken at first time... I don't know how it works - is GWT rebuilding and recompiling the page for every new user request?

I don't know how it works - is GWT rebuilding and recompiling the page for every new user request?
No.
GWT uses caching. The initial loading time is really depends on many factors.
When user/browser requests for the very first time, all the resources related to the page loads. That takes few seconds to load and really depends on your internet speed.
Once the complete page loaded and if you are requesting new page/ reloading the current page, all the resources won't load this time.
Coming to the part that rebuilding and recompiling for each request is wrong. In Gwt there are permutations which are specific to each browser. Every major browser have it's own permutation. If you request from Mozilla for example, permutations related to Mozilla loads. These permutations actually generates at compile time of project which you done in your IDE before deploying the project.
Once the request hit the browser, for very first time these all files related to the specific permutation loads into browser and cached in browser. Form next time on words you won't see any new files loading in to browser (you can see that using your firebug).
Using code splitting, lazy intializations and data compression techniques.
Continue reading .....

check yourapp.gwt.xml file if you have inherited some modules that takes time to load.
if so, during first load it takes time and the way gwt works is it loads and maintains a cache for future loads, which answers your problem about taking time to load at first and seconds to load next time.
And gwt does not rebuild or recompile the page, simply displays the page you have compiled

Take a look at GWT.runAsync, this will help you to not load everything on startup, just what you need :)

Related

Displaying the database table on the windows screen in real time

I have a database table which is running on a remote host. I need to write a program to display this table in a windows form or on a html page on the desktop screen. The program needs to run at equal intervals (say 30 min).
After every 30 min the program will run and the data needs to be overridden on that form or page. There could be any approach to this. Prefer Java.
Two different ways of doing it (really three, the third one being running a java-applet)
The coarsest way is to put a refresh header in your html like
<meta http-equiv="REFRESH" content="600;URL=page.php">
where you have to exchange page.php with whatever is the address of the page you want to reload (this says basically after 600 secounds, load page "page.php" You will not be able to sync this to the dbupdates, as the refresh happens a fixed time after the page load. So how often you reload will be a compromise between your server load and how long delay you will accept. Also, you probably will want to have this as a separate frame (ooouch!) if some information is to be entered on the page.
A bit more contemporary, use javascript ajax and timed events. You want to juse jquery or prototype.js or another library for that. Here you may be able to sync the reloads to the database updates, given that the real time clock on the workstation and the server are in sync.

Java Temporary file for Memory management

I have a huge data that has to be displayed in a page retrieved from database table. The table is regularly updated with new data and page has to display the latest data whenever refreshed. Since, the page is loaded with heavy loads of data it takes time to load (2-3minutes) and sometime it suffers from only displaying white page.
So, what I need to do is create a temporary file in server which stores this data from database and the page will extract info from this file. This file should be reloaded with new data in each 10-15 minutes so that till 15 mins page displays the old data but after 15 minutes if page is refreshed it shows the new data.
Hope my problem will be solved with the above idea but I am only limited to above theory. Please provide me solution how it can be done and any other better idea than the above. if any java code sample that would be great to solve my problem.
Thanks
Now you are propably using a lightweight webserver (guessing from the fact you are talking about pages loading white)
But if were using some java ee application server like glassfish, you could have a scheduled task running every 15minutes that loads the data and stores it into a file.
http://docs.oracle.com/javaee/6/tutorial/doc/bnboy.html
Maybe Quartz is the answer for you:
Scheduled task in a web application?
Or maybe you are not using a webserver/appserver at all and my answer completly invalid.

GWT Application loading time

I am using GWT 2.0.3 with ext version.When I run the application its take some time to load.As much as I know It take time to load some JS file (Not sure about it).For slow internet connection it wiil take more time.
I want to know what exactly GWT application do while loading.If it is loading some JS file the is there ant way to reudce loading time by dividing JS file or by nay other way?
Thanks in advance
When a GWT application loads, it loads all js files contained in your html host page, what means everything client side related is loaded.
To optimize this GWT introduced code splitting some time ago. You can check it here. The basic idea is to divide your application in logical parts, when a user wants to access to another part, its loaded on demand.
To speed up web app loading time, indeed split points are a first step.
But check as well this tool:
http://pagespeed.googlelabs.com
Slowness can also come from uncompressed pictures for instance.
Also, when you compile your GWT app, ensure you use "OBFUSCATED" mode for your compiled javascript, which makes it significantly smaller.
http://code.google.com/webtoolkit/doc/1.6/FAQ_DebuggingAndCompiling.html#Why_is_my_GWT-generated_JavaScript_gibberish?
Now if you are using Apache HTTPD as web server, Google has released a wonderful Apache module that implements web app best practices out of the box:
http://code.google.com/p/modpagespeed/

How to find average loading time for website?

How to write a code (in any programming language, preferably in java), which calculates the average loading time of any website (including all embedded elements such as images, Javascript, CSS, etc.) ?
I'd just use YSlow
Google just released Page Speed (a plug-in for firebug, just like YSlow) and it's got some pretty cool features.
I think websiteoptimization.com has all you need :)
I've always enjoyed using this tool:
http://www.websiteoptimization.com/services/analyze/
Depends what you mean by 'average loading time'.
If you sit at your PC with your site running locally and just hit F5 over and over again you'll get considerably different results to someone looking at the same code which is deployed in a data centre on the other side of the world.
Fiddler is also another option. See the Fiddler home page
A nice screenshot of the transfer timeline is here.
I had used souptag framework to parse html page and then found individual src attribute of all the tags, Then individually found size of each page mentioned in src attribute and then according to my internet speed found out average loading time.
Perceived loading time is important too. External scripts will delay rendering of everything below them until they've loaded and executed, in all browsers, so it's best to push them to the very bottom of the page when possible, as opposed to the very top which is the habit of many developers. Another source of delay in some browsers is img tags where the width and height are unspecified. The browser will give the image some time to load so that it can get the layout right the first try. Fixing both those issues will make your site appear a lot more responsive, even if total loading time is unchanged.
This has a nice JavaScript way to check load time of a web page:
http://javascript.internet.com/text-effects/loading-time-indicator.html

Java Applets loading at snail's pace

I have a Java Applet application ( achart) on my php Webpage ... Problem here is the Java Applet takes more time to load ... I am thinking of replacing these applets with some similar technology but fast ... I am counting on Ajax... what are my other options ... ?
Java applets load slowly. shrug Its the nature of the beast....
If you have multiple jars, you should check the order of the classpath you provide to your applet. Note that each jar is only downloaded "on demand" whenever a class needs to be loaded. It looks in the first jar, if it can't find the class it looks in the second and so on... You can reduce your startup time by ensuring that all of your classes required for starting up the app are in the first jar(s) listed.
Also, if you are attempting to load a class or resource which is not in your classpath, it must search through all the jars before returning AND hit the server codebase to look there. It can potentially greatly reduce your startup time.
Turn on applet tracing in the java control panel and you should get a better idea of how classes are being loaded out of the jars.
If the size of the applet's JAR library takes to long to download, you can shrink the size with the ProGuard tool. Here is a comparison of the compression ratio for some Java libraries.
Have you packed your jars.....
Have you tried Java deployment toolkit (http://blogs.oracle.com/vaibhav/entry/java_deployment_toolkit_6u10)
with jdk 1.6.10+.....
If its simple charts you want, have a look at:
http://code.google.com/apis/chart/
Yahoo has some nice charting components for actionscript 3 (flash) http://developer.yahoo.com/flash/astra-flash/charts/
Google has a service that will generate charts as images as Tim already pointed out.
Alternatively you could try to speed up the delivery of the applets that you are using - check if they have an Expires header so they only get downloaded once in a while instead of for every page (this won't help on the first view, but will speed up those after that)
Edit: if you only target specific browsers you could try and create the charts using javascript and the Canvas element, but that is definitely not supported by internet explorer. https://developer.mozilla.org/en/Canvas_tutorial
I know this answer is a bit late but, it could be that you are just being very inefficent with java or your machine is slow, I have a java program that has quite alot of code as well as accessing an SQLite DataBase and it runs quite quickly, loading within five seconds. If you have anything you don't use in your program then remove it, also try jaring and signing it(not sure if last two things would help.)

Categories

Resources