Python FastAPI - websocket delay

I am working on a little ChatGPT clone like project using langchain and stuff.

I actually have a request. Maybe you could help me with it or point me in the right direction…?

I have an endpoint that lets user connect to FastAPI sockets.

The problem is… when I send some data from my server to client on websocket, its not received in real time. Lets say, I send numbers from 0 to 10 to the socket in a for loop and sleep for 2 seconds and then send the next data.
On localhost, the client would recieve data each number with a delay of 2 seconds, which is perfect.

But, on the deployed Koyeb app, client receives 10 numbers at once after 20 seconds. :sob::sob:

I am all out of ideas now.

Hi @zShan,

We checked your deployment but did not find any issues on our side. I would like to ask you to share an open-source project that can reproduce the problem.

You can set up a basic project using this example: