Reputation: 638
I am working on a spring batch application where I am migrating millions or records from source db to destination db. While inserting the records into destination database, I am doing it in bulk inserts (1000 in each batch) and this way it inserts 3000 approx in a second.
destination db type - MS SQL server 2012, JDBC driver - JTDS
Now, I have a requirement where I should be able to reduce(not improve) the performance of the migration rate say 1000 records in 1 sec instead of inserting 3000. Is there a straight forward way to do this either using JDBC driver or any other configuration in spring?
Thanks,
Upvotes: 1
Views: 1304
Reputation: 48256
I would use Guava's RateLimiter.
It's pretty simple. Instantiate it somewhere (probably as a Spring bean):
double CALLS_PER_SECOND = 100;
RateLimiter rateLimiter = RateLimiter.create(CALLS_PER_SECOND);
Then use it in your loops:
rateLimiter.acquire();
You can't really do records/second, but you can do bytes/second or calls/second.
Upvotes: 1
Reputation: 340
Query Governor is similar to the limit option in Oracle: Link
Resource Governor allows you to set the min and max memory for the server: Link2
Upvotes: 0
Reputation: 43
Believe me, it's much easier to reduce the performance than to improve the performance. For Spring batch application, the easiest way is to sleep a while in your ItemWriter implementation for example.
Upvotes: 2