Performant logging to database in rust?

I am writing my own interpretation of a DNS sinkhole in Rust. Now I want to log all incoming requests in a (time series) database. What is the best way to do this efficiently? I want to keep my DNS as fast as possible.

I tried using influxdb, but being new to Rust and not that familiar with Rust async programming I can't get it to work.
In the end it doesn't have to be influx, it's just important to me that it's fast and logs all queries reliably.

I guess I would send the log entry to another thread using a crossbeam_channel, so that the database performance doesn't affect the main thread.

Sled is fast and easy to use for a db. (and works without async)

thanks for your reply. Is it possible to implement crossbeam_channel without interfering with tokio async code or are these two completely different things? I thought tokio was doing something similar to threads
maybe this is a really dumb question but as mentioned im a beginner

Yes, I'm using crossbeam channels and tokio, they don't interfere. If I get it correctly, the things that would cause trouble with tokio are only other runtimes or non-async blocking functions.

If using multiple threads with tokio, you can enable tokio's feature rt-multi-thread to be sure that multiple threads are effectively used so they won't slow down each other.

Crossbeam provides non-blocking functions as well as blocking ones.

When using async in a thread, you just have to avoid non-async blocking functions in the same thread (afaik).

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.