Create alarm triggers
Hi,
I have a use case where I would like to create triggers using the alarm package - recurring schedule for an action.
I also would then have a use case where I can delete these alarm triggers from the client.
I looked through the code and can't see this is possible currently - we can only invoke triggers and actions, not create them?
Is this something you might add in the near future?
Thanks Scott
The SDK doesn't handle creation or deletion of entities like triggers right now, though this isn't the first time I've heard of this use case.
You could call OpenWhisk directly? We have [swagger docs] (http://openwhisk.ng.bluemix.net/api/v1/docs/index.html)
I'm guessing that you just want to start and stop an action from a mobile client?
Thanks Paul, thought that might be the case and did consider a direct call.
I'm new to OpenWhisk (which I'm loving) so maybe my lack of knowledge needs some more understanding.
Basically, let's suppose I have a million subscribers to my weather app and they each want the weather checked for their saved location on a periodic basis e.g. every hour. If the weather is looking bad then we'll send them a push notification.
So with OpenWhisk I could do:
ALARM Trigger (every hour) -> Check Weather ACTION (for location) -> Send Push ACTION
I was thinking (naively) that each alarm trigger would have the inputs for the weather action i.e. the user's saved location.
And we'd create these alarm triggers from the App.
Is there a better of way of doing this using a server less approach?
Thanks Scott
@meyumeapps You should be able to use the trigger_payload parameter when setting up the alarm for this purpose. Whatever you set as the trigger_payload will be passed to the triggered action as separate parameters.
There is an example here: https://github.com/openwhisk/openwhisk/blob/c92bdbdd97aaeb80274f9d8a15fe6fa5478d951a/docs/packages.md#creating-and-using-trigger-feeds
Thanks @bjustin-ibm
Is it a crazy idea if we are talking about potentially 500,000 alarms?
The action would be generic, taking the parameters as you suggested, but the alarm needs to be specific to each user.
Another possible architecture is to have a single alarm that fires every hour. This triggers an action that retrieves (say from a DB) the list of users (and their locations) that want weather alerts. This action then loops over those users to fire separate actions to get the weather and, if necessary, send notifications.
In this way, you register a user for alerts by adding an entry to your DB, rather than creating a separate alarm just for them.
This was my first thought but it seemed to be potentially expensive with the loop invoking all those actions?
Another idea I'm mulling is have the users in the database with some field that a single alarm could update for all users - assume this would be pretty fast.
Off the back of the field change would then be the check the weather action, passing the details from the database for the user?
This was my first thought but it seemed to be potentially expensive with the loop invoking all those actions?
Expensive in what way? The DB retrieval should be fast, and if you make non-blocking invokes (not waiting for the result) asynchronously, then the triggered action should complete in a reasonable time, basically making 500k almost-instantaneous invoke calls. By invoking separate actions to check weather and send notifications, you are really harnessing the power of OpenWhisk by running all those actions in parallel - within the system limits, of course 😉
Cool, wasn't sure if the action invocation was quick enough.
non-blocking invokes would certainly do the trick 👍
will be experimenting 😄 loving the whole idea of OpenWhisk!
Good luck. I'm going to dig into the system limits in more detail, and will report back if I find anything that would significantly limit this approach.
Awesome, thanks @bjustin-ibm 👍
@meyumeapps So I did some digging around and found that if you follow my suggestion above you will very quickly hit your action invocation limit which (currently on Bluemix) is 5000/minute for invocations, and 1000 concurrently running actions.
I think a better solution would be to have 1 alarm that fires every hour. It triggers a single action which fetches all your users, iterates over them, and does the weather check/notifications all in the same action.
By the way, you can join us on Slack for more lively conversations: http://slack.openwhisk.org/
😉
@bjustin-ibm thanks for digging out those numbers ... and I've joined the Slack channel 😄
Closing issue as project is being archived.