How to reduce Glassfish startup time from 2 minutes to something acceptable

glassfish

I'm running Glassfish Open Source Edition v3.1.1 on a Ubuntu 12.04 Micro Instance in Amazon EC2 (Elastic Compute Cloud). I've configured a single domain with a single application. When I start the domain with time asadmin start-domain, it reports back with the following:

Waiting for domain1 to start ............................
(...)
Command start-domain executed successfully.
real    2m6.599s

Two minutes… What takes two minutes? Is there any way I can speed up the process or should I just go for other solutions like Tomcat or Jetty for my application server? When restarting Glassfish on my local Windows 8 client computer, it takes seconds, not minutes. Although I realize my computer has more hardware, it shouldn't take two minutes to start a simple application server.

I've tried adding the following two JVM-OPTIONS to the domain config file as recommended by in other discussions, to no avail: -Djava.net.preferIPv4Stack=true and Dcom.sun.enterprise.tools.admingui.NO_NETWORK=1

update:
After doing two launches with --verbose, this is an edited comparison of two interesting segments:

Run #1

[#|2013-03-15T11:32:48.597+0000| Created virtual server [__asadmin]|#]
[#|2013-03-15T11:33:12.244+0000| Virtual server [server] loaded default web module    []|#]
[#|2013-03-15T11:33:15.973+0000| Scanning for root resource and provider classes in the packages:

Run #2

[#|2013-03-15T11:36:10.707+0000| Created virtual server [__asadmin]|#]
[#|2013-03-15T11:36:25.127+0000| Virtual server [server] loaded default web module []|#]
[#|2013-03-15T11:37:37.198+0000| Scanning for root resource and provider classes in the packages:

Full log of run#2 at pastbin here

What's intersting to note is the vast difference in time between line two and three in the two runs. (3 secs vs 1 min+)

I can also add that while the server is launching, console response is very slow in a second SSH window – to the point where ls takes seconds to respond.

edit 2 Free-output after service launch:

              total       used       free     shared    buffers     cached
 Mem:        604376     469776     134600          0       8976      78212
 -/+ buffers/cache:     382588     221788
 Swap:            0          0          0

Best Answer

Note that a micro instance is:

  • very limited in term of CPU & it use the concept of burstable allocation. The exact description is : Up to 2 EC2 Compute Units (for short periodic bursts).

  • very limited in term of memory (613MB). Make sure Glassfish doesn't try to over allocate as you'll swap to disk and this get heavily penalized in AWS EC2.

Pretty sure you are hitting one of those 2...

Related Topic