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

Geolocation queries should be cached #1

Open
eudoxos opened this issue Oct 19, 2024 · 4 comments
Open

Geolocation queries should be cached #1

eudoxos opened this issue Oct 19, 2024 · 4 comments
Assignees

Comments

@eudoxos
Copy link
Member

eudoxos commented Oct 19, 2024

Geolocation is queried remotely after every update of VPN status (every few seconds), for each client; this should be cached (with infinite TTL). It also causes the markers to briefly disappear and appear one after another during the refresh.

for (var i of this.peers) {
const remote = i.remote.host;
// geo geolocation data
const response = await fetch(
"https://get.geojs.io/v1/ip/geo/" + remote + ".json"
);
var ans = await response.json();
//console.log(answer.latitude, answer.longitude);
i["coords"] = [ans.latitude, ans.longitude];
i["country"] = ans.country;
i["city"] = ans.city;
i["organization_name"] = ans.organization_name;
}

@bpatzak
Copy link
Member

bpatzak commented Oct 20, 2024

This is done in c20e8ab

I am currently trying to figure out why https://musicode.mupif.org/safe-api/scheduler-status2/ is so slow
The endpoint calls schedulerInfo method defined in monitor.py.

In schedulerInfo method there is

  • s.getStatistics() call that returns immediately
  • s.getExecutions(status='Running') which returns array of size 140 (in musicode), also including records with other statuses (Finished, etc). this method calls restApiControl.getExecutionRecords(status=status). So this call is the root cause of slow response of this endpoint. Filtering does not work properly.
  • Then the endpoint loops over recieved executions and tries to get tail of the log. Not sure if this is needed at all.... (at least the monitor does not seem to need the data on running executions, it shows only the data on "lastExecutions"
export MUPIF_NS="172.22.2.1:10000"
import Pyro5
import mupif
ns=mupif.pyroutil.connectNameserver()
query = ns.yplookup(meta_any={"type:scheduler"})
uri=query['mupif.scheduler'][0]
s = Pyro5.api.Proxy(uri)
executions = s.getExecutions(status='Running')
len(executions)
140

@stanislavsulc
Copy link
Collaborator

Filtering of executions by status is done in
mupif/mupifDB@2081d69
mupif/mupifDB@b71762e

@eudoxos
Copy link
Member Author

eudoxos commented Oct 21, 2024

This commit to mupif@Musicode disables fetching logs mupif/mupif@ff335e4 (@stanislavsulc sorry I have no time to really sync that with the container; apologies for the extra merge into Musicode — can you take care of that?)

@bpatzak
Copy link
Member

bpatzak commented Oct 21, 2024 via email

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

No branches or pull requests

3 participants