Mmm... Confusion... We were planning to measure the actual amount of CPU used in our deployment, so that we can charge or throttle later. My understanding was we should not measure sleep times etc..
For AppServer and ESB this method has shown considerable results for the CPU time. Shall we first try some BPEL services and see? AFAIK, Lasindu has only tried a simple service in BPS. AmilaM. On Mon, Jun 25, 2012 at 12:47 PM, Afkham Azeez <[email protected]> wrote: > Can we do this without JMX? I mean the Tomcat stuck thread detector valve > simply sets the time at which the request was received, and then another > Tomcat task runs periodically runs to check whether the request thread has > completed, and if it has not, it simply keeps adding to the time the thread > takes. So, that will include all external calls BPS makes, all > Thread.sleeps etc. That solution should work. > > On Tue, Jun 19, 2012 at 8:53 PM, Lasindu Vidana Pathiranage < > [email protected]> wrote: > >> I tried testing my code inside CarbonStuckThreadDetectionValve in >> org.wso2.carbon.tomcat.ext in carbon core inside invoke() method. What >> I did was when a thread passes through the valve to inside (Request) I >> measured the CPU time associated with it. When the thread passes again >> through the valve (after completing execution) I again measured the >> thread execution CPU time. >> >> Long key = Thread.currentThread().getId(); >> ThreadMXBean threadBean = ManagementFactory.getThreadMXBean(); >> System.out.println("Thread ID is : "+ key); >> System.out.println("Thread Execution CPU time is : >> "+threadBean.getThreadCpuTime(key)/ 1000000 + "ms"); >> System.out.println("Tenant Domain : "+ >> Utils.getTenantDomain(request)); >> System.out.println("Request URI : "+ request.getRequestURI()); >> >> System.out.println("-----------------------------------------------"); >> >> getNext().invoke(request, response); // previous code to >> invoke next valve inside invoke() method >> >> Long key2 = Thread.currentThread().getId(); >> System.out.println("Thread ID is(1) : "+ key2); >> System.out.println("Thread Execution CPU time is(1) : >> "+threadBean.getThreadCpuTime(key2)/ 1000000 + "ms"); >> System.out.println("Tenant Domain(1) : "+ >> Utils.getTenantDomain(request)); >> System.out.println("Request URI(1) : "+ >> request.getRequestURI()); >> System.out.println("================================"); >> >> >> Output when I tried with a Sample Web Service(with larger calculation >> inside a loop) in Application Server >> >> Thread ID is : 133 >> Thread Execution CPU time is : 20ms >> Tenant Domain : lasinduc.com >> Request URI : /carbon/admin/jsp/WSRequestXSSproxy_ajaxprocessor.jsp >> ----------------------------------------------- >> Thread ID is : 160 >> Thread Execution CPU time is : 0ms >> Tenant Domain : lasinduc.com >> Request URI : /services/t/ >> lasinduc.com/SimpleService.SimpleServiceHttpSoap12Endpoint/ >> ----------------------------------------------- >> Thread ID is(1) : 160 >> Thread Execution CPU time is(1) : 1860ms <--- Can be used as the >> CPU time of the particular request of the tenant >> Tenant Domain(1) : lasinduc.com >> Request URI(1) : >> /services/t/lasinduc.com/SimpleService.SimpleServiceHttpSoap12Endpoint/ >> ================================ >> Thread ID is(1) : 133 >> Thread Execution CPU time is(1) : 30ms >> Tenant Domain(1) : lasinduc.com >> Request URI(1) : /carbon/admin/jsp/WSRequestXSSproxy_ajaxprocessor.jsp >> ================================= >> >> Basically what I did was measuring the CPU time of a thread twice >> through a valve. (Before & after hitting axis2). This worked fairly >> well with the tests I did with AS and can be used to measure the CPU >> time per tenant in SLive. >> >> I tried this with sample web applications in the AS as well and worked >> fine and gave fairly measurable amount of time. What I can is to >> filter-in the necessary threads and measure CPU time per thread for a >> particular tenant. (with request URL : /t/lasinduc.com) >> >> What I can do next is to publish this CPU usage statistics per tenant >> to BAM and get the summation of CPU time at the end of the month or at >> any given point of time. >> >> Is there any other way where I could try this out or am I going in the >> right direction? >> >> >> >> Lasindu Charith >> Intern WSO2 Inc. >> Mobile : 94714427192 >> _______________________________________________ >> Dev mailing list >> [email protected] >> http://wso2.org/cgi-bin/mailman/listinfo/dev >> > > > > -- > *Afkham Azeez* > Director of Architecture; WSO2, Inc.; http://wso2.com > Member; Apache Software Foundation; http://www.apache.org/ > * <http://www.apache.org/>** > email: **[email protected]* <[email protected]>* cell: +94 77 3320919 > blog: **http://blog.afkham.org* <http://blog.afkham.org>* > twitter: **http://twitter.com/afkham_azeez*<http://twitter.com/afkham_azeez> > * > linked-in: **http://lk.linkedin.com/in/afkhamazeez* > * > * > *Lean . Enterprise . Middleware* > > > _______________________________________________ > Dev mailing list > [email protected] > http://wso2.org/cgi-bin/mailman/listinfo/dev > > -- *Amila Maharachchi* Technical Lead Member, Management Committee - Cloud & Platform TG WSO2, Inc.; http://wso2.com Blog: http://maharachchi.blogspot.com Mobile: +94719371446
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
