REST API command response time varies?

I notice one thing about REST API command response time:

When I power the board on and send the first REST API command from PC (using cURL) to Arudino Yun board, the response time is always pretty long (maybe 3~4 seconds). After that, the command’s response is pretty fast (< 1 second).

If I leave the board on without do anything to it for a period of time (I don’t know how long), the first REST API command response will be long again. After that, the command’s response is fast.

Did anybody notice it? I am wondering if there is a timeout for REST API command. If yes, how to disable it or make it infinite longer?

Thanks,

Nick

Your code?

I just ran the BridgeDemo and noticed it.

I have NOT noticed variability in running REST API commands. But I have noticed an initial delay any time I access the Yun using the xxx.local name as opposed to an IP address. This is the time that it takes your computer’s browser to look up the xxx.local name, find out it isn’t in it’s name cache, and then go out over the network looking for the node with that name. Once it finds the address for the node, it adds it to the local cache, and subsequent accesses are faster - at least until it expires from your computer’s cache from non-use.

I just tried an experiment. I loaded the Bridge Example, enabled the Developer/Network debugging panel in Firefox, and tried the following accesses in order:

  • Using IP address: response time was 344 ms
  • Using yun3.local address: response time was 2,781 ms, with 2,453 ms spent looking up the address, and 328 ms processing the request
  • Using yun3.local address: response time was 281 ms
  • Using yun3.local address: response time was 312 ms

So there is some variability in the actual response times, but the difference is small enough to not be noticed by a casual observer. The noticeable delay was caused by looking up the node address, but this didn’t happen when using an IP address.

If you want consistent REST API response times, you don’t need to do anything to the Yun. You need to do one of:

  • Use the IP address to access it
  • Define a manual host entry in your computer so it can always translate the node name locally and not have to go over the network and search for it that first time.
  • Live with the initial delay while your computer searches for the node.

The downside to option 2 (locally defining the name) is if the Yun has a dynamic IP address: if it changes, your locally defined static name will no longer point to the correct node.

Thanks for your reply, ShapeShifter.

I did the same test as you did by using Firefox (Enable Developer | Network). The link I used is:

http://192.168.2.105/arduino/digital/13

So, no xxx.local.

My results:

The first time response time after power on: 2387ms, after that: 392ms.

I waited for long time and tried again, one time I got 4862ms, most time I got around 400ms.

My conclusion is: the response time varies. We are ok if it's less than 1 second. More than 2 seconds is definitely too long.

nickyang:
I notice one thing about REST API command response time:

::::SNIP::::

Did anybody notice it? I am wondering if there is a timeout for REST API command. If yes, how to disable it or make it infinite longer?

Thanks,

Nick

If you are using Wifi, the likely cause is a noisy wifi environment. If you have an Android Smartphone, then get Wifi Analyzer from FarProc. You will likely see lots of your neighbors on the same channel as you.

Then you'll also see this has nothing to do with the REST API.

Solution: set your Yun to work on a different channel. You've got more than 12 to choose from.

Best of Luck
Jesse