Skip to content

Latest commit

 

History

22 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ray_serve_fastapi_tutorial

A simple tutorial on deploying fastapi apps using ray_serve

How to Run

Setting Up

  • Install Docker from here

    • Note: If you do not want to use Docker you can run the notebook/scripts directly on your machine also using jupyter lab
  • Run below script

    #!/bin/bash
    git clone https://github.com/abhishek9sharma/ray_serve_fastapi_tutorial.git
    cd  ray_serve_fastapi_tutorial
    make up_with_build 

Running the Jupyter Notebook

This notebook demonstrates how to deploy a Hello World FastAPI app Using Ray Serves Python API

Ray CLI

Below steps demonstrate how to deploy a Hello World FastAPI app Using Ray Serves CLI

  • Below comamnds should be run frome the cloned folder i.e. ray_serve_fastapi_tutorial

  • Change Directory to workspace ( if not using docker)

    • cd ray_serve_tutorial/workspace/
  • Install Environment

    chmod +x src/install_env.sh
    bash src/install_env.sh
    
  • Activate the environment

    source ray_env/bin/activate
    
  • Spin Up Ray Cluster

    • ray start --head --dashboard-host 0.0.0.0
    • Ray cluster should be visible at http://localhost:8265/
    • Status can also be verified using ray status
  • Serving App

    • Serve Ray App From CodeLocation

    • Serve Ray App From Config file

      • Run below commands
        • serve shutdown -y
        • serve build src.ray_fastapi:rayappadvanced -o serve_config_app.yaml
        • serve start --http-host 0.0.0.0 --http-port 8001
        • serve deploy serve_config_app.yaml
      • The app should be visible at http://localhost:8001/docs and serve at http://localhost:8001/hello
    • Serve Replica Autoscaling

      • Run app with autoscalilng config
        • Run command serve shutdown -y

        • Remove the num_replicas in serve_config_app.yaml

        • Add below config (You can refer serve_config_app_autoscale.yaml)

                max_ongoing_requests: 5
                autoscaling_config:
                    target_ongoing_requests: 2
                    min_replicas: 2
                    max_replicas: 5
          
        • Redeploy app using below commands

          • serve start --http-host 0.0.0.0 --http-port 8001
          • serve deploy serve_config_app.yaml
      • Simulate AutoScaling

References

About

A simple tutorial on how to wrap Fast API Apps on Ray Serve

Resources

Stars

0 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages