Best Practice to Make HTTP Request in FastAPI Application

preview_player
Показать описание
In this video, you'll learn how to make highly available FastAPI endpoints using asynchronous HTTP requests.

We'll cover:

Why standard requests library blocks the event loop
Introducing httpx for asynchronous requests in FastAPI
3 Best Practices:
Creating an AsyncClient with context manager (basic approach)
Using a dependency for cleaner code
Application-wide AsyncClient for efficiency (with trade-offs)

Optimize your FastAPI application for maximum responsiveness!

Hit that subscribe button for more FastAPI tips and tricks!

Search Queries:
fastapi asynchronous http requests
improve fastapi performance
fastapi high availability
fastapi async client
fastapi requests library blocking event loop
httpx in fastapi
fastapi async client best practices
fastapi dependency for async client
fastapi application state async client

#fastapi
#python
#webdev
#backend
#api
#programming
#fastapi
#python
#webdev
#backend
#api
#programming
Рекомендации по теме
Комментарии
Автор

Great video. Short and to the point. Subscribed.

nitishvirtual
Автор

thx bro! so useful material, keep going

opium
Автор

Hello! Thank you for the video! Could you tell me how to measure the request (in your video it’s about 300ms)? Using a decorator? If so, I tried it, but it didn’t help, because time information is simply not displayed in the logs. I would like this information to be absorbed and for me to see a clear difference in the use of reguess and nttpx. I can’t leave a comment with a link to pastebin because youtube deletes such comments

godgiven
Автор

dont we have to enable the 68 no line? "app = Fastapi(lifespan=lifespan)" ?

pritamsarkar
Автор

this is not about FastApi, its about sync functions and async functions so just dont use sync functions in async functions if sync one is takes a lot of time.

oktay