For each new request to events view, a new instance of streamed_events coroutine will be created, executed separately in the event loop. This means that if there are two requests from different users, two separate instances of the coroutine will be created, operating independently from each other. Each open connection will consume a portion of server resources. If you have 1000 users visiting your website, that will result in 1000 instances of the streamed_events coroutine, each executed separately in the event loop.
I do not believe this is good practice. In my opinion, it is better to use django-channels for persistent connections, and StreamingHttpResponse for long-lived connections.
For each new request to
eventsview, a new instance ofstreamed_eventscoroutine will be created, executed separately in the event loop. This means that if there are two requests from different users, two separate instances of the coroutine will be created, operating independently from each other. Each open connection will consume a portion of server resources. If you have 1000 users visiting your website, that will result in 1000 instances of thestreamed_eventscoroutine, each executed separately in the event loop.I do not believe this is good practice. In my opinion, it is better to use
django-channelsfor persistent connections, and StreamingHttpResponse for long-lived connections.