FullFact / health-misinfo-shared

Raphael health misinformation project, shared by Full Fact and Google
MIT License
0 stars 0 forks source link

Simultaneous submissions cause slow reponses #151

Open ff-dh opened 6 days ago

ff-dh commented 6 days ago

If multiple URLs are submitted at roughly the same time, the later submissions take longer to render while the load is increased.

Example (with one worker):

I thought the database might've been blocking these but after some db changes for throughput and reduced blocking this particular issue wasn't resolved. It could be a stream_template upper limit but the docs don't speak on anything like that.

andylolz commented 6 days ago

Yes, this probably does relate to using stream_template.

We currently run gunicorn with 2 synchronous workers: https://github.com/FullFact/health-misinfo-shared/blob/ae033e995f323e5d5ed3207e350c0980b593d255/Dockerfile#L21

We could up the number of workers, and/or make them async.

andylolz commented 6 days ago

It’s probably worth writing down somewhere: stream_template is a massive hack here, to avoid running the LLM in background tasks in celery. It would be much better to use background tasks here, but also a load of faff that is probably not worth it for an MVP.