Page History
...
Code Block | ||
---|---|---|
| ||
public class BulkInsertTest : TestKitXunit { private AppSettings appSettings; public BulkInsertTest(ITestOutputHelper output) : base(output) { Setup(); } public void Setup() { appSettings = new AppSettings() { DBConnection = "server=localhost;port=33061;database=showa_searchakkadb;user=root;password=root;" }; } [Theory] [InlineData(50000, 100, 10)] //5만개의 데이터 인입에 소요시간은 10초이내여야한다. (배치사이즈:한번처리하는데 최대수:튜닝) public void BulkSppedTest(int daatSize,int batchSize, int cutoff) { var bulkItems_reseverd = new List<MessageReseved>(); for(int i = 0; i < daatSize; i++) { var addData = new MessageReseved() { Seq = i.ToString(), no = i, Message = "TestMessage" + i, updateTime = DateTime.Now }; bulkItems_reseverd.Add(addData); } Within(TimeSpan.FromSeconds(cutoff), () => { EntityFrameworkManager.ContextFactory = context => new BatchRepository(appSettings); using (var context = new BatchRepository(appSettings)) { context.BulkInsertAsync(bulkItems_reseverd, options => { options.BatchSize = batchSize; }).Wait(); } }); } } |
...
- src : https://github.com/psmon/AkkaForNetCore/blob/master/AkkaNetCoreTest/Repositories/BulkInsertTest.cs
- bulk insert를 처리하기위한 Entity Expand Lib : https://entityframeworkcore.com/saving-data-bulk-insert
- 싱글톤 클러스터 액터를 사용하여 데이터 인입지점 모으기 : SingleTon Cluster Actor