We're using the Jetty servlet container. On the main server it has always run on only one of the servers cores. It can keep dooing that on the main server. But now we've invested in a new power server which will run heavy jobs. It has 12 cores and hyper-threading so the system sees 24 cores. The web application is a .war. How do you spread the load over all 24 cores in the best way? I tried starting 24 threads by sending JMS messages, but it didn't work out that great. I got a lot of exceptions and strange calculation results. Now I think I'll try scheduling 24 jobs one second apart with org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean. Is that the best way to spread the load?
EDIT:
-----
Now I'm using the Spring concurrent classes. I implemented it following this example: [url="http://stackoverflow.com/questions/852743/any-good-spring-threading-with-a-taskexecutor-examples"]http://stackoverflow.com/questions/852743/any-good-spring-threading-with-a-taskexecutor-examples[/url]
I call the "fire"-method 24 times so I get 24 threads. And I use
Code:
<bean name="somethingThatShouldHappenInAThread" class="package.name.SomethingThatShouldHappenInAThread">
<constructor-arg type="org.springframework.core.task.TaskExecutor" ref="taskExecutor" />
<constructor-arg type="package.name.ClassWithMethodToFire" ref="classWithMethodToFireBean"/>
</bean>
<bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="corePoolSize" value="24" />
<property name="maxPoolSize" value="48" />
<property name="queueCapacity" value="100" />
</bean>
But I still get "Lock wait timeout exceeded" (It takes 10 minutes for it to arrive though. Prior to that it works normally as it should.)
Code:
2011-09-05 16:55:18,350 WARN [org.hibernate.util.JDBCExceptionReporter] - <SQL Error: 1205, SQLState: 41000>
2011-09-05 16:55:18,350 ERROR [org.hibernate.util.JDBCExceptionReporter] - <Lock wait timeout exceeded; try restarting transaction>
2011-09-05 16:55:18,352 ERROR [org.hibernate.event.def.AbstractFlushingEventListener] - <Could not synchronize database state with session>
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:126)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:114)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:168)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:304)
at sun.reflect.GeneratedMethodAccessor27.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:198)
at $Proxy38.flush(Unknown Source)
I have 24 threads trying to modify different entries of the same set of tables and a few of the same entries as the other threads. Mainly the last_run timestamp of the strategy which all 24 threads are trying to process. (There has to be 24 threads otherwise I don't think Jetty will spread the load over all 24 cores of the server machine.) I'm using ehcache. Should I try to turn of all caching? (how ever you do that?)