[JVM] Parallel execution in multiple threads in mutiple JVM instance

223 views
Skip to first unread message

Aswathy Nair

unread,
Feb 24, 2016, 9:03:51 AM2/24/16
to Cukes
Hi ,

I want to know whether parallel execution like forking multiple JVMs and spawning multiple threads in each JVM is possible or not.
For my application which has 8 modules. So each module has to run parallel and independently. So in framework I have created 8 runner class corresponding to each module. But when it comes to features, I have 3 features per module
so total of 24 feature files.

So I want to run each module in separate JVM instance(which i already achieved with maven surefire parallel plugin and forkcount) and to create each JVM 3 parallel  to run 3 feature files.

Can someone help me to know is it possible.


Kindly do needful.
Aswathy

Aswathy Nair

unread,
Feb 25, 2016, 4:01:55 AM2/25/16
to Cukes
Any help Pls ..

Regards,
Aswathy

Nick Mellor

unread,
Mar 22, 2016, 2:06:54 AM3/22/16
to Cukes
Hi Aswathy,

We achieved this (multi-threading cucumber-JVM sitting on Geb) by using the GPars library. BUT:

(1) the threads were too heavy. Each of our JVM instances is 750M in size and the threads barely improved on the performance of single-threading. I'm inclined to think there were just too many cache misses, and any gains from multi-threading were lost.

(2) Cucumber is still not thread-safe (am I right? I'm writing nearly a year on from our multi-threading tech spike) so there is some risk that you'll get strange bugs creeping in. In practice I didn't notice this happening when I ran our tests in 2 threads. If you're saving values between steps you will need to make sure they're saved in a thread-safe way (e.g. store them in a ConcurrentHashMap) but that still doesn't guarantee thread-safety if the Cucumber application is still not thread-safe.

(3) the more concurrent threads there are, the worse problems (1) and (2) get, so multi-threading will not scale well.

So my advice is to give up on multi-threading :(

We too need better performance for our Cucumber tests, so we may have a go at running tests concurrently on n AWS instances, served by a work queue (e.g. Amazon SQS.) That should scale well, and none of the thread-safe problems.

Cheers,

Nick

King Arsan

unread,
Mar 22, 2016, 6:40:42 AM3/22/16
to Cukes
Have a look on this,

https://opencredo.com/running-cucumber-jvm-tests-in-parallel/

If you are running in a single machine, then I always find bit slow in execution.

Other options would be using Jenkins or Selenium Grid to distribute the execution.

r
Arsan

Nick Mellor

unread,
Mar 22, 2016, 4:53:27 PM3/22/16
to Cukes
Hi Arsan,

That's a good approach, but we would like not to have to rely on tagging to split tests between machines.

For our multi-threaded version, we batched scenarios into small groups based on prior execution time, something we will probably do with the multi-tasking version. You can run individual scenario(s) by putting the feature file and line number on the cucumber command line.

Nick
Reply all
Reply to author
Forward
0 new messages