Running a service (script) on a site with a specified interval - web-services

I have a website. the user is authorized, enters the site URL, then sets the interval in minutes (for example, 7 minutes). Then the user leaves the site.After 7 minutes, the program, the script, the service should start, I do not know how it's called and perform certain actions with the site that the user specified and then send the result to the mail. Tell me how can I do this service?What would it work even if the user came out and closed the browser. I can not understand in what direction I should move ... I use AWS from Amazon
UPD: let's describe in more detail. There is a login field, the user enters the login / password, the data is checked in a database called users, cookies are set with the user id (idUser), then the user enters one or more sites, they are stored in a database named data_ (idUser). The interval is stored in settings_ (idUser) value in the range 1-60 min. Suppose he sets the interval of 7 minutes. Then the user closes the tab, closes the browser. A specified interval (7 minutes) starts a script that takes data from the database data_ (idUser), (there are several URL sites stored there). The script processes them and sends the results of site verification to the mail. But the problem is also that the script will be one, and how to access the bd if I do not know idUser, because I can not get them from the cookie either ... Maybe I should change the database structure altogether?

Related

How to send a "you haven't used your app in a while " push notification in React Native using AWS?

Just wanted to know from a high level how I would accomplish this.
I thought that when a user opens the application, I will keep track of the last opened time in a Dynamo DB table.
Then I could have a background worker constantly check and see if anybody hasn't used their app in 3 or 4 days and then send a push notification, ie, "you haven't used your app in a while, why don't you open it up and do XYZ."
From a very high level, there are two possible ways:
1.) Local notifications (you don't need AWS for this):
You can schedule a local notification, every time the user opens up the app (or better - every time the user brings the app to foreground). It works like: User opens app -> cancel old scheduled notification if existing -> schedule new notification for "in 3 or 4 days" -> ready :-)
You can use something like this: https://github.com/zo0r/react-native-push-notification (see section Sheduled Notifications).
2.) You could do it with remote notifications (https://aws.amazon.com/sns/):
You can go the way you proposed. Then you have to store an entry in your db with the push notification token of the device and the last time the app was opened. Your worker then has to check and send the push message to the device using a service like SNS.
I would recommend 1.) over 2.) because you are independent from the users internet connection when getting the app opening info. In 2.) you can miss the opening info, when the user opens the app without internet connection. Also 2.) is more expensive then 1.) when you scale your app.
An advantage of 2.) would be, that you are more flexible when and what you send in your notification, since you can edit it on server side. 1.) would mean that it is coded in your app (at least until you build a synchronization mechanism for the variables) :-)

Django Naive Chat Implementation. Will it work?

I was asked to make a chat application on django for a special portal where only at a particular time 4 staff users can be talking to 4 selected users from a large (around 500 not all logged in at the same time) user database.
I implemented it using django and ajax with the following details ->
I used the chat model which stores all the chat messages sent to the server till now.Its fields are
userto
userfrom
message
Each user has two states :
He can wait for a chat room to get empty which he can be alloted
He can be in a chat room and talk with one of the staff users
When in a chat room , using ajax I query all messages in the chat table, and show the messages which belong to the chat. Now a request is sent to the server each 0.5 seconds to update the message list.
Note - Inside a chatroom only the messages between the two users should be displayed
When not in a chat room , The user is redirected to a normal page (which is not real time) and displays all chat rooms that can be joined.
Here the user refreshes the page and only at that time sends the request to the server , which updates the list of the chat rooms.Basically the staff talks to only 1 person at a time.
So basically the following should be the maximum load handled by the server every second ->
16 requests every second from each user(1 request every half second) to update the chat each of which goes through all the chat messages sent till now.
At max around 30-50 users will be visiting the portal at any given time , so they may send refresh requests say around 1 per every 4-5 seconds.But here the database query is very small as it has to go through only 4 rows of database ie the chatrooms.
So that gives around 30 requests to the server per second in which 16 are heavy requests which need to go through all chat messages sent by each user till now and 14 light requests which need to query only 4 rows of a database.
This will be deployed in the future on a server (RAM-256 GB upgradable to 1.5 TB , hard disk - 3*1.8 TB) and currently on a server (harddisk - 1900 GB and RAM - (around 128 GB)
I have the following 3 questions:
Will my current implementation work properly on the giver server constraints, if not I request
firstly improvements in the current system itself ( like reducing time between requests to update chat or database improvements )
Some better and easily implementable method as I don't have much time to change the complete thing
I am implementing an archive chat feature from the staff side so that , only non archived messages will be browsed through in those heavy requests every second, which will reduce the number of messages to be browsed considerably
If possible I would like to implement the database in such a way where there are separate tables for each staff and user combo. I don't know how to do this so if there is a way please point me in the right direction.
So that I just have to fetch the messages between a staff and user and just display them , and not go through all messages everytime, that should significantly reduce the load I presume.
I have closely followed the chat implementation on the following link
https://github.com/MiniGunnR/django-jquery-chat-application
https://www.youtube.com/watch?v=Z8Gjm858CWg&t=322s

Google Admin SDK user push notifications and renaming of users

I want to ask about the situation that is related to the renaming of a user by an administrator. It can take up to 10 minutes (from the disclaimer) to get user's name changed, but the notification about update event is sent immediately. There is no way to understand whether user's data is changed or not at the moment when notification is received. The only way to process it correctly is to delay processing by 10 minutes which is not good for me.
Is there something that I've missed to handle this? Otherwise it is quite useless API.

Network AAA - concurrent login accounting

I am looking for a network AAA (authentication, authorization, accounting) protocol that that manage concurrent network resource accessing from one account. An account, say, is logged in by two users concurrently, how can I distribute the session timeout of the account between the two users?
I am assuming you are not looking for the specific AAA functionality as used by telecommunications companies, but rather, RADIUS on steroids. Perhaps the easiest way to do this is to put something like FreeRADIUS on steroids.
I'll assume your particular NAS device (Wifi hub, packet gateway, etc) supports the following RADIUS records.
Access Request
Access Accept/Reject
Accounting Start
Accounting Stop
Interim Accounting
Session Disconnect
When you get a session start, let FreeRADIUS run some sort of script or log that start into the database. This is your clock start for each user. Even if the user logs in three times, you'll get start messages. When they log out for each session, you'll get a session stop. At a minimum, simply run the database and compute the deltas and apply the accounting rules to that user. If that user used 10, 20 and 30 minutes in concurrent sessions, you'll get stop records showing 10, 20 and 30 minutes.
This works, but it doesn't go quite far enough. First, if the sessions are long, you won't know about the time of those sessions until they terminate. That could be days from now. This is where the accounting records, particularly the interim accounting records come in. If your NAS supports it, you can tell it to generate an interim accounting record for a session, say, every 30 minutes. Thus, if a session lasts 30 minutes or less, you'll get the start and stop records. If a session lasts 45 minutes however, you'll get:
A start record at time 0
An interim accounting update at time 30
A stop record at time 45
It's not really the AAA you care about -- any RADIUS server likely will do the job -- FreeRADIUS, OpenRADIUS, Microsoft RADIUS server. It's your NAS device. If it can't send the records, you can't process them.

How can I timeout Client-scoped variables in Coldfusion?

I apologize if this is a "duh" question. It seems like the answer should be easily googleable, but I haven't found it yet.
I am working on a large Coldfusion application that stores a large amount of session/user data in the Client scope (ie <cfset Client.UserName = "JoshuaC"> ). I did not write this application, and I don't have the luxury of significantly refactoring it.
I've been given the task of setting the Client variables to time out after 72 hours. I'm not entirely sure how to do this. If I had written the application, I would have stored the variables in the Session scope, and then changed the sessiontimeout attribute of the CFAPPLICATION tag. As it is though, I'm not sure if that timeout affects the Client variables, or what their level of persistence is. The way the application works now, the Client variables never time out, and only clearing the user's cookies, or visiting a logout page which sets all the Client-scoped application variables to "", will clear the values.
Of course, I could create some kind of timestamp variable like Client.LastAccessDateTime, and put something in the Application.cfm to clear the client variables if that datetime is more than 72 hours prior to Now(). But there's got to be a better way, right?
Depending whether your are using a datasource or registry as a Client Store you have to set the "Purge data for clients that remain unvisited for 90 days to 3 days (=72 hours) on the
ColdFusion Administrator => Client Variables => Registry
or
Client Variables => NameOfDatabase Page.
If Client Variables are stored as cookies, then you have to adjust the expires period, when setting the cookie.
The Purge Interval on the Client Variables page only controls how often ColdFusion executes a purge operation on your client stores (= seeks for expired Client Variables in order to delete them).
I suppose you are looking for Purge Interval setting, which is configured in CF Administrator at Server Settings > Client Variables page. Default interval is 1 hour 7 min.
EDIT: This setting value is not exactly what you need. I'm sorry, see my comment about purging -- think it is more accurate.