I have a new durable function to replace a long running webjob and it works well and is faster than the former webjob however I have an issue with parallelism.
I understand all activities go onto a central work item Q, what this means is that items get processed in order, the issue I have is if there are 10 items in the backlog from user A and user B submits something then user B has to wait till all the data from user A has finished processing.
With the current webjobs we can autoscale and a new webjob will pickup the data for user B and process it in parallel to the existing processing.
Am I right in thinking the only way round this is to publish 2 copies of my function, one for each user/client to ensure one user isn't affected by another users backlog of data?
I tried chunking things onto the workitem Q so no single task put more than X items on the Q so that in theory there would be some sharing of the resource but that just slows things down as there is then less on the workitem Q and so the consumption plan autoscaling scales up very slowly due to the smaller volume on the workitem Q.
UPDATE
I should have been clearer about why I see the issue, the approx. Durable Function process is as follows:
- Split file into pages
- Fan Out putting an activity on the Q for each page
- Fan In
- Fan out putting another activity on the Q for each page (requires data from previous fan out to run)
- Fan In
- Insert information for pages into the DB in a single transaction
- Mark the file as processed in the DB
So User A loads file 1 that has 1000 pages, then User B loads a file with 100 pages.
While I appreciate it processes the activity Q in parallel it does still pull things off the Q in order (I assume) so if there are 1000 items on the Q for User A's file when User B's file starts, the initial 100 page activities then get put on the activity Q after the 1000 and hence are "blocked" by them. Then by the time the 100 initial page activities are done there is a good chance the next fan out for the 1000 page document will have added more items to the activity Q again further blocking the progress of the 100 page document.
My issue is User A and B may be 2 different clients who would not expect their work to be blocked by another client's processing, hence my comment about having duplicate instances of the Durable Function and brokering messages between the multiple instances
Does that make a bit more sense?