Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Probes selection rules #9

Closed
zarianec opened this issue Mar 14, 2022 · 0 comments · Fixed by #35
Closed

Probes selection rules #9

zarianec opened this issue Mar 14, 2022 · 0 comments · Fixed by #35
Assignees

Comments

@zarianec
Copy link
Contributor

Current measurement request payload:

{
    "locations": [
        {
            "type": "country",
            "value": "FR",
            "limit": 3 // per-location limit
        },
        {
            "type": "country",
            "value": "PL",
            "limit": 4 // per-location limit
        }
    ],
    "measurement": {
        "type": "ping",
        "target": "hello.com",
        "packets": 3
    },
    "limit": 10 // global limit
}

Global limit and per-location limit are mutually exclusive - it means that if the global limit is present in the request, the per-location limit is not allowed and vice-versa.

Because we are not limited by a single location type per request - the resulting probes set must contain unique records only.

const probes = [
	{ id: 1, country: "PL", contient: "EU" },
	{ id: 2, country: "UA", contient: "EU" },
	{ id: 3, country: "PL", contient: "EU" },
	{ id: 4, country: "NL", contient: "EU" },
];

const request = [
	{ type: "country": value: "PL", limit: 1 },
	{ type: "continent": value: "EU", limit: 4 },
]

const result = [
	// because of request[0]
	{ id: 3, country: "PL", contient: "EU" },
	

	// because of request[1] - even though 4 probes from the EU was requested - only 3 was found
	{ id: 2, country: "UA", contient: "EU" }, 
	{ id: 4, country: "NL", contient: "EU" },
	{ id: 1, country: "PL", contient: "EU" },
]

Case 1. With locations and limit per location

This is the easiest one. We must find the exact amount of probes for each location. If we don't have enough probes for a specific location, only these we have will be used and the final probes count may be smaller than expected.

Example:
Probes: UA:10; PL:4; NL:3
Request: UA:5; PL: 7; NL:3
Result: UA:5; PL:4; NL:3

Case 2. With locations and global limit

The final amount of probes shouldn't exit the global limit. It may be smaller if we don't have enough probes in total though.
At least 1 probe from each requested location must be present in the results (if we have probes there at all ofc.).
If some locations don't have enough probes the result must be filled with probes from locations that have them.

Example:
Probes: UA:6; PL:2; NL:1
Request: UA; PL; NL - Limit: 6
Result: UA:3; PL:2; NL:1

Case 3. Without locations and global a limit (e.g. World Wide)

For World Wide (WW) requests, we must apply "smart" logic where we break the world into groups and the final probes set must contain a predefined percentage of probes from each group.

percentage location
5 Africa
15 Asia
30 Europe
10 Oceania
30 North America
10 South America

Example:
For a WW request with a global limit of 100, the result will contain 30 probes from Europe, 15 from Asia, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant