Http connections in jar slower than in eclipse - java

I have a java software that I made on Eclipse and during the execution there is a series of http requests and responses that I have to make. They run pretty smoothly on Eclipse (using the org.apache.http library) but, when I export to a runnable jar, it's painful to see the time it takes between each http connection. I can almost say that the execution takes roughly 10x longer. I'm on the same JRE and I'm using the same parameters I use to open eclipse ( -Xms40m -Xmx512m).
JVM console shows that Eclipse spawns 5 threads to handle my program. The runnable jar uses 9 daemon and 1 user thread.
Can anyone help me figure out the issue here?
Thank you.

Diagnose the network latency. Trying pinging the host you are trying to connect from the machine that has eclipse running, and the machine that you are running from the jar.

Related

Experiencing high cpu consumption running Selenium-Server-standalone as a windows service

Thank you for viewing my post.
I'm running selenium-server-standalone as a windows service utilizing nssm(- the Non-Sucking Service Manager | http://nssm.cc/), utilizing the identical process as mentioned in this stackoverflow post #: https://stackoverflow.com/a/10656979/956863.
Quick Summary of post:
Download and extract nssm.exe
Installed NSSM and from the command line ran: nssm install Selenium-Server "C:\Program Files\Java\jre6\bin\java.exe" "-jar C:\Selenium\selenium-server-standalone-2.24.1.jar"
The machine where I'm running this process is running windows XP, service pack 3. This solution to run selenium server as a service works like a charm, and when selenium server is running, and crashes for some reason, selenium server successfully restarts without manual intervention.
But I"m coming into work, and am being informed by system administrators that high cpu alerts are being thrown. And again system logs are providing no information... So I'm wondering if selenium is actually the cause of this issue, and want to eliminate the possibility of running selenium as a service being blamed for this cpu spike.
Can anyone think of a solution, perhaps a way to stop the selenium service when cpu utilization reaches X amount? Or?
In the meantime, I'm going to set some sort of long term CPU utilization monitor and see if that can see something that the system monitor in xp may be missing. ( If anybody knows of a good way to achieve this, i'm open to suggestions as well )
I have selenium running as a service on windows 2008 server and noticed that its not able to clean up the headless browser instances. My tests are written in JavaScript with Soda so I have a start up and close out the browser instances but running as a service it doesn't close out those instances in the task manager.
I actually have two ways I'm running the service one way is where I'm using a bat file to run selenium the other way I have it running directly off a registry key.
I was able to fix the browser issue after I just added another step process to teamcity to run taskkill automatically on any browsers left open when the tests were complete. This fixed my CPU spiking issue.
Despite having vague reports of CPU spikes with Selenium as a service, I have yet to see one with my own eyes. Which version of Java are you using?
Our commercial run-anything-as-a-service product supports CPU tracking and can restart Selenium when it hogs the CPU. I suggest that you download the free 30-day trial and use it see if you can confirm or rule out Selenium as the problem in that time frame. Follow this guide to set up Selenium as a service.

Java daemon deployment

I have a console Java application, which runs all the time on a remote server (nohup java -jar myapp.jar &).
Frequently (every other day) I need to replace the JAR file by a newer one (whenever I fix a defect).
At the moment I do this by connecting to the server using ssh (WinSCP).
How can I create a mechanism, using which I could upgrade the application via the http protocol? Can I use JMX for that?
That mechanism should do following things:
a) Stop the currently running application.
b) Upload the new JAR file to the server.
c) Launch the new JAR file.
Basically you need to break down the program into two parts:
the monitor component which fetches the new jar, stops the program, replaces the jar, restarts the program
the actual program, the console java application
Theoretically you can do all of this in a single java process but the additional complexity is not worth the trouble in my opinion.
You might check out install4j or this similar StackOverflow question.
In LiveRebel, there's native support for standalone applications (i.e. daemons). So the main application is running with the watchdog agent which communicates to the command center. From command center it is possible then to manage the updates.

Google App Engine App with JPA deployment hangs

I have a java GAE web app with datanucleus as the JPA provider. When deploying locally on my machine - the deployment hangs (takes minutes). Looking at the task manager I have a javac process running. Any idea what is going wrong?
Agreed. Its the problem with GAE as it takes a 6permutation Compilation only after which the application would be deployed and shown on the browser. I feel its the problem only with GAE and not JPA. I have developed a similar app and if you feel its because of JPA, you can check the corresponding database admin to see how many threads are being opened for the user. If you seem to find some aren't Garbage collected, check your code. Else you can use ConnectionPooling mechanism (to speedup db retrieval using ORM).....
The answer depends on several parameters
How you deploy, are you using eclipse or command line?
GAE version (and GAE/GWT eclipse plugin version)
Windows or Linux?
In any case, a Thread Dump can help seeing which non daemon threads are stuck.
For command line deployment in Windows - press CtrlBreak after it hangs to get the thread dump
In Eclipse, if there is a way to deploy in debug mode, look at the debug view stack for the same info
See this answer as well: How to Force Thread Dump in Eclipse?
This thing depend on which platform u r using
Windows
linux
mac os x
you can check what is going on by checksignal
sending a signal
Usage:
SendSignal <pid>
<pid> - send ctrl-break to process <pid> (hex ok)
You can get the source via anonymous CVS at
cvs -d :pserver:anon#www.latenighthacking.com:/code-cvsroot co 2003/SendSignal
I have recently deployed my simple application in google app engine via eclipse. It failed to deploy couple of times. after sometime, It deploy successfully. I was able to access the application. if it hangs, stop the deployment process and redeply

Runtime.getRuntime().exec() not launching process

I have a multi-threaded application that launches an external app to do data conversion in preparation for later parts of the application.
I have an issue that when I set my thread count higher then 6 concurrent threads, the Runtime.getRuntime().exec() fails to launch the external application (I have also tried using ProcessBuilder with the same results). It does not throw any sort of Exception, and nothing is captured on either the standard output stream or standard error stream. What's even stranger is upon rebooting the server, I can run at least 8 concurrent threads for a few minutes without the issue, but then the issue will return.
I have read that Linux's implementation uses the fork() command which can cause an unable to allocate memory error, but I am not getting any such error.
I have written another test app to just launch X number of notespad.exe's without issue with X being as large as 100.
The application is running on a Window 2003 standard x64 server in a VMware environment.
JVM version is 1.6.0_11.
I can update the JVM in an attempt to resolve the issue, but would like to leave that as a last effort to prevent needing to test all application with the new JVM version.
Try to download the dll "framedyn.dll" from http://www.dlldump.com/download-dll-files_new.php/dllfiles/F/framedyn.dll/5.1.2600.2180/download.html and paste on C:\Windows\System32.

Jstack and Not enough storage is available to process this command

I'm trying to run jstack command on my java application. Application is rather big, running inside jboss AS occupying about 4gb of memory. OS is Windows Server 2003 Standard edition. Every time i get an error "Not enough storage is available to process this command". There is enough ram, 16gb, and disk space. So, any ideas?
I ran into this recently on Win2008r2 and thought I'd share my solution since it took a while to figure out. Rob's comment about psexec -s is what did it for me.
It appears that on Vista and later jstack doesn't work against services because of the user context. It has nothing to do with memory. I suspect this is the same reason people have seen this problem on 2003 via remote desktop, unless you use the /admin or /console switch on mstsc. As of Vista the tightened security is probably what broke it.
Starting my app from a cmd window worked fine, but that doesn't help me debug our standard install. Enabling the java debug port (for VisualVM, Eclipse or most any Java debugger) requires an app restart, so you lose the state you're probably trying to capture if you don't already have debugging enabled. Starting the service under my user credentials did not work - I was a little surprised at that. But psexec -s runs jstack from the system context, which worked like a charm. Oh, and you'll need to run psexec from an elevated cmd prompt, if UAC is on.
In the past I have seen this when the JVM is running as a Windows Service on Windows 2003.
First, check to see if this is an issue with the TMP directory.
Second, jstack (or the other utilities like jconsole) will not connect to the local process unless it is running in the same session. If the service is running as a specific user, you may be able to connect by logging into the same session. If you are using Remote Desktop, you can connect using "mstsc /admin" (used to be /console) and try to run jstack again. Definitely check to make sure the TMP directory is set properly if this doesn't fix the problem.
If the service is running as LocalSystem, the above procedure probably will not help much. I don't know if there is a way to log into the same session as LocalSystem.
Some other alternatives may be to set the process up for remote monitoring and use jvisualvm (from the server itself or another machine) to connect over a port and do a thread dump.
We had problems running JStack on a Windows machine with even a modest application (1GB). We ended up doing our stack and heap analysis using Netbeans. This seemed to cope with the parsing of dump files a lot better. YMMV.
Give Netbeans a try for profiling - its very good. Note that VisualVM is a cutdown NB profiler and comes with 6u7.
psexec -s jstack PID >> c:\jstack.log perfectly works on the same machine. For the first time it took some time but again I executed with the redirect to file option, it completed with in few seconds.
This is an error message from the underlying O/S. There's not much you can do in your code to deal with this other than catch the exception which is thrown. Boo to Windows for being so limited.
http://technet.microsoft.com/en-us/library/cc978735.aspx

Categories

Resources