We are trying to link data from a lidar to our serverless function running on OpenFaas subset Faasd. We are using the trigger to invoke this function when an object is within a certain distance. So we have the lidar publish data to the topic when an object is within a certain distance. Then we have the OpenFaas mqtt-connector to invoke the serverless function using triggers. The issue is that the mqtt-connector is being flooded by the publisher and is backed up within a second of an object being in the range.
We have tried changing the QOS (quality of service) all the way to 0, but even this change had no visible difference in the connector being backed up so quickly. We tried looking at ways to decrease the lidar polling frequency but didn't find much (We are using the LD-19 Lidar). So Lastly we are trying to find a way to increase the CPU Utilization of the connector in hopes that this can be sufficient, however we have only found ways to limit CPU Utilization.
This is our handler of the function being invoked:
import json
import paho.mqtt.client as mqtt
TOPIC = 'controller'
PORT = 1883
BROKER = "172.17.0.1" #mosquitto broker IP
def handle(event):
message = event.decode()
print("Received message: {}".format(message))
msg = 'stop'
client = mqtt.Client()
client.connect(BROKER, PORT, 60)
client.publish(TOPIC, msg)
return None