I have tried to add 1k api in a demo, the docs page( 127.0.0.1:8000/docs ) a bit slow, and if there is a multiple members team to do the project, they want see the specific module of api, is it better to separate the api by modules(or APIRouter )?
There won't be any difference even if you separate the docs in a different router as long as it runs in the same process. Does it block your app? It shouldn't because it's running as a coroutine, see
as @ycd said, it's running as a coroutine and shouldn't block your app.
if you want to separate docs of routes, you can use sub-app instead of APIRouter (I'm not sure it's a good idea)
from fastapi import FastAPI
from uvicorn import run
app = FastAPI()
sub_app = FastAPI()
@app.get("/index")
async def index():
pass
@sub_app.get("/index")
async def sub_index():
pass
app.mount(path="/sub", app=sub_app)
if __name__ == '__main__':
run(app)
/docs
/sub/docs
I don't think he doesn't want to create a brand new OpenAPI by creating a sub-application.
Since it will not include wanted docs.
If you have 1000 endpoints in a single application, I think that's a bit unrealistic? You should probably be breaking it down into standalone applications at that point. The most I've seen in production is 450 on a mainframe 馃槄
If you have 1000 endpoints in a single application, I think that's a bit unrealistic? You should probably be breaking it down into standalone applications at that point. The most I've seen in production is 450 on a mainframe 馃槄
馃槄馃槄
I agree with breaking endpoints down to standalone applications, maybe by modules, as I can deploy them to different vps to improve the performance.
You can still combine them into a single fastapi instance either way too.
Regardless, if your question is answered, please feel free to close this issue.