Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using RavenDB for Bulk inserts of data

I am trying to import large amounts of data (Twitter stream at about 20-25 tweets a second) into RavenDB for testing and large scale data testing. I have some code which is writing data quite well, but after a while I get an error:

Error while trying to add lots of data to RavenDB

I won't fill in all the code, but here is the gist of it:

Open RavenDB Session
Start reading data from Twitter Stream
For each line, parse JSON into known C# object
add item to RavenDB
increment counter
if counter % 25 = 0, save changes to RavenDB.

I have not tried what it has suggested, because it says to look at different ways of doing this. Should I kill my session every 200 or so inserts? Is there a way to insert an array of objects with Raven DB? Am I doing this completely wrong?

like image 712
TiernanO Avatar asked Apr 03 '12 17:04

TiernanO


1 Answers

Two option:

  • create a new sessions berefore the limit is reached (25 requests per session is a good value)
  • increase DocumentSession.Advanced.MaxNumberOfRequests to an appropriate value

Either way will work, although the second approach is slightly faster.

Edit: According to Orens comment below, it is actually the first approach that is faster.

like image 112
Daniel Lang Avatar answered Oct 19 '22 07:10

Daniel Lang