Deadlock in INSERT ... ON DUPLICATE KEY UPDATE
Following the MySQL recommendations, some options I'd consider:


Check the SHOW ENGINE INNODB STATUS to see what the deadlock is on.
Convert the INSERT ON DUPLICATE KEY UPDATE into a SELECT then INSERT or UPDATE.
Reduce the size of the batches so they are quicker.
Reduce the concurrency.


What is the relation between the ids in the concurrent batches?  Do the ranges of ids overlap?