datalust / serilog-sinks-seq

A Serilog sink that writes events to the Seq structured log server
https://datalust.co/seq
Apache License 2.0
225 stars 50 forks source link

Performance Expections when logging to SEQ #122

Closed chrisfink closed 4 years ago

chrisfink commented 5 years ago

When logging to SEQ using Serilog, I am seeing average execution times between 150 and 200ms which seems very high to me.

I have attached a test tool which I am using to produce these results. I have hidden the SEQ URL; but SEQ is within our network and running on adequate hardware. I have also pared down the logging to a bare minimum to try to isolate any issues by removing our enrichers and turning off the selflog to diagnose any issues.

As you can see in the example, the logging is bared boned and still taking 150ms plus. My understanding is that Serilog is async out of the box which brings up a few questions.

  1. What execution time should I be expecting out of SeriLog? My hope was sub 10ms execution times.
  2. Is there anything else I can do to improve the performance?

Appreciate any feedback you can provide. Performance is critical before we push this logging to production and these metrics are a big blocker for us at the moment.

Thank you!

SerilogStressTest.txt

nblumhardt commented 5 years ago

Hi Chris, thanks for getting in touch!

In your stress test, it looks like you're constructing and tearing down the whole logging pipeline on every iteration, which will block while asychronously-batched events are flushed across the network.

To fix this, the logging pipeline should be constructed only once at app start-up, i.e. LoggerConfiguration.CreateLogger(), and torn down only on a clean application exit (Log.CloseAndFlush()).

Let me know if this helps, Nick

nblumhardt commented 4 years ago

If you're still hitting issues in your testing, please drop me a line - closing this one as stale for now. Cheers!