[MP][UX][Docs] Enhance http server and its docs for MP mode#2722
[MP][UX][Docs] Enhance http server and its docs for MP mode#2722ApostaC merged 5 commits intoLMCache:devfrom
Conversation
Signed-off-by: ApostaC <yihua98@uchicago.edu>
Signed-off-by: ApostaC <yihua98@uchicago.edu>
Summary of ChangesHello, 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 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
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
| @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"} |
There was a problem hiding this comment.
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.
| - Returns ``{"status": "healthy"}`` when the engine is initialized and | ||
| memory checks pass. Suitable for Kubernetes liveness/readiness probes. |
There was a problem hiding this comment.
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.
| - 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. |
|
Need to merge #2723 first |
Signed-off-by: ApostaC <yihua98@uchicago.edu>
…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>
…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>
…2722) * update http server for clear-cache and update docs * update docs * add config to specify engine Signed-off-by: ApostaC <yihua98@uchicago.edu>
…2722) * update http server for clear-cache and update docs * update docs * add config to specify engine Signed-off-by: ApostaC <yihua98@uchicago.edu>
What this PR does / why we need it:
Adds a
POST /api/clear-cacheendpoint to the MP mode HTTP server that force-clears all KV cache data stored in L1 (CPU) memory. Also simplifies the/api/healthcheckendpoint by removing the expensivememcheck()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 upstreamstatusendpoint, and the simplified healthcheck.Special notes for your reviewers:
The
/api/statusendpoint was added upstream — this PR only adds its documentation.If applicable: