Skip to content
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

Split backend connection by read and write #256

Open
javuto opened this issue Apr 7, 2022 · 4 comments
Open

Split backend connection by read and write #256

javuto opened this issue Apr 7, 2022 · 4 comments
Assignees
Labels
backend Backend related issues osctrl-admin osctrl-admin related changes osctrl-api osctrl-api related changes osctrl-cli osctrl-cli related changes osctrl-tls osctrl-tls related changes

Comments

@javuto
Copy link
Collaborator

javuto commented Apr 7, 2022

Specify read and writer endpoints for the backend so it can be handled more efficiently.

@javuto javuto added osctrl-tls osctrl-tls related changes osctrl-api osctrl-api related changes osctrl-admin osctrl-admin related changes osctrl-cli osctrl-cli related changes backend Backend related issues labels Apr 7, 2022
@zhuoyuan-liu
Copy link
Contributor

zhuoyuan-liu commented Dec 16, 2024

I would like to take this issue with focus on osctrl-tls. I believe it's also the first step for other performance optimization tasks.

@zhuoyuan-liu
Copy link
Contributor

Currently, our OsqueryNode table maintains several timestamp columns—such as last_config, last_result, last_query_read, and last_status—to track when a node last reached out. Since these columns all represent similar events (i.e. a node "checking in"), I propose that we consolidate them into a single column called last_status. This change would simplify the schema and make it easier to reason about node activity.

In addition, because osquery nodes only check in every X minutes, we don’t need a 100% precise timestamp. We can tolerate a slight deviation (within less than X minutes) between the actual last-seen time and what’s stored in the database. This approximation would allow us to batch updates, thereby reducing the frequency of write operations.

Furthermore, regarding the IP address:

  • We should make IP address recording optional—configurable for environments where privacy is a concern or where IP data is not needed.
  • When IP recording is enabled, the system should update the stored IP address only when it actually changes rather than on every node check-in. Since a node's IP can change frequently (and often insignificantly), this condition will further reduce unnecessary write requests to the DB.

I believe these changes would improve our system’s efficiency while still providing sufficient information about node activity.

@javuto
Copy link
Collaborator Author

javuto commented Feb 21, 2025

How about I make the columns last_ to be updated in the DB every few hours, using a goroutine and the current value is kept in redis? I can start working on those changes and it should utilize the backend even less.

@zhuoyuan-liu
Copy link
Contributor

zhuoyuan-liu commented Feb 21, 2025

How about I make the columns last_ to be updated in the DB every few hours, using a goroutine and the current value is kept in redis? I can start working on those changes and it should utilize the backend even less.

Yes, it would be the next step. For now, caching them in memory already increased the performance significantly and would fit a lot of use cases. If we need to keep scaling up osctrl, it would be the same way as we did now. We just changed the backend from in-memory to Redis and it would be configurable. You can see the example here: https://github.com/zhuoyuan-liu/osctrl/blob/sync/tls/handlers/writers.go

What I want to discuss is that we can merge these last_ label into one as they have similar meanings ---indicate osquery last seen time. Also, we can remove some of the tables that have written heavy operations but didn't give much value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Backend related issues osctrl-admin osctrl-admin related changes osctrl-api osctrl-api related changes osctrl-cli osctrl-cli related changes osctrl-tls osctrl-tls related changes
Projects
None yet
Development

No branches or pull requests

2 participants