- 
                Notifications
    You must be signed in to change notification settings 
- Fork 3.2k
fix: dummy health check server not accessible on non-zero rank nodes #12297
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
base: main
Are you sure you want to change the base?
Conversation
| Summary of ChangesHello @ishandhanani, 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 addresses a critical bug where the dummy health check server failed to become accessible on non-zero rank nodes in multi-node inference setups. By refactoring the server's launch mechanism to utilize a separate daemon thread with its own event loop, the health check and metrics endpoints are now reliably available across all nodes, improving the robustness and observability of distributed SGLang deployments. Highlights
 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.
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 effectively resolves the issue of the dummy health check server being inaccessible on non-zero rank nodes. The root cause analysis is spot-on, and the solution of running the server in a dedicated daemon thread with its own event loop is robust and well-implemented. The change is clear and correct. I have one suggestion to further improve the robustness by adding exception handling in the new thread.
        
          
                python/sglang/srt/utils/common.py
              
                Outdated
          
        
      | def run_server(): | ||
| asyncio.run(server.serve()) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new implementation correctly runs the server in a background thread. However, if an exception occurs within server.serve() (e.g., the port is already in use), it will be raised in the background thread and terminate it silently. This could make debugging difficult as the main process would be unaware of the failure.
It's good practice to wrap the call in a try...except block to log any exceptions that occur in the thread. This will provide visibility into failures of the health check server.
| def run_server(): | |
| asyncio.run(server.serve()) | |
| def run_server(): | |
| try: | |
| asyncio.run(server.serve()) | |
| except Exception: | |
| logger.exception("Dummy health check server thread failed unexpectedly.") | 
Problem
When running multi-node inference with
--nnodes > 1and--node-rank >= 1, the dummy health check server logs that it's started but is not actually accessible:Inference works correctly across nodes, but the health check and metrics endpoints are unreachable on non-zero rank nodes.
Root Cause
The issue occurs in
launch_dummy_health_check_server()when called from an async context (e.g., custom distributed runtime wrappers or when an event loop policy is set):asyncio.get_running_loop()succeeds and finds the parent event looploop.create_task(server.serve())schedules the server as a taskproc.join()waiting for scheduler processesSolution
Run the health check server in a dedicated daemon thread with its own event loop:
Benefits:
Testing
Multi-node setup:
Custom async runtime:
Files Changed
python/sglang/srt/utils/common.py: Fixedlaunch_dummy_health_check_server()to use background thread