Running in an Spring-based application server context, an application is sometimes required to handle high rates of database inserts into one big table. The current implementation uses Spring Data with OpenJPA under the hood and is connected to an Amazon RDS (Postgresql 9.6) database. When it needs to persist something it just calls the Spring provided save method. After measuring the performance we found that it is able to write about 4000 records per second.
We built a dummy application to test several approaches and found that by doing 1000 inserts per batch using 4 connections in parallel yields the best performance at approximately 13500 records per second.
Now, we need to change application's code to buffer its persisted objects up to 1000 (or otherwise configured), run the batch insert procedure on these buffers when they are full or after some timeout period or upon server shutdown.
Anyone encountered such problem before? Any suggestions about threading issues, synchronization, data-structures?
Thanks in advance, Adrian.