Webhook vs calling particle variable

Hello all,

I’m working on a web app that will be logging data from multiple particle devices. Right now I have it set up so each one is sending out a webhook about every four seconds. My app then receives it and logs it to the database. I’m wondering if it would be more efficient to use particle variables and call them from my web app from the database of devices.

What do you guys think?
Thanks in advance,

This depends on what you mean by “more efficient”, and on the nature of your data. If you only want to get updates when the data changes, then having that initiated by the device (via web hook when there is a change to the data) would result in fewer data sends. Are you using an Electron where a lesser number of transmissions would be important?

1 Like

By more efficient I mean use less processing power on the server side.

The data logging every 4 seconds regardless of changes. Some applications will be using the electron but I’m not concerned about the data cost of sending it.

I’m leaning towards calling variables from the server instead of using webhooks, it would give me more control on the server side.

I prefer to use the Server-Sent Events stream. When you use SSE, your server make a single outbound connection to the Particle cloud and keeps it open. The cloud then sends the events that match your subscription pattern through the connection as soon as they occur. It uses TLS/SSL for the connection, but you don’t have to have your own server certificate and you only incur the TLS overhead once per connection, rather than once per event for webhooks. Also, it works from behind firewalls and NAT and with dynamic IP addresses.

I will look into that, it seems to fit my needs exactly.

Thank you for taking the time to respond!