Skip to content

[MP][UX][Docs] Enhance http server and its docs for MP mode#2722

Merged
ApostaC merged 5 commits intoLMCache:devfrom
ApostaC:local-dev/clear-cache-endpoint
Mar 10, 2026
Merged

[MP][UX][Docs] Enhance http server and its docs for MP mode#2722
ApostaC merged 5 commits intoLMCache:devfrom
ApostaC:local-dev/clear-cache-endpoint

Conversation

@ApostaC
Copy link
Copy Markdown
Contributor

@ApostaC ApostaC commented Mar 9, 2026

What this PR does / why we need it:

Adds a POST /api/clear-cache endpoint to the MP mode HTTP server that force-clears all KV cache data stored in L1 (CPU) memory. Also simplifies the /api/healthcheck endpoint by removing the expensive memcheck() call — it now only checks that the engine is initialized.

Updates the MP mode documentation (quickstart, architecture, deployment) to cover all HTTP API endpoints including the new clear-cache, the upstream status endpoint, and the simplified healthcheck.

Special notes for your reviewers:

The /api/status endpoint was added upstream — this PR only adds its documentation.

If applicable:

  • this PR contains user facing changes - docs added
  • this PR contains unit tests

ApostaC added 2 commits March 9, 2026 23:20
Signed-off-by: ApostaC <yihua98@uchicago.edu>
Signed-off-by: ApostaC <yihua98@uchicago.edu>
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the multiprocess (MP) mode HTTP server by introducing a new API endpoint for cache management and streamlining an existing health check. It also provides comprehensive documentation updates across various guides to ensure all HTTP API functionalities are clearly described, improving the server's operational utility and clarity for users.

Highlights

  • New API Endpoint: Added a POST /api/clear-cache endpoint to the MP mode HTTP server, allowing for the force-clearing of all KV cache data stored in L1 (CPU) memory.
  • Simplified Healthcheck: The /api/healthcheck endpoint was simplified by removing the expensive memcheck() call, now only verifying that the engine is initialized.
  • Enhanced Documentation: Updated the MP mode documentation (quickstart, architecture, deployment) to comprehensively cover all HTTP API endpoints, including the new clear-cache, the upstream status endpoint, and the simplified healthcheck.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • docs/source/mp/architecture.rst
    • Updated description of http_server.py to include POST /api/clear-cache and /api/status endpoints.
    • Revised the description for lmcache/v1/multiprocess/http_server.py in the key source files table to reflect its expanded API functionality.
  • docs/source/mp/deployment.rst
    • Modified the HTTP server variant description to highlight support for cache management API.
  • docs/source/mp/quickstart.rst
    • Updated the introductory text for the HTTP server quick start to mention HTTP management endpoints.
    • Replaced the simple health check example with a detailed list-table of all HTTP endpoints (/api/healthcheck, /api/clear-cache, /api/status) and provided corresponding curl examples.
  • lmcache/v1/multiprocess/http_server.py
    • Removed the engine.storage_manager.memcheck() call from the /api/healthcheck endpoint, simplifying its logic to only check engine initialization.
    • Implemented a new POST /api/clear-cache endpoint that triggers engine.clear() to force-clear L1 KV cache data.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@ApostaC ApostaC requested review from Oasis-Git and YaoJiayi March 9, 2026 23:25
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request enhances the multi-process HTTP server by adding a /api/clear-cache endpoint and simplifying the /api/healthcheck endpoint. However, the new /api/clear-cache endpoint lacks authentication, which could allow unauthorized users to perform destructive operations on the cache, leading to a potential Denial of Service (DoS). Additionally, there is an inconsistency in the quickstart guide regarding the health check's behavior that needs addressing.

Comment on lines +108 to +125
@app.post("/api/clear-cache")
async def clear_cache(request: Request):
"""
Force-clear all KV cache data stored in L1 (CPU) memory.

This clears all objects including those with active read/write locks.
In-flight store or prefetch operations may be corrupted.
"""
engine = getattr(request.app.state, "engine", None)
if engine is None:
return JSONResponse(
status_code=503,
content={"status": "unhealthy", "reason": "memory check failed"},
content={"status": "error", "reason": "engine not initialized"},
)

return {"status": "healthy"}
engine.clear()
logger.info("Cache cleared via HTTP API")
return {"status": "ok"}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

security-medium medium

The new /api/clear-cache endpoint allows any user who can reach the HTTP server to force-clear all KV cache data in L1 memory. This is a destructive operation that can also corrupt in-flight store or prefetch operations. Exposing such a management endpoint without any authentication or authorization mechanism poses a risk of Denial of Service (DoS). It is highly recommended to implement an authentication mechanism (e.g., API key, bearer token) for administrative endpoints like this.

Comment on lines +152 to +153
- Returns ``{"status": "healthy"}`` when the engine is initialized and
memory checks pass. Suitable for Kubernetes liveness/readiness probes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The description for the /api/healthcheck endpoint is no longer accurate. This pull request removes the memcheck() call from the health check, so it no longer needs to 'memory checks pass'. The documentation should be updated to reflect that it only checks for engine initialization.

Suggested change
- Returns ``{"status": "healthy"}`` when the engine is initialized and
memory checks pass. Suitable for Kubernetes liveness/readiness probes.
- Returns ``{"status": "healthy"}`` when the engine is initialized.
Suitable for Kubernetes liveness/readiness probes.

@ApostaC
Copy link
Copy Markdown
Contributor Author

ApostaC commented Mar 10, 2026

Need to merge #2723 first

@ApostaC ApostaC added the full Run comprehensive tests on this PR label Mar 10, 2026
@ApostaC ApostaC merged commit c2642c9 into LMCache:dev Mar 10, 2026
24 of 28 checks passed
shaoxiawjc pushed a commit to shaoxiawjc/LMCache that referenced this pull request Mar 11, 2026
…2722)

* update http server for clear-cache and update docs

* update docs

* add config to specify engine

Signed-off-by: ApostaC <yihua98@uchicago.edu>
Signed-off-by: shaoxiawjc <wjc2800@163.com>
realAaronWu pushed a commit to realAaronWu/LMCache that referenced this pull request Mar 20, 2026
…2722)

* update http server for clear-cache and update docs

* update docs

* add config to specify engine

Signed-off-by: ApostaC <yihua98@uchicago.edu>
Signed-off-by: Aaron Wu <aaron.wu@dell.com>
jooho-XCENA pushed a commit to xcena-dev/LMCache that referenced this pull request Apr 2, 2026
…2722)

* update http server for clear-cache and update docs

* update docs

* add config to specify engine

Signed-off-by: ApostaC <yihua98@uchicago.edu>
jooho-XCENA pushed a commit to xcena-dev/LMCache that referenced this pull request Apr 2, 2026
…2722)

* update http server for clear-cache and update docs

* update docs

* add config to specify engine

Signed-off-by: ApostaC <yihua98@uchicago.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full Run comprehensive tests on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants