Azure / Azure-Functions

1.1k stars 189 forks source link

Python warmupTrigger doesn't run on all workers on a scaled-out instance, and requests are sent to worker processes that aren't warm yet #2462

Open empowerNate opened 3 months ago

empowerNate commented 3 months ago

I found this happening on the Elastic Premium plan but assume the same problem happens on the Dedicated plan. I implemented a warmupTrigger with the V2 programming model, and it works on some of the worker processes within a scaled-out instance. However, it doesn't get called on all the workers, and some requests are sent to workers before they are fully warmed up. On an EP3 instance, it only got called on 2 of 4 workers, for example.

Additionally, I tried adding a long time.sleep to the warmupFunction of 10 * n_workers. However, the same worker where the warmupTrigger runs will start receiving requests before the warmupTrigger has finished, weirdly. I was hoping this could be a hack to make the warmupTrigger work despite the bug.