I have a web service running on tomcat. I have configured 30 request threads. The service is working fine. The unusual thing is that the number of threads JMX is displaying are more than 150. My application is not forking any threads in the application java code. I am unable to know what could be the reason for this? I couldn't find anything on google and SO as well..
Using a tool like VisualVM (https://visualvm.java.net/) will give you a complete list of all running threads in your current process.
Related
In our confluence server (tomcat 9 based), we added interruptThreshold to 30mins to kill long running threads (usually these are stuck threads).
However, interrupts for certain threads are not succesful (and it is okay, as it's mentioned in documentation that it doesn't work in all cases), but these specific threads gets killed after 8 hours.
These specific threads are related to a custom plugin and our developers say they don't have such 8 hours setting anywhere and I couldn't find anything in tomcat or in confluence.
We will be able to replicate the stuck threads, but how to findout what's killing them after 8 hours?
Such actions on Tomcat should be logged in the {CONFLUENCE_HOME}/{DATA_FOLDER}/logs folder, please find these logs files and look for this operation/timestamp.
If for some reason, logs are not fully reflected, you can set it as described in
https://confluence.atlassian.com/doc/configuring-logging-181535215.html.
Also, you can control loggng in -X... Java / Tomcat statements when running start.bin/start.sh.
Our multi-threaded Java application is using the Java XCC library. Over MarkLogic admin console under status tab only 2 threads are shown as active while the application is running, that is the most probable reason of bottleneck in our project. Please advise what is wrong here?
To effectively run xcc requests in parallel you need to make sure you are using separate Sessions for each thread. See:
https://docs.marklogic.com/javadoc/xcc/com/marklogic/xcc/Session.html
Having only 2 active threads running is not necessarily a sign of a problem, its possible that your requests are being processed as fast as you issue them and read the response. If your queries are fast enough there is no need for more threads. Without more information about your queryies, response times and server load its not possible to say if there is a bottleneck or not. How many threads are you running ? Compare the response time as you increase threads. Check that you have sufficient network IO so that your requests are not bottlenecked in the network layer.
I suggest profiling your queries and using the Performance History console to see if the server is running at high utilization. Try increasing the number of client threads, possibly running them from different servers.
Almost finished my java web app. All working fine.
Whats next.
I need now to write some kind of process that runs in back ground to take care of some regular manteinance and send some tweets in a regular basis.
From google you can find out that Daemon is the right way.
Can anyone guide me step by step how to accomplish this?
1- Writing the program.
2- And then put it into run in a linux enviroment. (Keeping it runing if i logoff as user. As Tomcat does).
3- If possible start it at linux starts regardless i logon or not.
A URL to a good tutorial will help a lot.
Bad news is that my development enviroment is my windows notebook and my production enviroment is Ubunto (Not sure if i can test daemon threads in windows).
Good news is that have the production server in my house at 4 meters from where i am writing this:)
Thank you very much in advance.
It's probably easier - and cross platform - to just put that stuff inside your Tomcat server. Check out the Quartz scheduler, it does what cron does and more, is easily integrated in a web app and allows you to call jobs written in Java without any complicated plumbing. As an added advantage, these jobs are deployable just like any other web app in Tomcat.
I have a Java application which should run on a server machine in the background (the application can be started by a command without GUI). The problem is: When I log off from the server, the application gets killed. I'm looking for something similar like nohup under Linux. I found some solutions, but I'm unsure, what is the best for my situation (Windows Server 2003, Java Application run from BAT-Skript, restart after booting the machine)? What are the pros and cons of the solutions?
psexec: Do the process really need to run under the SYSTEM account?
Combination of instsrv and srvany: But srvany should should never be used in a production environment
I have started the application with the scheduled tasks with the option run as NT AUTHORITY\SYSTEM. But after log off, the application was still killed. Can I get this working?
The DOS Task Scheduler AT command
Write a windows service (on Java, C# - I don't think it does matter)
Start the app from your service
or
Run your app as a window service using 3d party utility
The only way in which you can get a process to run without a user being logged in is to have the process run as a windows service or at the very least called by a windows service.
Just to add to above answers.
Consider using http://wrapper.tanukisoftware.com.
It's rather mature and popular (in contrast to ServiceEx and RunAsService).
Yes, a Windows Service is definitely the way to go but there are a few things to watch out for when you run a Java application as a Windows Service. Most of them are covered in this tutorial showing how to setup a java application with our commercial run-anything-as-a-service application, AlwaysUp:
http://www.coretechnologies.com/products/AlwaysUp/Apps/RunJavaApplicationAsAService.html
Beware: You will almost surely need the "-Xrs" flag on Windows 2003 to prevent the closing-on-logoff behavior but things can get tricky if you are catching shutdown events. Let me know if that is an issue for your situation.
I'm writing a java application that runs in Tomcat, on a multi-core hardware.
The application executes an algorithm and returns the answer to the user. The problem is that even when I run two requests simultaneously, the tomcat process uses at most one CPU core.
As far as I understand each request in Tomcat is executed in separate thread, and JVM should run each thread on separate CPU core.
What could be the problem that bounds the JVM or Tomcat to use no more than one core?
Thanks in advance.
Are you sure that two threads are being created. You could simply print the name of the thread as a quick test.
What happens if you run the algorithm in a standalone app?
All the processor management will be taken care by the server itself. It is not mandatory that if you pass two requests, it should use two CPUs.
Are you executing any synchronized blocks/methods which would force serial execution? The tomcat connector configuration in server.xml controls the request thread pool - but the default is 200 threads, IIRC.
Here is the procedure to do a load balancing in tomcat http://tomcat.apache.org/tomcat-5.5-doc/balancer-howto.html
I think this will work with Tomcat 6 too as they mentioned balancer webapp is shipped with tomcat 5.0 and later.