2 Replies Latest reply on Jan 14, 2010 12:50 PM by gifor

    JMX and MBeanProxyExt.create

      Hi,

      I have a performance issue on MBeanProxyExt.create method.

      We have an MBean which store a PojoCache object (to store runtime objects status) and an HashMap to store some runtime information (basically credential of logged-in users).

      The work flow of external request is:

      1) the web request invoke a web service

      2) the invoked web service method create an MBean proxy (with MBeanServer server = MBeanServerLocator.locate() to create local reference and MBeanProxyExt.create(...))

      3) the MBean reference is used to retrieve the object inside the MBean instance

      4) the workflow continue using this information

       

      The workflow work well for few users but when we have 100-150 concurrent users the "create" response time has a big variability (from few ms to 3-4 sec with an average of 700ms). This sort of behavior could be symptom of a lock between threads or the presence of a full pool of resource. Anyone can provide information about this behavior?

      It's possible to use the same instance of the MBean proxy (statically initialized during the applications startup) or use other workaround?

       

      Best regards

      Giovanni

        • 1. Re: JMX and MBeanProxyExt.create

          I imagine what you are seeing is contention inside the JDK method MBeanServerFactory.findMBeanServer() which iterates

          over a list in a synchonized block. That is what MBeanServerLocator.locate() uses.

           

          Code from openjdk:

              public synchronized static
                   ArrayList<MBeanServer> findMBeanServer(String agentId) {
          
               checkPermission("findMBeanServer");
          
               if (agentId == null)
                   return new ArrayList<MBeanServer>(mBeanServerList);
          
               ArrayList<MBeanServer> result = new ArrayList<MBeanServer>();
               for (MBeanServer mbs : mBeanServerList) {
                   String name = mBeanServerName(mbs);
                   if (agentId.equals(name))
                    result.add(mbs);
               }
               return result;
              }
          

           

          To answer your other question. The generated proxy is threadsafe. So you can cache it and use it across many threads at once.


          NOTE: MBeanProxyExt is largely redundant now. The JDK provides similar functionality since 1.5

          http://java.sun.com/javase/6/docs/api/javax/management/MBeanServerInvocationHandler.html

           


          1 of 1 people found this helpful
          • 2. Re: JMX and MBeanProxyExt.create
            gifor

            Thank you Adrian!

            I tried to replace:

            MBeanServer server = MBeanServerLocator.locate();

            PhysicalSessionManagerMBean sessionManager = (PhysicalSessionManagerMBean) MBeanProxyExt.create(PhysicalSessionManagerMBean.class,"jboss.jmx:service=PhysicalSessionManager", server);

             

            with:

            MBeanServer server = MBeanServerLocator.locate();

            ObjectName on = new ObjectName("jboss.jmx:service=PhysicalSessionManager");
            PhysicalSessionManagerMBean sessionManager = (PhysicalSessionManagerMBean) MBeanServerInvocationHandler.newProxyInstance(server, on, PhysicalSessionManagerMBean.class,false);

             

            and now after 400.000 calls I get an average response time of these 3 lines of code of 0,3ms instead of 729ms... quite stange from my incompetent (I have limited knowledge of JMX) point of view.

             

            Regards

            Giovanni