0

I have a website with some images using the p:graphicsimage tag with the rendered attribute. So the images are only shown if the bean (db query) returns a true. I also have a login form checking the user against a db. This works fine but my current problem is that the page needs a lot of time for loading the page(arround 25sec).

The bean method of the loginbutton is called ~20sec after pressing the loginbutton but I don't know what the server is doing during this time. Any idea how to check the server states or how to fix that problem?

My beans are ManagedBeans

Thanks in advance!

mbauer
  • 348
  • 1
  • 6
  • 25
  • Try to debug the method that's executed after login. Try to find the statement where the lagging happens. – Konstantin Yovkov Jan 15 '15 at 15:20
  • Have you run a profiler? Try CPU Samples in jvisualvm. That will tell you where your CPU time is going. Maybe it's the DB query. – wrschneider Jan 15 '15 at 15:23
  • Profiler shows that 98% of the time the cpu is idle – mbauer Jan 15 '15 at 15:37
  • Are you running the application on a real server with sufficient resources? While slowness/performance is dependent upon several things, business logic running on the service layer (JPA things on EJBs or else) may have significant impact on performance, if that logic/code is cluttered/scattered - for example, if you are doing many things by Java code which could otherwise be delegated to a single (one or two) (aggregate) SQL statement, query optimization techniques are overlooked, the result set from the database is not lazily fetched, the eager fetch is used at many places unnecessarily etc. – Tiny Jan 15 '15 at 19:43
  • Make sure that image size is not to big. It is possible that browser is getting those images, but they are too big (20 MBs or osmething) and it takes time. Just guessing – anotherUser Jan 16 '15 at 10:44

2 Answers2

1

You can debug your method and benchmark the potential areas very old-school like

long startTime = System.currentTimeMillis();
method();
long endTime = System.currentTimeMillis();
System.out.println((endTime - startTime) + "ms")

or use a profiler like yourkit.

SceniX
  • 21
  • 1
0

There are a couple of things you can do to improve performance of your screens

  1. GZIP filter will reduce the initial load time significantly. It compresses the page contents while transferring to client browser. Refer to https://stackoverflow.com/a/35567295/5076414
  2. You can additionally implement a cacheFilter to bring performance of your screens at par with JavaScript based UI. This will cache the static content of your screen such as icons, images, stylesheets, javascripts etc. You can control what to cache and what to exclude. Refer to https://stackoverflow.com/a/35567540/5076414
  3. For client side UI components, you can use Primefaces which is JQuery based UI.

How to verify if my screen is using gzip and cache

To see if your contents are already usign gzip and cache, In your Google Chrome Browser -> right click on your screen -> inspect -> click network tab -> refresh your screen. Click on the images, icons, stylesheets and see if you see following in response header

Cache-Control:max-age=2592000 if the status of element is 304 (coming from cache)

Content-Encoding:gzip if the status of element is 200

Community
  • 1
  • 1
Sacky San
  • 1,535
  • 21
  • 26