Skip to content

feat: add resource utilisation middleware to monitor CPU and memory. #1352

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

Merged
merged 21 commits into from
Jun 21, 2025

Conversation

vkhinvasara
Copy link
Contributor

@vkhinvasara vkhinvasara commented Jun 17, 2025

Resource Utilization Thresholds: Sending 503 response if CPU/Memory thresholds exceed.

Description

This PR enhances our ingestion pipeline by implementing an overload protection mechanism during peak usage. Specifically, when CPU or memory utilization crosses predefined thresholds, the system will proactively reject further ingestion requests with an HTTP 503 (Service Unavailable) status. This prevents uncontrolled resource consumption and cascading failures.


File Changes

  • resource_check.rs: This is a middleware which checks resource utilization before every ingestion request.
  • modal/mod.rs : To wrap the above middleware.
  • http/mod.rs: To expose said middleware.

Summary by CodeRabbit

  • New Features

    • Introduced resource utilization monitoring and request throttling based on CPU and memory usage, with configurable thresholds and intervals.
    • Added middleware to automatically reject requests when system resources are over-utilized, returning a 503 Service Unavailable response.
    • Enabled new command-line options to configure resource check interval and CPU/memory thresholds.
  • Chores

    • Updated build cache key in the GitHub Actions workflow to improve cache management.

Copy link
Contributor

coderabbitai bot commented Jun 17, 2025

Walkthrough

A resource monitoring and throttling feature was introduced to the HTTP server. This includes a background task that monitors CPU and memory usage, configurable thresholds and intervals via CLI, middleware to reject requests when resources are over-utilized, and integration of this middleware into key HTTP endpoints. Supporting validation and workflow cache updates were also made.

Changes

File(s) Change Summary
src/handlers/http/mod.rs Declared new public resource_check module.
src/handlers/http/resource_check.rs Added resource monitoring module: background task, global flag, and Actix middleware for request throttling.
src/cli.rs Added CLI options for resource check interval and CPU/memory utilization thresholds.
src/option.rs Added validation functions for percentage and seconds input.
src/handlers/http/modal/ingest_server.rs
src/handlers/http/modal/query_server.rs
src/handlers/http/modal/server.rs
Wrapped ingestion and query endpoints with resource utilization middleware.
src/handlers/http/modal/mod.rs Integrated resource monitor lifecycle into server startup and shutdown.
.github/workflows/build.yaml Updated build cache key to a new version.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ActixServer
    participant ResourceMonitor
    participant Middleware

    Note over ResourceMonitor: Runs in background<br>periodically checks CPU/memory
    ResourceMonitor->>ResourceMonitor: Update RESOURCE_CHECK_ENABLED flag

    User->>ActixServer: Incoming HTTP request
    ActixServer->>Middleware: Pass request to middleware
    Middleware->>ResourceMonitor: Read RESOURCE_CHECK_ENABLED
    alt Resources OK
        Middleware->>ActixServer: Forward request to handler
    else Resources over-utilized
        Middleware->>User: Respond 503 Service Unavailable
    end
Loading

Suggested reviewers

  • parmesant

Poem

In the warren, servers hop and check,
Watching memory, CPU—by spec!
If things get hot, requests must wait,
The middleware guards every gate.
With thresholds set and warnings clear,
The system stays fast—no need to fear!
🐇💻


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 305ad25 and 63e7a58.

📒 Files selected for processing (1)
  • .github/workflows/build.yaml (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .github/workflows/build.yaml
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: Build Kafka aarch64-apple-darwin
  • GitHub Check: Build Default aarch64-unknown-linux-gnu
  • GitHub Check: Quest Smoke and Load Tests for Distributed deployments
  • GitHub Check: Quest Smoke and Load Tests for Standalone deployments
  • GitHub Check: coverage
  • GitHub Check: Build Default x86_64-unknown-linux-gnu
  • GitHub Check: Build Default aarch64-apple-darwin
  • GitHub Check: Build Default x86_64-pc-windows-msvc
  • GitHub Check: Build Kafka x86_64-unknown-linux-gnu
  • GitHub Check: Build Default x86_64-apple-darwin

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
src/handlers/http/resource_check.rs (2)

29-30: Hard-coded thresholds → move to configuration

CPU_UTILIZATION_THRESHOLD and MEMORY_UTILIZATION_THRESHOLD are compile-time constants.
Making them environment- or config-driven (e.g. PARSEABLE.options) allows tuning without redeploying.


57-58: Include Retry-After header for back-pressure friendliness

When returning 503 Service Unavailable, consider adding Retry-After to hint clients when to attempt again:

-return Err(ErrorServiceUnavailable(error_msg));
+let mut err = ErrorServiceUnavailable(error_msg);
+err.response_mut().headers_mut().insert(
+    http::header::RETRY_AFTER,
+    http::HeaderValue::from_static("30"), // seconds
+);
+return Err(err);

Small change, big UX improvement.

src/handlers/http/modal/mod.rs (1)

48-48: Import grouping

resource_check is added to the gigantic super::{…} list. No functional issue, but grouping related imports (middleware modules together) would aid readability.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 97e5d42 and 4fb2da7.

📒 Files selected for processing (3)
  • src/handlers/http/mod.rs (1 hunks)
  • src/handlers/http/modal/mod.rs (2 hunks)
  • src/handlers/http/resource_check.rs (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/handlers/http/modal/mod.rs (1)
src/handlers/http/resource_check.rs (1)
  • check_resource_utilization_middleware (34-76)
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Build Default aarch64-apple-darwin
  • GitHub Check: Quest Smoke and Load Tests for Standalone deployments
  • GitHub Check: coverage
  • GitHub Check: Quest Smoke and Load Tests for Distributed deployments
  • GitHub Check: Build Default x86_64-pc-windows-msvc
  • GitHub Check: Build Default x86_64-unknown-linux-gnu
  • GitHub Check: Build Default aarch64-unknown-linux-gnu
  • GitHub Check: Build Kafka aarch64-apple-darwin
  • GitHub Check: Build Kafka x86_64-unknown-linux-gnu
🔇 Additional comments (3)
src/handlers/http/resource_check.rs (1)

61-63: refresh_cpu_usage needs a delay between calls

sysinfo computes CPU load as a delta between two successive calls. When you perform refresh_cpu_usage() and immediately read global_cpu_usage() without any pause, the value is often ~0 %. If the static System suggestion above is not adopted, you’ll need at minimum:

sys.refresh_cpu();
tokio::time::sleep(Duration::from_millis(200)).await;
sys.refresh_cpu();
let cpu_usage = sys.global_cpu_usage();

Failing to do so will under-report utilisation and the middleware might never trigger.

src/handlers/http/mod.rs (1)

39-40: Module export looks good

Publicly exposing resource_check integrates the new middleware cleanly; no further action required.

src/handlers/http/modal/mod.rs (1)

115-118: To verify the relative cost and early‐exit behavior of each middleware, let’s locate their implementations:

#!/bin/bash
# Find the shutdown‐check middleware implementation
rg -n "fn check_shutdown_middleware" -n .

# Find the resource‐utilization middleware implementation
rg -n "fn check_resource_utilization_middleware" -n .

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (1)
src/handlers/http/modal/ingest_server.rs (1)

129-132: Same duplication issue as in server.rs

See earlier comment – ensure the resource monitor is started exactly once per process.

🧹 Nitpick comments (5)
src/option.rs (1)

178-188: Unify percentage-validation helpers and numeric types

validate_percentage duplicates most of validate_disk_usage but returns f32 while the earlier helper uses f64.
Consider consolidating both into a single generic routine and sticking to one float type (prefer f64 throughout for higher precision and consistency).

src/handlers/http/modal/server.rs (2)

142-145: Guard against spawning multiple resource-monitor tasks

spawn_resource_monitor() is invoked here and again in ingest_server.rs.
If both server roles coexist in the same binary this will start two background loops polling the same SYS_INFO, doubling load and causing racy log noise.
Add a OnceCell/Lazy flag inside resource_check so the monitor is spawned only once.


158-159: Silently dropping the monitor task handle

The oneshot signal is sent, but the spawned task’s JoinHandle is not awaited. On orderly shutdown this may leak warnings if the task panics.
Store the handle and await it after sending the shutdown signal, similar to startup_sync_handle.

src/cli.rs (1)

320-338: Align threshold types with existing options

CPU and memory thresholds use f32 whereas --max-disk-usage-percent uses f64.
For a consistent public API (and to avoid accidental precision loss) consider switching these to f64 as well.

src/handlers/http/resource_check.rs (1)

33-34: Use AtomicBool for cheap lock-free reads

RESOURCE_CHECK_ENABLED is a single boolean read on every request. An AtomicBool with Ordering::Relaxed would avoid the async RwLock overhead and allocation per request.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4fb2da7 and 5ce1ab9.

📒 Files selected for processing (5)
  • src/cli.rs (1 hunks)
  • src/handlers/http/modal/ingest_server.rs (2 hunks)
  • src/handlers/http/modal/server.rs (3 hunks)
  • src/handlers/http/resource_check.rs (1 hunks)
  • src/option.rs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: Build Default x86_64-unknown-linux-gnu
  • GitHub Check: Build Default x86_64-pc-windows-msvc
  • GitHub Check: Quest Smoke and Load Tests for Distributed deployments
  • GitHub Check: Build Default x86_64-apple-darwin
  • GitHub Check: Quest Smoke and Load Tests for Standalone deployments
  • GitHub Check: Build Default aarch64-apple-darwin
  • GitHub Check: Build Default aarch64-unknown-linux-gnu
  • GitHub Check: Build Kafka x86_64-unknown-linux-gnu
  • GitHub Check: Build Kafka aarch64-apple-darwin
  • GitHub Check: coverage

coderabbitai[bot]
coderabbitai bot previously approved these changes Jun 18, 2025
@vkhinvasara vkhinvasara requested a review from parmesant June 18, 2025 09:05
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (5)
src/handlers/http/resource_check.rs (5)

41-45: Thresholds captured once – runtime config changes are ignored

cpu_threshold and memory_threshold are read before the loop and never refreshed.
If these values are expected to be hot-reloaded (e.g. via SIGHUP or admin API), the monitor will keep using the stale numbers. Consider moving the reads inside the tick branch:

-        let cpu_threshold = PARSEABLE.options.cpu_utilization_threshold;
-        let memory_threshold = PARSEABLE.options.memory_utilization_threshold;
+        // fetched on every iteration to pick up dynamic config changes

51-58: spawn_blocking each tick is avoidable overhead

Sampling three numeric fields from sysinfo is cheap and already guarded by a Mutex.
Spawning a blocking task every 30 s creates overhead and needless thread context switches.

-                    let (used_memory, total_memory, cpu_usage) = tokio::task::spawn_blocking(|| {
-                        let sys = SYS_INFO.lock().unwrap();
-                        ...
-                    }).await.unwrap();
+                    let (used_memory, total_memory, cpu_usage) = {
+                        let sys = SYS_INFO.lock().unwrap();
+                        (sys.used_memory() as f32,
+                         sys.total_memory() as f32,
+                         sys.global_cpu_usage())
+                    };

If you still worry about blocking, wrap the initial /proc scan in a background task and keep subsequent reads cheap.


70-73: Promote heavy log line to debug! (or throttle)

Emitting a full resource report at info on every 30-second tick can flood production logs.
Either:

  1. change to debug!, or
  2. log only on state changes (already handled below), or
  3. throttle with tracing::info!(rate = ...).

Minor, but keeps logs actionable.


70-73: Prefer f64 for GB conversion to avoid precision loss

used_memory / total_memory are cast to f32, then divided by 1024³. Large byte counts can exceed f32’s 24-bit mantissa and lose precision (especially on >128 GiB hosts).

-                          used_memory / 1024.0 / 1024.0 / 1024.0, 
-                          total_memory / 1024.0 / 1024.0 / 1024.0);
+                          (used_memory as f64) / 1024f64.powi(3),
+                          (total_memory as f64) / 1024f64.powi(3));

89-90: Acquire write lock once to read & update flag

Two separate lock calls (read then write) introduce an avoidable race window.
Capture the previous value while holding the write lock:

-                    let previous_state = *RESOURCE_CHECK_ENABLED.read().await;
-                    *RESOURCE_CHECK_ENABLED.write().await = resource_ok;
+                    let mut guard = RESOURCE_CHECK_ENABLED.write().await;
+                    let previous_state = *guard;
+                    *guard = resource_ok;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b58212f and f6a2517.

📒 Files selected for processing (1)
  • src/handlers/http/resource_check.rs (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
src/handlers/http/resource_check.rs (1)
Learnt from: vkhinvasara
PR: parseablehq/parseable#1352
File: src/handlers/http/resource_check.rs:70-74
Timestamp: 2025-06-18T08:43:30.100Z
Learning: The sysinfo crate (version 0.30+) returns memory values from `used_memory()` and `total_memory()` in bytes, not kilobytes. Converting bytes to GiB requires dividing by 1024³ (1,073,741,824). In older versions (pre-0.30), the methods returned kilobytes.
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: coverage
  • GitHub Check: Build Default aarch64-apple-darwin
  • GitHub Check: Build Default x86_64-pc-windows-msvc
  • GitHub Check: Build Kafka aarch64-apple-darwin
  • GitHub Check: Build Default x86_64-apple-darwin
  • GitHub Check: Build Default aarch64-unknown-linux-gnu
  • GitHub Check: Build Kafka x86_64-unknown-linux-gnu
  • GitHub Check: Build Default x86_64-unknown-linux-gnu
  • GitHub Check: Quest Smoke and Load Tests for Distributed deployments
  • GitHub Check: Quest Smoke and Load Tests for Standalone deployments
🔇 Additional comments (1)
src/handlers/http/resource_check.rs (1)

33-34: ```shell
#!/bin/bash
set -e

echo "=== Cargo.toml entries for Tokio ==="
rg -n '^\stokio\s=' --glob 'Cargo.toml' || echo "No direct Tokio entry in Cargo.toml"

echo
echo "=== Cargo.lock entries for Tokio ==="
rg -n '^tokio ' --glob 'Cargo.lock' || echo "No Tokio entries found in Cargo.lock"


</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

coderabbitai[bot]
coderabbitai bot previously approved these changes Jun 18, 2025
@vkhinvasara
Copy link
Contributor Author

vkhinvasara commented Jun 18, 2025

Example usage: cargo run local-store --cpu-utilization-threshold 80.0 --memory-utilization-threshold 80.0

@parmesant @nikhilsinhaparseable

coderabbitai[bot]
coderabbitai bot previously approved these changes Jun 18, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Jun 18, 2025
@vkhinvasara vkhinvasara changed the title feat: add resource utilization middleware to monitor CPU and memory u… feat: add resource utilisation middleware to monitor CPU and memory. Jun 18, 2025
@nikhilsinhaparseable
Copy link
Contributor

@vkhinvasara

  1. please add the behaviour for query server as well
  2. query utilises the CPU and memory the most, please add the check in query scope
  3. make the duration for for the resource utilisation check (30 secs) configurable through env var and default it to 15 secs

…ing interval to be taken from the cli via `--resource-check-interval` flag. Also wrapped the middleware around cpu intensive query endpoints available in `query.rs`.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/handlers/http/modal/query_server.rs (2)

57-60: Good middleware integration, but consider broader scope protection.

The middleware is correctly applied to the query factory and counts webscope using Actix Web's from_fn pattern. However, consider whether other resource-intensive endpoints in the query server should also be protected.

For example, endpoints like /logstream/{logstream}/stats (line 306-310) and cluster metrics endpoints might also benefit from resource monitoring, given that the PR objectives mention the query server "utilizes CPU and memory heavily."

Consider applying the middleware at a broader scope or to additional endpoints:

 .service(
     web::scope(&base_path())
+        .wrap(from_fn(resource_check::check_resource_utilization_middleware))
         .service(Server::get_correlation_webscope())
-        .service(
-            Server::get_query_factory()
-                .wrap(from_fn(resource_check::check_resource_utilization_middleware))
-        )
+        .service(Server::get_query_factory())

Also applies to: 73-76


164-165: Improve resource monitor shutdown error handling.

The shutdown signal ignores potential errors with let _ = resource_shutdown_tx.send(());. While the receiver might be dropped, it's better to log shutdown issues for debugging purposes.

Consider logging shutdown issues:

 // Shutdown resource monitor
-let _ = resource_shutdown_tx.send(());
+if let Err(_) = resource_shutdown_tx.send(()) {
+    tracing::debug!("Resource monitor may have already been shut down");
+}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f90714d and cd8c029.

📒 Files selected for processing (5)
  • src/cli.rs (1 hunks)
  • src/handlers/http/modal/query_server.rs (4 hunks)
  • src/handlers/http/modal/server.rs (8 hunks)
  • src/handlers/http/resource_check.rs (1 hunks)
  • src/option.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/option.rs
  • src/handlers/http/modal/server.rs
  • src/cli.rs
  • src/handlers/http/resource_check.rs
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: Quest Smoke and Load Tests for Standalone deployments
  • GitHub Check: Quest Smoke and Load Tests for Distributed deployments
  • GitHub Check: coverage
  • GitHub Check: Build Kafka x86_64-unknown-linux-gnu
  • GitHub Check: Build Default aarch64-apple-darwin
  • GitHub Check: Build Default x86_64-apple-darwin
  • GitHub Check: Build Kafka aarch64-apple-darwin
  • GitHub Check: Build Default x86_64-unknown-linux-gnu
  • GitHub Check: Build Default aarch64-unknown-linux-gnu
  • GitHub Check: Build Default x86_64-pc-windows-msvc
🔇 Additional comments (1)
src/handlers/http/modal/query_server.rs (1)

25-25: LGTM: Import additions are correct.

The imports for resource_check and from_fn middleware are properly added to support the resource utilization monitoring functionality.

Also applies to: 32-32

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/handlers/http/modal/mod.rs (1)

149-150: Consider logging resource monitor shutdown status.

The shutdown signal uses let _ = resource_shutdown_tx.send(()); which silently ignores potential errors. While this might be intentional if the receiver could already be dropped, consider logging the result for better observability during shutdown sequences.

-            // Shutdown resource monitor
-            let _ = resource_shutdown_tx.send(());
+            // Shutdown resource monitor
+            if let Err(_) = resource_shutdown_tx.send(()) {
+                warn!("Resource monitor receiver already dropped during shutdown");
+            }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4578d0c and 53a4532.

📒 Files selected for processing (4)
  • src/handlers/http/modal/ingest_server.rs (5 hunks)
  • src/handlers/http/modal/mod.rs (3 hunks)
  • src/handlers/http/modal/query_server.rs (3 hunks)
  • src/handlers/http/modal/server.rs (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/handlers/http/modal/query_server.rs
  • src/handlers/http/modal/ingest_server.rs
  • src/handlers/http/modal/server.rs
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: Build Default aarch64-unknown-linux-gnu
  • GitHub Check: Build Default x86_64-pc-windows-msvc
  • GitHub Check: Build Default aarch64-apple-darwin
  • GitHub Check: Build Default x86_64-apple-darwin
  • GitHub Check: Build Default x86_64-unknown-linux-gnu
  • GitHub Check: Build Kafka aarch64-apple-darwin
  • GitHub Check: Build Kafka x86_64-unknown-linux-gnu
  • GitHub Check: coverage
  • GitHub Check: Quest Smoke and Load Tests for Distributed deployments
  • GitHub Check: Quest Smoke and Load Tests for Standalone deployments
🔇 Additional comments (2)
src/handlers/http/modal/mod.rs (2)

48-48: LGTM - Clean module import addition.

The addition of resource_check to the import statement properly exposes the resource monitoring functionality for use in the server lifecycle.


110-112: Resource monitor startup integration looks correct.

The resource monitor is properly initialized with a oneshot channel for graceful shutdown control. Starting it before the HTTP server creation ensures the monitoring infrastructure is ready when middleware begins checking resource utilization.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jun 19, 2025
@vkhinvasara
Copy link
Contributor Author

@nikhilsinhaparseable

Example usage: cargo run local-store --resource-check-interval 10

Changes:

  • Added resource check interval in cli.rs, making it now configurable with the default value of 15 seconds.
  • Wrapped the middleware around only query.rs and ingest.rs endpoints.

Changes made so far in this PR:

  • Added resource monitoring middleware (resource_check.rs)
  • Made the threshold for cpu/memory configurable (cli.rs).
  • Registered the monitor to the start of this server through a channel, accounting for graceful shutdown.

@vkhinvasara vkhinvasara self-assigned this Jun 19, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Jun 19, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Jun 19, 2025
Copy link
Contributor

@nikhilsinhaparseable nikhilsinhaparseable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5b142b7 and da3583a.

📒 Files selected for processing (1)
  • src/analytics.rs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: Build Kafka aarch64-apple-darwin
  • GitHub Check: Build Default x86_64-apple-darwin
  • GitHub Check: Build Default x86_64-unknown-linux-gnu
  • GitHub Check: Build Default x86_64-pc-windows-msvc
  • GitHub Check: Build Default aarch64-unknown-linux-gnu
  • GitHub Check: Build Default aarch64-apple-darwin
  • GitHub Check: Quest Smoke and Load Tests for Distributed deployments
  • GitHub Check: Build Kafka x86_64-unknown-linux-gnu
  • GitHub Check: Quest Smoke and Load Tests for Standalone deployments
  • GitHub Check: coverage

coderabbitai[bot]
coderabbitai bot previously approved these changes Jun 20, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Jun 20, 2025
Copy link
Contributor

@nikhilsinhaparseable nikhilsinhaparseable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved

@nitisht nitisht merged commit 61697ea into parseablehq:main Jun 21, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants