iPlantCollaborativeOpenSource/troposphere — pull request #20 by jchansen (2014-06-06 18:03:59+00:00)
Title: instance/volume stores only fetch resources once

Fixed self-inflicted DDOS bug I accidentally coded into the React application. What should have been 12 ajax calls became 2^12, each call being repeated the number of times it’s bit represented. The first call happened once, the next twice, then 4, 8, 16, 32, 64, 128, 256, 512, 1024 and the last ajax call was repeated 2048 times). So what should have been 12 API requests became 4096 in less than 2 seconds.

The problem was that the stores that fetch the volumes and instances for a promise were lazy loading, meaning they never sent the request until someone actually needed it. By each time a request came back, React would re-render the page, and the components requested data again, which triggered another response. So everyone requested data again as soon as one response came back.

The solution was to implement a dictionary that keeps track of which requests for project instances and volumes are already inflight to make sure a request is never sent twice. This resolved the problem beautifully. Now requests are sent exactly once, and the page feels properly responsive again.