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

can run with granian by setting REFLEX_USE_GRANIAN var #3919

Merged
merged 6 commits into from
Sep 25, 2024

Conversation

Lendemor
Copy link
Collaborator

WIP: allow use of Granian instead of the uvicorn/gunicorn for running backend.

@itsmeadarsh2008
Copy link

itsmeadarsh2008 commented Sep 16, 2024

Thanks for this PR.
Edit: This shall improve the performance of API as it is written in rust.

@Lendemor Lendemor marked this pull request as ready for review September 17, 2024 01:21
@bertbarabas
Copy link

Is it worth trying this currently? I'd love to check if it helps the performance of the file upload since that problem seems to be in uvicorn/gunicorn.

reflex/utils/exec.py Outdated Show resolved Hide resolved
reflex/utils/exec.py Outdated Show resolved Hide resolved
@Lendemor
Copy link
Collaborator Author

Is it worth trying this currently? I'd love to check if it helps the performance of the file upload since that problem seems to be in uvicorn/gunicorn.

We would love to have more people trying it.
It is working, but testing in real condition rather than on basic app will let us know if anything need to be adjusted.

@bertbarabas
Copy link

How would I try this out? Is it in vv0.6.0a2 or do I need to do more or perhaps wait for it?

@Lendemor
Copy link
Collaborator Author

How would I try this out? Is it in vv0.6.0a2 or do I need to do more or perhaps wait for it?

If you want to try it right now, you can clone the project and use this branch to run reflex instead of the installed package.

It is not part of 0.6.0a2, and I'm not sure if it will be in 0.6.0, need to discuss it with the team.
At the latest I think it'll be in 0.6.1

@masenf
Copy link
Collaborator

masenf commented Sep 18, 2024

How would I try this out?

pip install git+https://github.com/reflex-dev/reflex@lendemor/use_granian granian
REFLEX_USE_GRANIAN=1 reflex run

Is it in vv0.6.0a2 or do I need to do more or perhaps wait for it?

planned for v0.6.1 in ~2 weeks

@Lendemor I tried this out and it seems to work in dev mode, but the websocket doesn't connect in prod mode and /ping gives "Internal Server Error"

@Lendemor
Copy link
Collaborator Author

I'll look into it, prod mode was running fine before my last commit I think

@bertbarabas
Copy link

Here are some timings of uploading a file of size: 522,134,318 bytes in my actual application in dev with browser and backend on the same laptop.
(I killed reflex and relaunched between tests)

REFLEX_USE_GRANIAN=0 reflex run
Run 1 took: 127 seconds
Run 2 took: 183 seconds

REFLEX_USE_GRANIAN=1 reflex run
Run 1 took: 63 seconds
Run 2 took: 104 seconds

Looks like Granian is faster although my laptop may not be the best place to measure speed, maybe the laptop gets slower as it gets hotter…

@Lendemor
Copy link
Collaborator Author

Lendemor commented Sep 19, 2024

I'll look into it, prod mode was running fine before my last commit I think

Turned out the backend never actually worked for prod mode, because I tested it with a stateless app.

It's working now.

@itsmeadarsh2008
Copy link

Here are some timings of uploading a file of size: 522,134,318 bytes in my actual application in dev with browser and backend on the same laptop. (I killed reflex and relaunched between tests)

REFLEX_USE_GRANIAN=0 reflex run Run 1 took: 127 seconds Run 2 took: 183 seconds

REFLEX_USE_GRANIAN=1 reflex run Run 1 took: 63 seconds Run 2 took: 104 seconds

Looks like Granian is faster although my laptop may not be the best place to measure speed, maybe the laptop gets slower as it gets hotter…

Try it in a codespace.

@adhami3310 adhami3310 merged commit 001b8c4 into main Sep 25, 2024
46 checks passed
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