Created
October 21, 2014 08:26
-
-
Save rofr/3c1f53ed716a1485e637 to your computer and use it in GitHub Desktop.
OrigoDB approaching 100k transactions per second with Akka.NET and GetEventStore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Serializable] | |
public class CommandBatch | |
{ | |
public readonly Command[] Commands; | |
public CommandBatch(IEnumerable<Command> commands) | |
{ | |
Commands = commands.ToArray(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EventStoreJournal : IJournalWriter | |
{ | |
private readonly IEventStoreConnection _eventStore; | |
private readonly IFormatter _formatter; | |
public EventStoreJournal(IEventStoreConnection connection) | |
{ | |
_formatter = new BinaryFormatter(); | |
_eventStore = connection; | |
} | |
public async Task AppendAsync(IEnumerable<Command> commands) | |
{ | |
await _eventStore.AppendToStreamAsync("akka", ExpectedVersion.Any, ToEventData(commands)); | |
} | |
private EventData ToEventData(IEnumerable<Command> commands) | |
{ | |
var id = Guid.NewGuid(); | |
var stream = new MemoryStream(); | |
_formatter.Serialize(stream, new CommandBatch(commands)); | |
return new EventData(id, "akka", false, stream.ToArray(), null); | |
} | |
public void Dispose() | |
{ | |
_eventStore.Close(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Batch size: 10 | |
async elapsed: 00:00:00.3937971 | |
Batch size: 20 | |
async elapsed: 00:00:00.1693689 | |
Batch size: 40 | |
async elapsed: 00:00:00.1212457 | |
Batch size: 80 | |
async elapsed: 00:00:00.1002378 | |
Batch size: 160 | |
async elapsed: 00:00:00.1115851 | |
Batch size: 320 | |
async elapsed: 00:00:00.1092974 | |
Batch size: 640 | |
async elapsed: 00:00:00.1316378 | |
Batch size: 1280 | |
async elapsed: 00:00:00.1281053 | |
Batch size: 2560 | |
async elapsed: 00:00:00.1047487 | |
Batch size: 5120 | |
async elapsed: 00:00:00.1486240 | |
Batch size: 10240 | |
async elapsed: 00:00:00.1450204 | |
Batch size: 20480 | |
async elapsed: 00:00:00.1629530 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
100k tps is actually not correct, it's slightly less than 50k tps. There was a very silly mistake in the test code.