Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Rhino with Tomcat server  RSS feed

 
Nuwan Kumara
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI all,

I hv intregrated Rhino javascript with Tomcat server. When i keep running my application its gettting slow.I monitor it with the response time and its gettting increese with the time. In my application i generate request delay with 10 ms.Following is my test servlet.

public class StudentAction extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

doPost(request, response);
}

ContextFactory factory = new ContextFactory();

public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
long time1 = new Date().getTime();


Context cx = factory.enterContext();
try {
Scriptable scope = cx.initStandardObjects();
String s = "var i=10;var j=5;var x=i*j;";
cx.evaluateString(scope, s, "<cmd>", 1, null);
System.out.println(scope.get("x", scope));
} finally {
Context.exit();
}
long time2 = new Date().getTime();
System.out.println("Execute time :- " + (time2 - time1));
}
}
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand the remark about "request delay". Are you hitting the servlet as part of a load test? If so, over which period of time, with how many parallel requests? After how many invocations does the code begin to slow down?
 
Nuwan Kumara
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dittmer,

Thank you for the quick response. Actually i generate requests from erlang with a 10ms time interval. Sorry about my previoues post.
When the response time gettting increese the parallel requests which is proccess in side the servlet also increese. I have configure my Tomcat server with 150 Thread Pool .

Thank you
kaman.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, so you're sending requests every 10 ms. But just because you're sending them that fast doesn't mean that the server is able to process and respond to them that fast. How long is the processing time for a single request to a warmed-up server?

Evaluating scripting code takes considerably longer than running the same code written in Java. I would not be surprised if the server simply can't process 100 of these requests per second.
 
Nuwan Kumara
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dittmer,

Thank you very much for your help. Actually the code which i post was sample project to identify the problem which is in my project. But the thing is in my real project when content of the Global Scriptable object getting big its increese the proccesing time than we except .

Is there any way that i can manage this situation. Any idea about peformance of using Rhino with multithread envt .

Thank you,
kaman
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So the question really has nothing to do with accessing the server repeatedly, or with any "time interval" or "request delay" or some such, but is instead about why Rhino processing gets slower if you keep more objects in a Scriptable?

It's hard to advise on this without knowing the specifics. For instance, how much stuff are you keeping in the Scriptable? How does the processing time change (from what to what?) How many parallel requests are you trying to service? How does the processing time increase with just a single thread?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!