Congratulations on the new release!
Thanks for the sanity check on the design. Here is the code I am now using to explore perf. It’s pretty basic, but I believe operates in roughly same manner as perf test client included in downloads. I can get up to about 1500 messages/sec with current rig, depending on how I set params. Next step for me is to try out different hardware configs and see how that affects things.
using EventStore.ClientAPI;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
namespace MyEventStorePerf
{
class Program
{
class StreamTracker {
public string StreamName = “Perf-” + Guid.NewGuid().ToString();
public int WriteCount = 0;
public int HowManyWriters = 1;
public int HowManyMessages = 1;
public Stopwatch Watch = new Stopwatch();
}
static void Main(string[] args)
{
Console.WriteLine(“started”);
var conn = EventStoreConnection.Create(new System.Net.IPEndPoint(System.Net.IPAddress.Parse(“192.168.164.132”), 1113));
conn.Connect();
var starts = new List();
//500 30 per
int howManyStreams = 500;
int howManyMessages = 30;
int howManyWritersPerStream = 10;
var totalTime = new Stopwatch();
var streamCount = 0;
Action onFinished = () => {
Interlocked.Increment(ref streamCount);
if (streamCount == howManyStreams) {
totalTime.Stop();
var totalRequests = howManyStreams * howManyMessages;
var reqPerSec = (totalRequests + 0.0) / totalTime.ElapsedMilliseconds * 1000;
Console.WriteLine(“Total {0} requests completed in {1}ms ({2:0.00} reqs per sec).”, totalRequests, totalTime.ElapsedMilliseconds, reqPerSec);
Console.WriteLine(“finished”);
conn.Close();
}
};
Func<StreamTracker, Action> getStarter = _tracker => {
var tracker = _tracker;
var thread = new Thread(new ThreadStart(() =>
{
writeEvents(tracker, conn);
}));
return () => {
if (!tracker.Watch.IsRunning) {
tracker.Watch.Start();
}
thread.Start();
};
};
for (int i = 0; i < howManyStreams; i++) {
var tracker = new StreamTracker { HowManyWriters = howManyWritersPerStream, HowManyMessages = howManyMessages };
listenEvents(tracker, conn, onFinished);
for (int k = 0; k < howManyWritersPerStream; k++)
{
starts.Add(getStarter(tracker));
}
}
totalTime.Start();
foreach (var writeThread in starts) {
writeThread();
}
Console.ReadLine();
}
static void listenEvents(StreamTracker tracker, IEventStoreConnection conn, Action onFinished)
{
var count = 0;
conn.SubscribeToStream(tracker.StreamName, false, (sub, evt) =>
{
Interlocked.Increment(ref count);
if (count == tracker.HowManyMessages)
{
tracker.Watch.Stop();
var reqPerSec = (tracker.HowManyMessages + 0.0) / tracker.Watch.ElapsedMilliseconds * 1000;
Console.WriteLine("{0} requests completed in {1}ms ({2:0.00} reqs per sec).", tracker.HowManyMessages, tracker.Watch.ElapsedMilliseconds, reqPerSec);
onFinished();
}
});
}
static void writeEvents(StreamTracker tracker, IEventStoreConnection conn)
{
var _dataBytes = System.Text.Encoding.UTF8.GetBytes(“1”);
for (int i = 0; i < tracker.HowManyMessages; i++)
{
var msg = new EventData(Guid.NewGuid(), “PerfEvent”, true, _dataBytes, null);
Interlocked.Increment(ref tracker.WriteCount);
if (tracker.WriteCount <= tracker.HowManyMessages)
{
conn.AppendToStream(tracker.StreamName, ExpectedVersion.Any, msg);
}
else {
break;
}
}
}
}
}
``