SmartApp Latency


(Jody) #1

Are external actions being throttled? I have a very simple rest endpoint app that allows me to turn on and dim some lights. When doing a simple get request for a single light to turn on or off it takes about 6 seconds


(Convinced ST will never be unbroken…) #2

That is not too outside the norm. I usually see 1 to 3, but far too often then should be I can see 10 or more. I have no idea what they’re doing that require these delays. It is exasperating how long the mobile app takes to draw a screen (like there is a separate handshake for each and every device).

And frankly… it hasn’t been getting any better (since June anyways).


(Jody) #3

@scottinpollock You are right that can it take longer. 6 seconds is the amount of time that it takes when it is working “normally”. I have wracked my brain trying to figure this out. All of the requests on my webserver are in the sub millisecond range until it gets to the ST request. And this is with a single device. When I fetched the full list of devices it took 45 seconds before it returned the data. Any tips on how to optimize my smartapp code would be great. I was hoping that I had done something inefficiently and this was a solvable problem.


(Geko) #4

There can be many reasons why a complex cloud service like SmartThings becomes sluggish. In my past experience, we were running a cloud service for industrial monitoring and ran into similar issues when databases grew sufficiently large. Our dashboard would take 10-15 seconds to load and customers were not happy to say the least. Like ST, it was also a Java backend and it required a massive database and framework redesign to get performance back to acceptable levels.


(Convinced ST will never be unbroken…) #5

Not knowing exactly what you’re doing it is hard to make a suggestion. I would first try getting those endpoints directly from a browser an see how long they take to actuate. If it is appreciably shorter than what your seeing from your app then something may be amiss with it.


(Jody) #6

It is a relatively simple webpage. It makes a javascript request to an api endpoint when the user clicks a toggle. My app transactions are very fast. Usually 0.1 or 0.2 ms. Then it hits the smartthings server and takes 5+ seconds.

Started PATCH "/things/11" for 192.168.1.211 at 2014-10-25 12:50:05 -0500
Processing by ThingsController#update as JS
  Parameters: {"utf8"=>"âś“", "thing"=>{"switch_value"=>"on", "dimmer_value"=>"100"}, "id"=>"11"}
  User Load (0.2ms)  SELECT  `users`.* FROM `users`  WHERE `users`.`id` = 1  ORDER BY `users`.`id` ASC LIMIT 1
  User Load (0.1ms)  SELECT  `users`.* FROM `users`  WHERE `users`.`id` = 1 LIMIT 1
  Thing Load (0.1ms)  SELECT  `things`.* FROM `things`  WHERE `things`.`user_id` = 1 AND `things`.`id` = 11 LIMIT 1
  Service Load (0.1ms)  SELECT  `services`.* FROM `services`  WHERE `services`.`user_id` = 1 AND `services`.`provider` = 'smartthings' LIMIT 1
http://graph.api.smartthings.com/api/smartapps/installations/001834a7-316d-4e64-ad38-b577ee4f7f3f/switches/XXXXXXXXXXXX/level/100?access_token=XXXXXXXXXXXXXXX
  Rendered things/update.js.erb (0.0ms)
Completed 200 OK in 5831ms (Views: 6.9ms | ActiveRecord: 0.5ms)

(Convinced ST will never be unbroken…) #7

Like I said, how long does it take the light to actuate when you call that endpoint from a browser?


(Jody) #8

5-10 seconds on average for the light to change states. It’s right in line with the last time at the bottom of my paste. in that instance it took 5 seconds.


(Convinced ST will never be unbroken…) #9

Well that is not what I am seeing here ATM. Have you tried a traceRoute from your end?


(Jody) #10

Network latency is very low. Internet latency is 20ms for typical requests. I asked if they were throttling because my ST mobile app is not this slow.


(Convinced ST will never be unbroken…) #11

Well then I got nuthin’ (c;

Try emailing support.


(Jody) #12

@scottinpollock I think the solution is to collect requests and do them in batches. With single requests taking 2-5 seconds it’s currently impossible to have a truly dynamic dashboard. @urman you have any sage wisdom on the best way to interact with endpoints?