Skip to content
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

Refactor app backend to async #460

Merged
merged 16 commits into from
Feb 1, 2024
Merged

Refactor app backend to async #460

merged 16 commits into from
Feb 1, 2024

Conversation

sarah-widder
Copy link
Contributor

@sarah-widder sarah-widder commented Dec 16, 2023

This refactor is intended to improve the performance of the app by making the backend routes asynchronous and configuring the gunicorn worker count to support more concurrent requests.

  • Replace Flask with Quart to support ASGI
  • Upgrade openai to v1, use AsyncAzureOpenAI client for both with and without data
  • Use async client for chat history CosmosDB
  • Make all associated routes async
  • Add gunicorn config to dynamically set default worker count

To run locally:

  1. Install requirements python -m pip install -r requirements.txt
  2. Set up your .env file and run the VSCode debug configuration "Python: Quart"
  3. See app at http://127.0.0.1:50505/

To deploy:

  1. Run az webapp up --name <app name> --runtime "Python:3.11" --sku "B1" from the root of the repo.
  2. Change the startup command on the app service to python3 -m gunicorn app:app
  3. Restart the app.

To do:

  • Update documentation
  • Update deployment scripts and templates

@sarah-widder sarah-widder marked this pull request as ready for review January 11, 2024 02:40
@mrn-linak
Copy link

Hi @sarah-widder,

This is great! Do you have an ETA on when it might be merged?

@sarah-widder
Copy link
Contributor Author

Hi @sarah-widder,

This is great! Do you have an ETA on when it might be merged?

Hi @mrn-linak hoping for the end of this week. Thanks for your interest :)

@mrn-linak
Copy link

Hi @sarah-widder,
This is great! Do you have an ETA on when it might be merged?

Hi @mrn-linak hoping for the end of this week. Thanks for your interest :)

Amazing! Thanks for the reply :-)

@sarah-widder sarah-widder merged commit 28f962c into main Feb 1, 2024
1 check passed
@sarah-widder sarah-widder deleted the sawidder/async-refactor branch February 1, 2024 23:04
@junan-trustarc
Copy link

This refactor is intended to improve the performance of the app by making the backend routes asynchronous and configuring the gunicorn worker count to support more concurrent requests.

* Replace Flask with Quart to support ASGI

* Upgrade openai to v1, use AsyncAzureOpenAI client for both with and without data

* Use async client for chat history CosmosDB

* Make all associated routes async

* Add gunicorn config to dynamically set default worker count

To run locally:

1. Install requirements `python -m pip install -r requirements.txt`

2. Set up your .env file and run the VSCode debug configuration "Python: Quart"

3. See app at http://127.0.0.1:50505/

To deploy:

1. Run `az webapp up --name <app name> --runtime "Python:3.11" --sku "B1" ` from the root of the repo.

2. Change the startup command on the app service to `python3 -m gunicorn main:app`

3. Restart the app.

To do:

* Update documentation

* Update deployment scripts and templates

JFYI, anyone who uses before deployment script updates, change from "main:app" to "app:app" as it is typo.

  1. Change the startup command on the app service to python3 -m gunicorn app:app

@iMicknl
Copy link
Member

iMicknl commented Feb 2, 2024

@sarah-widder could it be that the start.sh / start.cmd scripts haven't been updated for these code changes?

sudo-init pushed a commit to sudo-init/sample-app-chatGPT that referenced this pull request Sep 20, 2024
nikhilnagaraj pushed a commit to Admin-bh-Edge/Edge-Comp-Policies that referenced this pull request Oct 2, 2024
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.

6 participants