Prevent Synthetics Running Concurrently

Hello New Relic Team,

I’m wondering if there is any way to prevent synthetic scripts being run concurrently from minions. This posses a problem for me when I have user login and add/remove items from a cart and the user account is stored in the DB. Sometimes the checks will overlap in execution causing overlapping shopping cart additions/removals and trigger a false positive. I understand I can set the check to a single location with a long enough interval to prevent overlap but I lose the capability to test from different locations by doing this and as a result I can’t accurately test my CDN.

I’m wondering if there is a way to set up either the script or minions so as to wait till one test is finished before triggering the next.

1 Like

HI, @adrian.stratienco: I don’t know of any way to prevent a check from starting when another is in progress, but I can think of a couple of workarounds:

  • When a test starts, it can set a flag somewhere (such as in New Relic Insights) and clear it when finished. Have your monitor check the flag at startup; if it is set by a minion in another location, don’t run the check.

  • If you can figure out the location from which the script is running, you can use a different user account for each location. Or you can randomly select a test user on each run, reducing the likelihood that two locations will login with the same credentials.

1 Like

Thanks @philweber I’ll give the Insights Boolean a try, that sounds like it may do it. I’m not a big fan of managing multiple logins per script.

As a feature request, it may be useful to have that as a tick-box in the synthetics GUI under the general tab which auto-magically sets this up in the synthetic. Dunno if I’m the only one that runs into this issue from time to time but I’d suspect many sites use login based sessions.

I have a script that looks like this:

var users = [
	{"username":"testuser1","password":"xxxxxxxx"},
	{"username":"testuser2","password":"xxxxxxxx"},
	{"username":"testuser3","password":"xxxxxxxx"},
	{"username":"testuser4","password":"xxxxxxxx"},
	{"username":"testuser5","password":"xxxxxxxx"}
];

// select random test user
var userId = Math.floor(Math.random() * 5);
var user = users[userId++];

login(user);
1 Like

Hi @adrian.stratienco, did you get the insights method working? We have the same issue running concurrent tests.

Cheers

I ended up modifying the scripts to account for running concurrently and that essentially worked around the issue.

Hi @bevan! Did @adrian.stratienco’s reply help with your issue? Let us know if you’re still having problems. Thanks!

Phil,

Is there a way in the scripting to determine the minion that is running the script? In my case, I’m OK having multiple accounts - one for each minion location, I’m just not sure how to get the location of the minion that is running.

I do not know of any way to determine the location of the minion running the script. But you could use the Insights method mentioned in the thread above to store the last-used login account; query that value from your script, and use the next one in the list.

@philweber @chad.markle - I actually answered this earlier this morning :smiley: You can determine the location in your script.

Check that out over here:

4 Likes

Great! That’s what I’m looking for! I appreciate the help.