在使用Masstransit和RabbitMQ时,我看到了一个令人失望的性能。递送/获取下降到0.20/秒。我用一个简单的测试应用程序开始调查这个问题。这个应用程序并行运行,一个线程使用RabbitMQ客户机库向RabbitMQ发送消息,另一个线程使用Masstransit库向RabbitMQ发送相同的消息。RabbitMQ客户端库发送的消息是Masstransit库的10倍。
RabbitMQ运行在HyperV机器中的Docker容器中。Masstransit的PublishConfirm标志有一些影响,但没有那么大。为了得到公平的比较,a为RabbitMQ情况定义了与Masstransit情况相同的拓扑。
Masstransit代码:
public MasstransitMessageSender(string user, string password, string rabbitMqHost)
{
this.user = user;
this.password = password;
this.rabbitMqHost = rabbitMqHost;
}
public RabbitMqMessageSender(string user, string password, string rabbitMqHost)
{
var myUri = new Uri(rabbitMqHost);
this.factory = new ConnectionFactory
{
HostName = myUri.Host,
UserName = user,
Password = password,
VirtualHost = myUri.LocalPath,
Port = (myUri.Port > 0 ? myUri.Port : -1),
AutomaticRecoveryEnabled = true
};
}
public Task SendCommands(int numberOfMessages)
{
return Task.Run(() =>
{
var busControl = global::MassTransit.Bus.Factory.CreateUsingRabbitMq(
sbc =>
{
// Host control
var host =
sbc.Host(
new Uri(this.rabbitMqHost),
h =>
{
h.Username(this.user);
h.Password(this.password);
h.Heartbeat(60);
h.PublisherConfirmation = false;
});
});
busControl.StartAsync().Wait();
var task = busControl.GetSendEndpoint(new Uri(this.rabbitMqHost + "/MasstransitService"));
var tasks = new List<Task>();
task.Wait();
var endpoint = task.Result;
for (var i = 0; i < numberOfMessages; i++)
{
tasks.Add(endpoint.Send<IMyMessage>(new
{
Number = i,
Description = "MyMessage"
}));
}
Task.WaitAll(tasks.ToArray());
});
}
RabbitMQ代码:
public RabbitMqMessageSender(string user, string password, string rabbitMqHost)
{
var myUri = new Uri(rabbitMqHost);
this.factory = new ConnectionFactory
{
HostName = myUri.Host,
UserName = user,
Password = password,
VirtualHost = myUri.LocalPath,
Port = (myUri.Port > 0 ? myUri.Port : -1),
AutomaticRecoveryEnabled = true
};
}
public Task SendCommands(int numberOfMessages)
{
return Task.Run(() =>
{
using (var connection = this.factory.CreateConnection())
{
using (var channel = connection.CreateModel())
{
var messageProperties = channel.CreateBasicProperties();
channel.ExchangeDeclare("PerformanceConsole:ShowRabbitMqMessage", "fanout", true, false, null);
channel.ExchangeDeclare("RabbitMqService", "fanout", true, false, null);
channel.QueueDeclare("RabbitMqService", true, false, false, null);
channel.ExchangeBind("RabbitMqService", "PerformanceConsole:ShowRabbitMqMessage", "", null);
channel.QueueBind("RabbitMqService", "RabbitMqService", "", null);
for (var i = 0; i < numberOfMessages; i++)
{
var bericht = new
{
Volgnummer = 1,
Tekst = "Bericht"
};
var body = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(bericht));
channel.BasicPublish("RabbitMqService", "", messageProperties, body);
}
}
}
});
}
使用MassTransit-Benchmark我在我的MacBook Pro 2015上得到了以下性能,在OS X上使用NetcoreApp2.2。
PhatBoyG-Pro15:MassTransit-Benchmark Chris$ dotnet run -f netcoreapp2.2 -- --clients=50 --count=50000 --prefetch=100
MassTransit Benchmark
Transport: RabbitMQ
Host: localhost
Virtual Host: /
Username: guest
Password: *****
Heartbeat: 0
Publisher Confirmation: False
Running Message Latency Benchmark
Message Count: 50000
Clients: 50
Durable: False
Payload Length: 0
Prefetch Count: 100
Concurrency Limit: 0
Total send duration: 0:00:05.2250045
Send message rate: 9569.37 (msg/s)
Total consume duration: 0:00:07.2385114
Consume message rate: 6907.50 (msg/s)
Concurrent Consumer Count: 8
Avg Ack Time: 4ms
Min Ack Time: 0ms
Max Ack Time: 251ms
Med Ack Time: 4ms
95t Ack Time: 6ms
Avg Consume Time: 1431ms
Min Consume Time: 268ms
Max Consume Time: 2075ms
Med Consume Time: 1639ms
95t Consume Time: 2070ms
您可以下载基准测试并自己运行:https://github.com/masstransit/masstransit-benchmark
问题内容: 将Java ORM用于MongoDB的开销是多少?或者更好的是,我们在基本驱动程序级别进行读写? 我们将为我们的要求之一添加Mongo DB。 有对Java夫妇的Java ORM映射工具 -morphia -Spring数据 - 其他 Morphia的最新版本已于一年多以前发布, 但Spring数据得到了积极维护。如果我现在要开始使用哪一个, 问题答案: 使用ORM会降低性能,但会加快
但这并不能解决我的问题。我在我的分级中启用了multidex,因为没有它我会得到错误: com.android.dex.DexIndexOverflowException:方法ID不在[0,0xFFFF]:65536 所以这是一个解决方案,它在以前的Android Studio版本(也适用于公司的其他人,他们正在使用Android Studio1.4-2.0),但在我升级了我的Android St
我的docker撰写文件如下所示: 如果我在浏览器中键入http://localhost:15672,我将获得Rabbitmq界面,但是如果我试图像这样从我的探索项目连接: 然后它在队伍中断了 错误是说 ExtendedSocketException:连接被拒绝127.0。0.1:5672系统。网插座。插座EndConnect(IAsyncResult异步结果) ConnectFailureExc
MassTransit 是一个 .NET 的分布式应用开发框架。
案例1: 使用时: 获取异常: 看到的超文本标记语言套件异常:java.lang.RuntimeException:java.lang.RuntimeException: GoogleChrome在路径中找不到!请将包含“chrome.exe”或“google-chrome”或“GoogleChrome”的目录添加到您的PATH环境可用,或显式指定GoogleChrome路径,如下所示:*goog
Debug.DockerFile 运行命令 正在连接RabbitMQ