My question is how can i figure out the duration of hook_block cache time and then how can I control it?
I want to control the cache settings to get cached every one hour or two hours?
Any idea about this?
You can check the Block Cache Alter module for that (http://drupal.org/project/blockcache_alter).
Related
I maintain a record of users' email/IP taking screenshots (44 keypress) of our website.
Currently, I am blocking them based on their weekly screenshot count.
However, I'm thinking of applying daily rate-limiting such that they are restricted access for some time (which is increased if they cross daily thresholds multiple times & the daily threshold limit also starts to decrease) and at some point, they are permanently restricted.
Is this the best way to reduce unrestrained screenshots of my website?
Thank You
I tried restricting users based on their weekly print-screen count. However, there were some users who were crossing the weekly threshold in only a few hours. I would definitely like to restrict such users immediately.
I think you will have a hard time restricting access based on a client side action. Screenshots can always be taken by using OS tools, such as snipping tool, or web scrapers EyeWitness. It may be worth going back to the drawing board to get some better answers:
Why do you want to block people for taking screenshots?
Is this temporary restriction going to actually stop this happening?
How long to you want users to be restricted for?
Have you researched any methods of preventing screenshots from being taken? Rather than trying to detect who takes them?
Have you warned users that taking screenshots will result in them being blocked? This may stop them in the first place.
I am creating an website using node.js, express.js, and mongoose and I have one field that needs to be updated after a certain time so my question is there a way to do that ? Or I have to use cron? Thank you for your answer.
You don't necessarily need to use cron.
For example, you could use setTimeout() or setInterval() (https://nodejs.org/uk/docs/guides/timers-in-node/) to achieve this functionality inside your application with the simplest means possible.
Also, there are libraries like cron (https://www.npmjs.com/package/cron) which handle these timeouts/intervals for you and are nice if you prefer cron-style syntax without having to deal with os-side infrastructure or don't have any access to it.
You shouldn't need to update a field when the ban expires. Instead, put a future time in the field for when that ban expires. Then whenever they attempt to connect or login, you just check if the time in the field has passed. If not, they aren't allowed in. If so, then they are allowed in. This is much more efficient than trying to clear a field in 30 minutes. Just put a time for 30 minutes from now in the field and check that time anytime they connect.
Is there a way to do graceful ramp down of my user load while running load tests using locust framework ?
For e.g. using the below command -
I want to run a single user for a time period of 5 minutes in a loop, but here what happens is that the last iteration end abruptly with lets say 5 requests on some of the tasks and 4 on some others.
Yes! There is a new flag (developed by yours truly :) called --stop-timeout that will make locust wait for the users to complete (up to the specified time span)
There is (as of now) no way to do actual ramp down (gradually reducing the load by shutting down users over time), but hopefully this is enough for you. Such a feature might be added at a later time.
You can create your own Shape that allows you to specify how many user should be present at any time of the test.
This is explained there: https://github.com/locustio/locust/pull/1505
Running a single script with only two users as a single scenario without any pacing, just think time set to 3 seconds and random (50%-150%) I experience that the web app server runs of of memory after 10 minutes every time (I have run the test several times, and it happens at the same time every time).
First I thouhgt this was a memory leak in the application, but after some thought I figured it might have to do with the scenario design.
The entire script having just one action including log in and log out within the only action block takes about 50 seconds to run and I have the default as soon as the previous iteration ends set not the with delay after the previous iteration ends or fixed/random intervalls set.
Could not using fixed/random intervalls cause this "memory leak" to happen? I guess non of the settings mentioned would actually start a new iteration before the one before ends, this obvioulsy leading to accumulation of memory on the server resulting in this "memory leak". But with no pacing set is there a risk for this to happen?
And having no iterations in my script, could I still be using pacing?
To answer your last question: NO.
Pacing is explicitly used when a new iteration starts. The iteration start is delayed according to pacing settings.
Speculation/Conclusions:
If the web-server really runs out of memory after 10 minutes, and you only have 2 vu's, you have a problem on the web-server side. One could manually achieve this 2vu load and crash the web-server. The pacing in the scripts, or manual user speeds are irrelevant. If the web-server can be crashed from remote, it has bugs that need fixing.
Suggestion:
Try running the scenario with 4 users. Do you get OUT OF MEMORY on the web-server after 5 mins?
If there really is a leak, your script/scenario shouldn't be causing it, but I would think that you could potentially cause it to appear to be a problem sooner depending on how you run it.
For example, let's say with 5 users and reasonable pacing and think times, the server doesn't die for 16 hours. But with 50 users it dies in 2 hours. You haven't caused the problem, just exposed it sooner.
i hope its web server problem.pacing is nothing but a time gap in between iterations,it's not effect actions or transactions in your script
I'd like to write an extension that displays a desktop notification every day at a specified time. Having a quick look through the Chrome APIs, it seems like the only way to do this would be to:
create a background page for my extension,
use setInterval() with a sufficiently low resolution to not tax the CPU (even 5 min is fine),
when interval fires, check if the current time is after the desired time,
ensure that the user has not already been displayed the notification today.
(The details of the last step are irrelevant to my question, just put in to show I realize I need to prevent "flapping" of the notice).
This seems rather indirect and potentially expensive though; is there any way around this? Is the background page needed?
I suppose I could just call setTimeout() and only fire the event once (by calculating how long between now & desired time), then call it again after the notification is shown. For some reason that sounds more "brittle", though I'm not sure why...
I think you will want the background page to do this smoothly. You can't use a content script because you need to keep the "state"/timer.
So when background page first loads (browser start) you work out the current time and the offset to the next notification time and setInterval to that exact interval. That way you won't need to poll every five minutes and/or work out if you've shown the message. You simply show it at the exact time required. This has to be far more efficient, effective and cleaner than polling. At notification you just reset the interval again.
Some sample functions here:
setTimeout but for a given time
From reading the above post and from a quick search on the net it appears that you should have no problem calling setInterval for an interval such as once a day. Calvin suggests 25 days!
That is how I would approach it.
EDIT: Since posting one thing that has sprung to mind is what happens if a PC gets hibernated for n hours? I need to test this myself for a similar project so I will update once I've had a chance to test this out.