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

switch to hypercorn to reduce memory leak #93

Closed
wants to merge 2 commits into from

Conversation

vincentsarago
Copy link
Contributor

This PR change the ASGI web server for the STAC and Raster API to use Hypercorn instead of Uvicorn.

In fastapi/fastapi#1624 people mention that it resolved their issue. I've run a small tiler locally (simple titiler app) and confirmed that the memory growth was way more stable when using Hypercorn

Copy link
Member

@mmcfarland mmcfarland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some memory testing with a single process here too, against a uvicorn and hypercorn images as well as with and without our experimental malloc env var. In general, hypercorn with the flag was had the lowest rate of increase, but only marginally. The presence of the malloc flag still has an outsized impact in our scenario. If you see more stable consumption in a default titiler deployment, I'm inclined to merge this and evaluate in staging. In the dev environment, there wasn't a difference in workflow (hot reloading, etc)

@@ -37,6 +37,7 @@
# server deps
"server": [
"uvicorn[standard]>=0.12.0,<0.16.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the uvicorn dep can be removed here and in stac setup if the commands in docker-compose are similarly changed to

command: >
      bash -c "pypgstac pgready && hypercorn pcstac.main:app --bind 0.0.0.0:8081 --reload"

and

command: [ "hypercorn", "pctiler.main:app", "--bind", "0.0.0.0:8082", "--reload"  ]

@vincentsarago
Copy link
Contributor Author

In general, hypercorn with the flag was had the lowest rate of increase, but only marginally.

👍 no need of hypercorn then!

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.

2 participants