A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/issues/347 below:

1s -> 200ms response time fix · Issue #347 · stac-utils/stac-fastapi-elasticsearch-opensearch · GitHub

When profiling the application I have noticed that most of the time is spent on running jsonable encoder from FastAPI. This is a little known fact about FastAPI, but it's much more efficient for methods to return Response instances rather than Python objects which need to be processed through jsonable encoder (to handle nested Pydantic instances etc.). Having applied the fix below, we have noticed a significant performance improvement, especially on large search responses, and I would like to share this "fix" with the upstream:

https://gist.github.com/Zaczero/00f3a2679ebc0a25eb938ed82bc63553

It basically wraps all compatible endpoints, to return Response instances directly (thus skipping the jsonable encoder logic). Cons: this breaks Pydantic support for response objects but it could be worked around by improving the wrapper logic but since it's not used here (afaik), it doesn't really matter.

jonhealy1, MathewNWSH, pedro-cf and vprivat-adsrhysrevans3 and pedro-cfemmanuelmathot and pedro-cf


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4