We are running a simple stress test (whose code I will paste below) for a
numbercompare rule file)
We get the following error before the test finishes. Which seems odd for one
rule
javax.servlet.ServletException: java.lang.OutOfMemoryError: PermGen space
This test is run against 3 loablanced tomcat servers
Here is my JVM_OPTS for each of those tomcat
JVM_OPTS="-Xms4096m -Xmx4096m -XX:NewSize=2048m -XX:PermSize=512m
-XX:MaxPermSize=512m -Xss1024K -XX:+UseCodeCacheFlushing
-XX:-UseSplitVerifier"
Here is
I have a simple rule file deployed on guvnor on my abc with JVM_OPTS on the
guvnor being
JVM_OPTS="-Xms4096m -Xmx4096m -XX:NewSize=2048m -XX:PermSize=512m
-XX:MaxPermSize=512m -Xss1024K
Here is my stress test that we are running
package DroolsTest;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import confident.guppy.tools.Caller;
public class DroolsSpeedTest {
public static void main(String[] args) {
HttpURLConnection httpURLConnection = null;
InputStream inputStream = null;
BufferedReader bufferedReader = null;
long t1 = System.currentTimeMillis();
for (int i = 0; i < 10000; i++) {
try {
long start =
System.currentTimeMillis();
// Three
boxes
String url =
"https://abc-uat2.xyz.com/ces/v2.0/rules/10/compare/10";
httpURLConnection = (HttpURLConnection) ( new URL(url).openConnection());
if
(httpURLConnection != null) {
inputStream = httpURLConnection.getInputStream();
bufferedReader = new BufferedReader(new InputStreamReader(
inputStream));
String results = "";
String info = "";
while ((info = bufferedReader.readLine()) != null) {
results += info;
}
//caller.log(results);
} else {
System.out.println("Unable to create the HTTP connection with the required
server...");
}
if (i % 20
== 0 && i != 0 ) {
System.out.println(" passing " + i + " ms " + (
System.currentTimeMillis() - start ));
}
} catch (Exception boom) {
boom.printStackTrace();
System.out.println("It died on the " + i + " attempt because " +
boom.getMessage());
}
}
long t2 = System.currentTimeMillis() - t1 ;
System.out.println("I took ms : "+ t2 );
}
}
Here is my rules defined on guvnor
package org.numbercompare;
declare NumberCompare
message : String
numberone: Integer
numbertwo: Integer
end
rule "numberone is equals to numbertwo"
when
n: NumberCompare(numberone == numbertwo);
then
n.setMessage("numberone is equals to numbertwo");
end
rule "numberone is greater than numbertwo"
when
n: NumberCompare(numberone > numbertwo);
then
n.setMessage("numberone is greater than numbertwo");
end
rule "numberone is less than numbertwo"
when
n: NumberCompare(numberone < numbertwo);
then
n.setMessage("numberone is less than numbertwo");
end
Here is my code that updates the rule file
public KnowledgeBase readKnowledgeBase() throws Exception {
ResourceFactory.getResourceChangeNotifierService().start();
ResourceFactory.getResourceChangeScannerService().start();
ResourceChangeScannerConfiguration sconf =
ResourceFactory.getResourceChangeScannerService().newResourceChangeScannerConfiguration();
sconf.setProperty("drools.resource.scanner.interval", "2");
ResourceFactory.getResourceChangeScannerService().configure(sconf);
KnowledgeAgentConfiguration kaconf =
KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
kaconf.setProperty("drools.agent.scanDirectories", "true");
kaconf.setProperty("drools.agent.scanResources", "true");
kaconf.setProperty("drools.agent.newInstance", "false");
KnowledgeAgent kagent =
KnowledgeAgentFactory.newKnowledgeAgent("CS", kaconf);
kagent.applyChangeSet(ResourceFactory.newClassPathResource("ChangeSet.xml"));
KnowledgeBase kbase = kagent.getKnowledgeBase();
return kbase;
}
@Override
public DroolsDTO getDroolsDTO(int numberone, int numbertwo) throws
Exception {
DroolsDTO droolsDTO = new DroolsDTO();
KnowledgeBase kb = readKnowledgeBase();
FactType factType = kb.getFactType("org.numbercompare",
"NumberCompare");
Object nc = factType.newInstance();
factType.set(nc, "numberone", numberone);
factType.set(nc, "numbertwo", numbertwo);
StatefulKnowledgeSession ksession =
kb.newStatefulKnowledgeSession();
ksession.insert(nc);
ksession.fireAllRules();
ksession.dispose();
droolsDTO.setMessage(factType.get(nc, "message").toString());
return droolsDTO;
}
My changeset.xml
<change-set
xmlns='http://drools.org/drools-5.0/change-set'
xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
xs:schemaLocation='http://drools.org/drools-5.0/change-set
http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/...
<add
<resource
source='http://abc:8082/guvnor/org.drools.guvnor.Guvnor/package/org.numbercompare/LATEST'
type='PKG' basicAuthentication="enabled" username="admin"
password="admin"/
</add
</change-set
Also in the guvnor logs during the test I see
, I see thousands of these: WARN 28-01 11:50:55,551
(RulesRepositoryManager.java:getRulesRepository:70) Creating RulesRepository
with default username. =============== session-guest-864931
and the session-guest numbers keep climbing.
and admin user logging in about every second.
--
View this message in context:
http://drools.46999.n3.nabble.com/permgen-error-for-simple-rule-stress-te...
Sent from the Drools: User forum mailing list archive at
Nabble.com.