I have a really complex issue regarding the JMX timer and i could use some help. Based on the architecture of the Simple Schedule Provider, I developed a version of a job scheduling system for academic purposes.
This system consists of:
- an mbean provider which listens to a session EJB for registering job schedules at runtime.
- a manager which contains the JMX Timer for triggering those schedules
- a listener class whose instances catch the triggering events.
- a JMS queue where we put the objects describing the logic of each schedule in order to execute it.
- an MDB whose instances consume the objects in the queue and execute their corresponding logic.
When the timer fires a schedule, the listener catches the event and places an object message into the queue. An MDB instance is then used by the container to consume the message by executing an interface predefined method on the enclosed object.
This system makes use of the JbossCache 1.4 (TreeCache) for persistence purposes because it is supposed to be much faster than a traditional JDBC storage engine. Every time a message object is placed in the queue, this information is stored in the cache. Its meaning is that a job's repetition is under execution.
Our scheduling system can also work in a clustered Jboss environment, where the Provider , Manager (including JMX Timer) and JMS Queue act as singletons working on a single node while several instantiated MDBs on every node of the cluster are ready to consume messages pulled from the JMS queue through the cluster-wide JNDI. The cache also works in synchronous replication mode. In this way we want to achieve a load balancing regarding the load that comes from the processing of the actual logic of the various scheduled jobs.
I wont refer to other issues as fail-over etc cause they are irrelevant with my current subject but whoever wants more info on this can mail me.
Anyway, this system works just fine under normal conditions (delays lower than 100ms). However, when we started stress testing it (more than 200 -300 job executions per second) we noticed several strange issues.
I will demonstrate them through an actual example. Our jobs where simple java classes inserting a row per each execution into an in-memory JDBC table (mysql). Each row consists of timestamps (System.getTimeInMillis()) pulled at certain points of the executing process, starting at the Timer trigger firing and ending at the time the actual job started running.
Well, having these data, we noticed that delays of several seconds (up to 1 minute) occurred solely because of the JMX Timer.
MDB consumed at : 120050ms;
Started executing : 120051ms;
As far as we know the java.util.Timer can support much more than 200-300 task executions per second, jmx timer doesnt? Do these JMX Timer delays make sense to you? Keep in mind that the cpu and memory usage never exceeded 70%.
And another even more strange issue is that when working in a cluster, the delays under the same stress tests, go 300% higher! And still the only reason is the JMX timer and not the cache synchronous replication, which is absolutely crazy. How can that be? The timer is used as singleton and he has no knowledge himself that he is working in a cluster. Shouldnt i notice exactly the same FiredAt - shouldFireAt delays as if I worked in a single node environment?
I am ready to use Jprofiler to find some answers, but i am pretty sure that its the JMX Timer's bad performance that degrades the whole system's performance.
I could use some advise here.
thx in advance.
Are you on jdk5? Have you tried jdk1.4?
Are you on jdk5? Have you tried jdk1.4?
why should i use 1.4? as far as i know jboss uses the jmx libraries previously included in J2ee and now included in jdk1.5.
btw i am from greece too dimitris :P
Because I suspect the jdk1.5 javax.management.timer.Timer implementation uses a java.util.Timer which creates a single thread to execute schedules, and this can screw up your timing if executing a task takes time.
The jboss javax.management.timer.Timer (if you use jdk14) has a nice and dynamically extensible thread pool to do the same thing, and so it scales a lot better.
worked just fine! can execute 4000 tasks in 40 secs with 2secs max delay :)
with Sun's jmx timer the delay would reach 50 secs!
I would never have discovered this implementation difference without ur help thx again.
I told you the jdk timer implementation sucks. :)