Speed of api calls?

I am trying to develop a project where I need near realtime analog readings from 5 sensors off of 4 different spark cores, upwards of 20 requests/sec. Is this possible? Am I better off limiting the spark cores to a LAN with the computer?


Technically you can do this through the Cloud but at some point we will probably put in place rate limiting to make sure we don’t accidentally get DDoSed. I would recommend doing something like this through direct TCP connections, if you’re on the same network.

1 Like

You could also do something like this with the local cloud. We’ve also been talking about a streaming / socket interface through the cloud to your core, but you’ll get maximum bandwidth if you can stay within your LAN. :smile:

Realtime request throughput to anywhere on the internet will depend on what kind of latency you experience from your connection and routing. If you’ve got fiber then maybe!


I’m wondering, is it more important that you get 20 requests per second, or that you get 20 variable readings per second, or that you need all readings at the same time?

4 cores * 5 sensors (each?) * 20/sec = 400 readings (per second?)

If you kept each value in a single packet, maybe 16-32 bytes per message… If you combined payloads and did each reading per core simultaneously (say 2 bytes each… then maybe only 80 packets a second total of 32 bytes?)

If you were only sending, and not triggering each reading with an API call… I’m very badly guessing that would only be something like 3-13KB traffic if you go one way only streaming. Maybe the best bet would be to establish an end-to-end UDP tunnel facilitated by the cloud, but then send this streaming data directly to your client?

How would you go about creating a TCP connection with this kind of responsiveness/low latency?

I’m hoping to use my Spark as a controller for a game (within Unity), and the lag for an API call with an eventlistener seems to be too slow for my purposes but maybe I’m doing something wrong?


Hi @filmic

Sorry about my slow response! There’s a great example of a remote control TCP server here:

It uses a protocol that’s supported by both Johnny Five https://github.com/rwaldron/spark-io , and Cylon.js http://cylonjs.com/documentation/examples/spark/annotated/blink/ . You can write code to run on your machine in a language like JavaScript, and just control your Core locally quickly.

Happy Hacking! :smile:


i’d say if response times are really important to you then forget the cloud and write a TCPServer.

i’ve just written a pseudo telnet server that you poke and it gives you sensor readings, in 60-odd lines of code, including disabling the cloud so it only accepts connections from the lan, no wan latency to deal with, still works without internet connection.