I am working with google cloud functions. I am coming from a serverbased applications so I don't know much about the serverless world.
I have a scenario where i have two kinds in google datastore ie iot_kind and config_kind. One kind has config which is like a lookup table and other kind has normal payload values.
I am publishing the data from a IoT device into the pubsub topic and getting that data into the cloud functions.
eg IoT payload is
{"id":"213213", 'price': 20, 'name':"some_name"}
then I am querying the config KIND and extracting some data from it like price multiplier
select *
from config_kind
where id = "213213" #lets say output is 2
Then I am multiplying the price*2 and saving it to IoT_kind eg value=40
Now in this way I have to make a read every time I get a data into the cloud function which is i think quite expensive and also a bit processing.
Is there any better way of doing it? Like I save latest config somewhere and then whenever payload comes it sees the config and do the processing according to the config and then save it to a database?
And can I do something like make a cloud function and store the latest value there and then call this cloud function from another cloud function to get the values out of it? would it be less expensive or expensive ? Thanks a lot!
Cloud Function is a serverless and stateless service. When an instance is created, it lived for a while and it has been stopped. No disk are mount, all work in memory. That means that you can't save any value in it persistently.
Anyway, you have 3 solutions to reduce the number of config read into datastore
Is that make sense for you?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.