예제 #1
0
        static void Main()
        {
            var configPath = Path.Combine(ApplicationEnvironment.ApplicationBasePath, "config.json");

            SettingsProvider.FillFromFile(configPath);
            var settings    = SettingsProvider.GetSettings();
            var baseAddress = $"http://*:{settings.ServicePort}/";

            new WebHostBuilder()
            .UseKestrel()
            .UseContentRoot(Directory.GetCurrentDirectory())
            .UseStartup <Startup>()
            .UseUrls(baseAddress)
            .Build()
            .Run();
        }
예제 #2
0
 private void Load(int requestCount, int bodySize, bool publishToKafka)
 {
     if (publishToKafka)
     {
         if (SettingsProvider.GetSettings().MergeMessages)
         {
             var body = GetRandomBody(bodySize * requestCount);
             kafkaProducer.Produce(TopicName, Guid.NewGuid(), body);
         }
         else
         {
             for (var i = 0; i < requestCount; i++)
             {
                 var body = GetRandomBody(bodySize);
                 random.NextBytes(body);
                 kafkaProducer.Produce(TopicName, Guid.NewGuid(), body);
             }
         }
     }
 }
        private static KafkaProducer CreateKafkaProducer()
        {
            var topology     = TopologyService.GetTopology("Kafka");
            var settings     = SettingsProvider.GetSettings();
            var kafkaSetting = new KafkaSetting(settings.DisableKafkaReports)
                               .SetBootstrapServers(topology)
                               .SetAcks(1)
                               .SetRetries(0)
                               //.Set("queue.buffering.max.ms", 20)
                               .Set("auto.commit.interval.ms", 1400)
                               .Set("session.timeout.ms", 8400)
                               .Set("message.max.bytes", 1000000)
                               .Set("message.copy.max.bytes", 604000)
                               //.Set("receive.message.max.bytes", 92000000)
                               .Set("max.in.flight.requests.per.connection", 560000)
                               .Set("queue.buffering.max.messages", 9200800)
                               .Set("queue.buffering.max.kbytes", 839460)
                               .Set("queue.buffering.max.ms", 500)
                               .Set("batch.num.messages", 1000000)
                               .SetClientId("client-id");

            return(new KafkaProducer(kafkaSetting, OnMessageSent));
        }
예제 #4
0
 private async Task LoadAsync(int requestCount, int bodySize, bool publishToKafka)
 {
     if (publishToKafka)
     {
         if (SettingsProvider.GetSettings().MergeMessages)
         {
             var body = GetRandomBody(bodySize * requestCount);
             await kafkaProducer.ProduceAsync(TopicName, Guid.NewGuid(), body);
         }
         else
         {
             var tasks = new List <Task>();
             for (var i = 0; i < requestCount; i++)
             {
                 var body = GetRandomBody(bodySize);
                 random.NextBytes(body);
                 tasks.Add(kafkaProducer.ProduceAsync(TopicName, Guid.NewGuid(), body));
             }
             await Task.WhenAll(tasks.ToArray());
         }
     }
     MetricsReporter.Produced(requestCount, bodySize);
 }