2 years back, I was tasked to quickly build a system for an Health Club that was hit by the Covid pandemic. The system was built within a week & I used what technology I was comfortable with and deployed the system.
The requirements were simple - A member subscribes to a program and he gets regular, timely notifications via FCM. The signup date of the member is rolling, hence it has to follow the n+number of days & time schedule logic.
I built this using simple php with nodejs handling the scheduler. The scheduler runs every minute, checks the mariadb database and runs a loop to send these notifications. This is running correctly at the moment. Having said this, I know this is not the optimal way of doing a solution like this.
I would compare this to the "Autoresponders" we set in any mailing system. Once a person joins, we can schedule Autoresponders - the sending and delivery is managed by the mailing provider.
I wanted to understand if I can use Topics or Realtime / Firebase database to achieve this?
I know it's a super generic question, but if someone can point me in the right direction, I would appreciate it.
Regards,
Mihir.
PS: I am insisting on Firebase because my apps are already integrated with it and would not require much of work to run these changes.
Related
I have an app (Flutter using Android Studio) I am on the final stages of and I would, in an ideal world, want to include a feature to notify the user via a mobile notification if a date held against their UID is equal to today (let's use a birthday as an example).
I've spent 2 days looking in to all options, and was very close to using Cloud Functions to store a once a day cron function to notify all users, using FCM, based on the condition above - but something stopped me.
I'm very new to app building. So new that I can not confidently say I do not have a bug or infinity loop somewhere to rack up a huge bill upgrading to the Blaze plan - which without I can not use functions (I literally had credit card in hand on the upgrade page and stopped).
After 3 months of app building I feel I'm between a rock and a hard place. I don't want to launch without auto-notifications (as it's pretty key to the slickness of the app) BUT I can not risk a skies the limit, no-cap, no protection Blaze account if the worst was to happen.
It seems crazy for the effort to be put in to Firebase by Google, which to be fair helps new developers code and launch apps, to put them unnecessarily at risk or cost without automated protection. At least the Flame plan capped your spend - but I can see this is a real concern to new app developers such as myself (I've developed for the web for years). I just can't risk Blaze. I am more than happy to pay for things I use, but not to put myself at risk. Anyway I digress...
Without upgrading to Blaze - is there anyway a newbie such as myself, who is still learning the ropes, I can use FCM, and a cron job, to every day check the Cloud Firestore for users where a certain condition applies (i.e. UID date = today) - and notify them through a notification to their mobile device?
I would recommend using Google Cloud Functions and Cloud Scheduler to accomplish this.
It is worth noting that Firebase + Google Cloud provide an amount of free usage per month. It is quite likely that you could keep your usage under the limits, at least initially. Also, if you are a new Google Cloud customer, there may currently be a trial offer you can redeem for things not covered in the free tier.
https://cloud.google.com/free
https://firebase.google.com/pricing
https://cloud.google.com/scheduler
I am building a web app with the following stack:
UI - React
Backend framework - NestJS
Infrastructure - Google Firestore document DB, services deployed in Heroku
I need to calculate finance portfolio metrics on a daily basis for all users and display them when the user logs in. I am in a bit of a dilemma what approach to take and I have several ideas, so I hope you can give me some guidance.
Scheduled microservice
I can build and schedule a microservice in Python (the finance framework is in Python) that will run every day and calculate the needed metrics for the users and update the database. Seems straightforward but it might consume a lot of compute resources, especially when the user base grows large.
Cloud Functions
Google Firestore supports cloud functions that can trigger on specific events. I can leverage that and run the calculation microservice when the data is requested - that way I will calculate the information only on-demand. The downside is that if the data has not been requested for a long time, I will have to calculate the metrics for a larger period of time and this might take a while.
P.S. Just saw that there are also scheduled cloud functions - possible implementation might check if the data is calculated today (user has logged in at least once) and if not, calculate it.
I will be happy to discuss any other options that might be available.
I have so far been very impressed with the firebase platform for hosting a client-side single page app and for data storage. However, I have one component that I don't know where to host...
I want to have a background process that aperiodically updates the database. The nature of when an update is needed is based on an external source and, although the general timeframe of when updates are available is known, the exact timing is not. My thinking was to have a background task running that has some smarts to determine when an update is needed, and then trigger an update at that time.
I don't know where I would host something like this. I considered running it in a loop in a firebase function, but due to pricing model being based on time, that would get very expensive, and functions are not suited for daemon-type processes. The actual "database update" would be suitable for a function, but not the triggering logic. Also, I have seen functions-cron which does offload the triggering logic, but since my updates are not truly periodic, it doesn't seem exactly appropriate. I haven't looked too much into AppEngine and how that relates to the firebase platform...so basically my question:
What are the options for "reasonably-priced" hosting an always-running background task?
Google App Engine - Standard is something you want to look at more. It is reasonably priced since what you are doing will likely fit into GAE-Std's free daily quota. In GAE-Std, you create a scheduled cron job: GAE will call you task as if it was an incoming web request.
See Firebase doc for integrating with GAE
See GAE doc for cron jobs
What costs are involved with developing and/or releasing a Google Assistant App?
eg: Can you develop an app using DialogFlow and a backend (say Firebase) without having to pay while you learn?
First of all - you don't need to use Dialogflow or Firebase to develop your action. Both are suggested, but neither are required. You can use any NLP you want, or none at all if you use the Actions SDK (but you want an NLP). You can use any backend at all, including running it off your local machine and tunneling to it via ngrok, but you don't want to do that for production.
But, during development (and even during a light deployment before your action becomes massively popular and a stand-out hit), you have lots of solutions that will be free.
Dialogflow is free for use with the Google Assistant. Period. There is an Enterprise edition which offers additional services and support for a cost, but you won't need them. There are restrictions, but you won't bump into them until you hit 3 requests per second - which you shouldn't during development.
Firebase's free tier (the Spark Plan) is good for very simple experimentation, but once you start doing network calls to outside Google's network (if you are trying to call the network API for other services), you will be blocked. No worries! The "Blaze Plan" paid tier does require a way to bill you, but they don't start billing you until you get quite a bit of usage: 2 million function calls / month and similarly scaled usage of CPU, memory, and network. So even the "Blaze Plan" will be free during development (and for basic usage).
Updated, December 2020
Things have changed a bit since the original answer was posted, but the underlying basics remain true - there is no charge to develop for Actions on Google.
Dialogflow now has an "Essentials" edition and a more advanced "CX" edition. While you can still use both to build Actions, they're not really intended for this purpose anymore.
Instead, Google has included the Actions Builder into the Actions Console to handle the NLP work. The Actions SDK works with this, but can also just pass along all the STT information to your webhook. Both are also free to use.
Dialogflow is for free if you don't use it as an enterprise:
https://dialogflow.com/pricing/
And Firebase free tier should be enough if you not using firebase
already for other projects. enter link description here
But of course you have to calculate your own time so in case of the
spent time probably not.
For everything else yes it is, as long as you not using it already somewhere. You can for development also host your server local and use an ngrok tunnel as sever address for Dialogflow.
As an addition to shortQuestion's answer:
The free plan in Firebase should be enough if you're just using it for learning and developing apps for personal use. If you want to go a bit further you'll need to upgrade the plan.
You can sign up with a free trial for actions on Google to get 300$ of credits during a 12 month period which would be more than enough to do anything you want.
The costs of Firebase/Actions on Google on a higher plan aren't anything to worry about though, you'd be talking about a few cent per multiple hundred thousand requests.
I'm looking for a method in which an application I will be hosting will have the ability to run a tasks on a giving interval of x minutes to check a database and send out reminder emails automatically. This would of course be based upon a scenario in which someone has scheduled a meeting, let's say, on a day and the service's job would be to send a reminder a week prior to the meeting and on the day of the meeting. Would I be looking to run a Windows Service to complete this function or is there a better way to do such a thing? Not asking for full source just a push in the right direction. Thanks for the guidance in advance!
sounds like a windows service would work good here. Set a timer in the service that will read your database at the given interval and perform the actions you want.
Here's a link that might help you to get started.