Slow REST API query dispatch

Some of our REST API queries are so slow, they reach Retool's 120 second timeout. However, the timeout occurs before Retool even makes the HTTP request to our web server. There is similar behavior reported here, and we have the same behavior where the resource accessed outside Retool does not express the slowness reported by Retool (i.e., when we curl our resource, it responds within an acceptable timeframe).

Debugging this problem, we found the slow dispatch correlates to the size of the request payload. We drew this conclusion by simultaneously watching our web server's router logs and the timeline in the debug console on the Retool client. They're approximations given Retool's debugger doesn't provide the kind of fine-grained insight we'd need for exactness. In all cases, these are JSON blobs encoding an array of JS objects. We sliced that array for each test so the data is the same shape, etc. but less of it. Slicing the data does not work for this application, to be clear - more below - and was done to test the issue. Here's some numbers:

18KB payload
8 second request dispatch

89KB payload
52 second request dispatch

159KB payload
111 second request dispatch

222KB payload <- largest payload we have
238 second request dispatch <- unsure on this given Retool retries when outside 120 second timeout

Now, why are these payloads so big? In brief, the API diffs the data provided against another state of the data it holds. It our belief we do not have an arbitrarily simple way of paring down the request size for our Retool application. Instead, we would like to better understand if there's some bug here or if there's an undocumented limit to request payloads.

Any thoughts?

1 Like

I am also working on this issue, and it's a bit surprising to see how long retool is taking to handle the request. On a 111 seconds request, it is spending 5 of those seconds on our server. We don't see the request until about 50 seconds after hitting the submit button in retool. The response is then written in 5 seconds, and it doesn't return in retool UI until 50 seconds later. This means that it is spending ~ 106 seconds being handled by retool's servers. This is obviously such an impactful issue that we are having to reconsider how to build with retool, yikes!

A temporary solution we've found is to not use the JSON option for a REST API request body and instead encode using JSON.stringify and the Raw option. Your resource may end up looking configured like this:

1 Like

Hi @dlk and @joeatxy,

Do your RestAPI resources use customAuth by any chance? We've recently discovered a performance bug with customAuth resources where defined variables + complex body requests may be causing the slowness you're seeing.

Oddly enough, we are using the oauth2 flow. When recreating oauth2 with customAuth, our issues goes away.