I am hosting Strapi the headless CMS on Google App Engine and my issue is that this backend goes to sleep after some inactivity, and due to this it requires waking up when it is interacted with, resulting in a good few seconds passing by before any API calls are retrieved.
I can see on Google App Engine the logs show that the app is starting, then the network stuff happens and so on until nginx is started and then a welcome back message is stated before the API call can be seen.
Does anyone know how I can keep this running continuously without having it sleep…perhaps pinging is an option but I was hoping for a setting/config that would allow this.
Thank you
Here is a Guide for creating a strapi project on App Engine.
As mentioned in the Documentation :
Warmup requests are used by the App Engine scheduler, which controls
the auto scaling of instances based on user-supplied configuration.
With warmup requests enabled, App Engine issues GET requests to
/_ah/warm up. You can implement handlers for this request to perform
application-specific tasks, such as pre-caching application data.
The scheduler starts up instances when it determines that more
instances are needed. Warmup requests may appear in logs even if they
are disabled because the scheduler uses them to start instances.
For example, if you are using Express.js, your handler might look
like:
const express = require('express');
const app = express();
app.get('/_ah/warmup', (req, res) => {
// Handle your warmup logic. Initiate db connection, etc.
});
// Rest of your application handlers.
app.get('/', handler);
app.listen(8080);
You can also refer the forum for more information related to strapi automatic scaling on App Engine.
For more information, you can refer to the Documentation_1 and Documentation_2 to know how instances are managed and requests have been handled on App engine.
Related
I am fairly experienced with Node, Express, and React but new to Next.
I am using Next's middleware to re-write API requests to my backend server (using NextResponse.rewrite).
I am not using Next's API functionality.
I am planning to deploy the app to Vercel.
Some of my APIs need more than 60 seconds to respond. From Vercel's Limits Doc, I see that the middleware function timeout is 30 seconds. Does it apply to rewritten requests (proxied to the backend) as well? If yes, is there a way to extend this? Without it, a Vercel deployment is out of the question and I will have to self-host Next which involves a lot more infra management.
I am using Cypress for end-to-end testing an application, together with the cypress-firebase package. I followed the official setup instructions (using TypeScript, and the Firebase Web SDK version 9 with the compat mode).
In my tests, calling cy.login() seems to work as expected in that Cypress logs that the createCustomToken task successfully performs two HTTP POSTs with status code 200 each.
However, when visiting a page of the application afterwards, no user is logged in. In the application, the login status is supposed to be detected using Firebase's onAuthStateChanged function. It seems that cy.login() never triggers onAuthStateChanged, though.
My best guess is that maybe the auth instances used by cypress-firebase and the application code are not the same?! Is there a way to confirm this, or could there be another reason?
Happy to provide further information if it may help.
The issue was indeed related to auth instances not matching: The application was using a named instance, whereas the initializeApp code in Cypress was not naming the app (and thus relying in an app instance named [DEFAULT]).
Fortunately, cypress-firebase has support for named apps:
const namedApp = firebase.initializeApp(fbConfig, "app_name");
attachCustomCommands({ Cypress, cy, firebase, app: namedApp });
The need is for blocking the spam users from overusing the quota, or prevent DDOS attacks from client applications,
When a cloud function sees that the resources are being heavily consumed (by using admin sdk, collections.onRead property) by some particular uid, it should log the user out from the application by writing auth.SignOut(); or exit(0); in that users firestore record, which is actively being listened by client application, and the client application should then execute that code by referencing to that particular function of firebase_auth: library,
Or is there any better approach to achieve this kind of failsafe for these kind of scenarios ?
check background fetch so even the app is terminated you can run some functions in the background and keep checking your condition once the condition satisfies call logout.
https://flutter.dev/docs/development/packages-and-plugins/background-processes
https://pub.dev/packages/background_fetch
The flutter builds an encrypted package as an output for your implementation (codes).
So it is not possiblee to include some more code/ execute some codes without rebuilding the package.
But you can use an internet connection to fetch some config (dynamic) for your application from your custom Backend or Firebase (remote config). By this, you will be able to do some tasks dynamically, such as the theme of the application, the color of a widget, and many more.
I implement user signup logic in my nodejs backend server. It uses firebase for username and password signup. Below is the code used in nodejs:
var firebaseClient = require('firebase');
firebaseClient.initializeApp(config)
firebaseClient.auth(). createUserWithEmailAndPassword(req.body.email, req.body.password).catch(function(error){
console.log(error);
})
the problem for this approach is that firebase has a usage limit which is 100 accounts/IP address/hour. All users who signup in my application will go to my nodejs server first. That means firebase will think there is only one user. It will meet the usage limit very easily. I know I can put the signup process in the frontend but I don't like doing this. Because my signup logic needs to save something in my local database as well. I wand them to be in one place. Does anyone know how to handle the usage limit in my case?
The Firebase-Auth AdminSDK should not be rate limited so you can use it on your NodeJS server without any problems to handle as many user authentications as you require.
Make sure you don't use the client-side javascript SDK, which should not be used on the backend, but instead for frontend consumers like IoT, WebApps, Consumer Desktop Apps..
More info on the difference here: https://firebase.google.com/docs/admin/setup
We have this Pub/Sub system that you subscribe to via a callback mechanism in C# to recieve events from various things that happen within the database. This subscription has a callback signature attached to it that allows for the Pub / Sub system to callback any subscribers it has and notify them of the change on that Callback thread.
We are taking our windows application and migrating it into a web application. In doing so, I need a way to update this Web Application (The clients) with information from this Pub / Sub. I want to use SignalR, but not sure where to host it. I assume if I host it on the same Web Application as the Client, it won't be able to subscribe to the pubsub due to it not being able to do background threading.
Currently, I have it in a Console application hosting the SignalR server on a specific port. Obviously this is for testing and not ideal for a larger scale.
My question is.. is it really safe to be hosting SignalR outside of IIS? should I put this in a Windows Service? Web Service somehow? Can it go in a Web Application somehow?