Anybody have a good examples of using the parallel...
# cfml-general
m
Anybody have a good examples of using the parallel features or multi-threading <cfhttp> requests? We are doing a ton of AWS REST API calls across AWS regions. 1. We loop in serial the regions (usually 4 regions) 2. Then process the results 3. Then usually build a query/structure of the combined region results. If I could call each region AWS API in parallel then combine the results that would give me 3x-4x speed improvement.
s
We've used cbstreams for this
f
Using
arrayEach
is also quite handy for this it has a parallel and maxThreads support in lucee and CF2021: https://cfdocs.org/arrayeach
b
I was JUST messing around with a fuseless lambda function a couple days ago that was doing pretty much the exact same thing that @foundeo posted above… an array of urls and expectations that were looped over with array.each() and http requests made and verified for each of them. Super simple… right? It worked fine until I enabled parallel and gave it more than 1 maxthreads. When I did, the http var was randomly undefined in the lambda function but it worked fine outside of it. I haven't been back to debug it yet since it was mostly just a simple idea that popped in my head for testing out fuseless lambda functions.
I did not var my cfhttp result variable. Once i did, the random failures inside the array each went away