-
Notifications
You must be signed in to change notification settings - Fork 83
Refactor client #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor client #73
Conversation
fix remove clone clean up fix
I updated the test script. It contained a small bug that caused the futures to be spawned in the loop. New client for each request Reuse Client I also wrapped the |
Thanks for this PR. Great addition and time improvement! Maybe we can integrate your test script into the test suite to prevent performance regressions in the future? Although it also greatly depends on the InfluxDb performance. What do you think? |
I think it is difficult to design the script in such a way that it outputs meaningful/reliable values. The performance depends on many factors such as: the host system (hardware), the network latency, the influxdb configuration and, as you already mentioned, influxdb itself. Therefore, the result of the script would not be suitable for comparing it against fixed values. But I agree, the script could give at least an indication for any performance regressions. However, I would have to adjust it a bit. It seems that sometimes the script generates too many requests too quickly, which leads to some connection errors. Maybe something like backpressure could help here. I think I will implement something tomorrow. Do you prefer to have the test script in this or in a separate pr? |
Maybe we should then just add the script into the project which can be used manually to test performance. |
Alright, I have adjusted the script. I took some ideas from this blog post. I put the script into |
Awesome! Thanks a lot! |
Your PR is now under 0.3.0 at crates.io: https://crates.io/crates/influxdb Thanks again for your contribution! |
Description
I recently saw that instead of creating one
request::Client
and reusing it for further requests, we always create a new for each single request.request::Client
internally manages a connection pool with which we can reuse the underlying connection. This can significantly improve performance of read/write requests.This PR revises the influx client in such a way that the influx client only creates a
request::Client
at the beginning and reuses it for later requests.I did a small test on my machine and the results look promising:
New client for each request
10k write request
done in: 6.825374934s
Reuse Client
10k write request
done in: 903.934066ms
Here is the test script if you want to test as well
Note
I have restricted the visibility of the
Client
fields. It would be a breaking API change for the people who currently using the old fields.Checklist
cargo fmt --all
cargo clippy --all-targets --all-features -- -D warnings
cargo readme -r influxdb -t ../README.tpl > README.md