jeudi 7 juillet 2016

Processing hundreds of thousands of records using Hibernate and Threading, swiftly

I have a serious problem. I'm working on a code that should process over 500,000 records in an hour. Typically, each of these records has data in another table, which I have to go and look for while processing.

I am currently using hibernate. I tried using an Executor service with multiple threads to handle 100 records each - so that's, 10 threads, each processing a 100 record, and when a thread is done, it leaves the pool and another thread enters.

But the thing is, speed hasn't improved. I noticed, the more threads I run, the slower the whole process. Currently, it takes 2 mins for a thread to process 100 of these records. When I have 10 threads running, it takes 20 mins, which is essentially the same as running a thousand records in 1 thread!

I thought these threads were supposed to run concurrently. Is there a differently implementation I can utilise?

Mind you, I'm using a server that has 8 cores and 64GIG RAM.

Thanks

Aucun commentaire:

Enregistrer un commentaire