-
Notifications
You must be signed in to change notification settings - Fork 175
Issue with concurrent requests on AWS Fargate #22
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
Comments
Concurrency and asynchronous call is natively supportted by FastAPI, I did a quick test with 2 concurrency requests (with long response) and I can see both are streaming in parallel, I didn't test via code though. You can probably try below:
|
Hi @daixba, I forgot to mention that I'm not streaming the response But without streaming, the API is waiting for each request to finish before being able to handle other requests
I agree; This is why I think the problem with boto3 |
所以这个能解决吗,我的大并发请求一遇到非流式就没办法 |
This is not a problem with Fargate's capacity, it's due to the fact that we're using block code in the loop. Let me explain this: in fastapi, an async handler runs in a loop, a sync handler is wrapped to a thread and then runs in a loop Therefore, when there is blocking code in an async handler, it will block the whole server. Usually, we all understand the following code: import time
import asyncio
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def root():
await asyncio.sleep(1000) # Won't block
time.sleep(1000) # Will block
return {"message": "Hello World"} Yet import time
import asyncio
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def root():
time.sleep(1000) # Won't block!
return {"message": "Hello World"} |
@QingyeSC If you're in a hurry, you can build the image yourself from #23. If you want selfhost, I forked my version https://github.com/Wh1isper/bedway |
Also ran into this issue, fixed it by subclassing the Hopefully pull #23 gets approved though 👍 |
Sorry, it's been a long time to address this issue. Now the performance is improved based on my test. Now this project make async call to converse api. We don't need to use aioboto3 here. Check the 0ead770 for more details Simply redeploy or update the container image to have a try! Please let me know if any feedbacks. |
Describe the Bug
I am encountering an issue where concurrent requests are being processed sequentially rather than simultaneously when deployed on AWS Fargate.
I suspect the problem is that boto3 runs synchronously, and its calls are blocking.
API Details
To Reproduce
Steps to reproduce the behavior:
Expected Behavior
I expected that when sending multiple concurrent requests to the API, all requests would be handled simultaneously or at least as many as the server can handle
The text was updated successfully, but these errors were encountered: