Closed thedig closed 4 years ago
This is awesome @thedig ! You are a speed demon :)
It just occurred to me that calculating the totals in a live scenario is not quite as simple as our tests would make it seem. The complication is that each exitnode publishes its route table information whenever it wants (more or less every 2 minutes). This means that the timestamps of the logs from one exitnode are not guaranteed to match the timestamps of the logs from any other exitnode (in fact they almost certainly will not match).
Running the simulate-activity.js script once does not make this obvious, but if you comment out one of the simulated posts (as though one of the exitnodes skipped a beat), you'll see an error on the server-side. (I'll open an issue about making simulate-activity.js a little more robust.)
I can think of two ways to deal with this timestamp issue. Let's say the logs look something like this:
timestamps | 2 | 6 | 8 | 11 |
---|---|---|---|---|
exitnode reporting | A | B | A | B |
route table | 10.0.0.1, 10.0.0.2 | 10.0.0.3 | 10.0.0.1 | 10.0.0.2, 10.0.0.3 |
Method 1: Keep a running total of nodes as you move through time. So the resulting totals would be:
timestamps | 2 | 6 | 8 | 11 |
---|---|---|---|---|
unique nodes | 10.0.0.1, 10.0.0.2 | 10.0.0.1, 10.0.0.2, 10.0.0.3 | 10.0.0.1, 10.0.0.3 | 10.0.0.1, 10.0.0.2, 10.0.0.3 |
totals | 2 | 3 | 2 | 3 |
Method 2: Bin our logs in increments of, say, 5 minutes. So the above logs would get reduced to a two data points:
timestamps | 2-7 | 7-12 |
---|---|---|
unique nodes | 10.0.0.1, 10.0.0.2, 10.0.0.3 | 10.0.0.1, 10.0.0.2, 10.0.0.3 |
totals | 3 | 3 |
I think method 2 might be a simpler implementation. It loses some granularity, but I think that's okay. Might even able to do it with a single mongo query.
Let me know what you think! Or if any part of this is unclear. Maybe there's a simpler way to deal with this? In general I think implementations that are simpler and easier to understand are better, even if they're not quite as correct.
(I definitely did not foresee this problem when I wrote the issue...)
Yeah I figured my first implementation would be overly simple / missing something, and was hoping an attempt would highlight the nuance here. Thanks for more color! I'll see if I can poke at this again in a couple days.
🌈🎨
Schoolwork is eating me this week, can probably look at this again after I get a project in on Monday Jan 28.
Cool! Thanks for the update!
Hey @thedig just checking in. Is this PR something you're still interested in working on? How's school?
@bennlich Yes! absolutely, this course has been clobbering me, apologies! I'm done with it in 2 weeks and then extracurricular software time can focus on something like this.
Cool!
@bennlich I have been super derelict here, apologies! moving, job change, life change and summer has taken me away from recreational coding
I'm gonna try to come to a Sunday sudo mesh in the next month now that things are finally chilling out (but my Tuesdays keep being full). We'll see if I can jump in again and if this work is still helpful.
Heya! No worries @thedig. I hope the life + home + work changes have been good to you on the whole.
This PR is definitely still welcome IMO if you're up for finishing it off.
You've reminded me to update our online materials re: Sundays -- we're not planning to meet this summer because of low capacity w/ folks traveling and what not. But I'm always game to chat on the rocket chat or find another time to meet in person. Let me know! I'm online most days.
@bennlich ahh ok, then maybe I'll cya on a Sunday come September. I might be able to make a Tuesday in August bt all my travels. Are you there most weeks?
Yep. Almost always there on a Tuesday if I'm in town. Just missed tonight tho cause I'm in Seattle.
Also down to schedule a monitor dev night on a non-tuesday if you're wanting to get back into this. I bet a few others would join us. We're kinda low on developers right now, so I'm sure it would be worth our while to try to gather together people who have been on the edge of getting involved.
@thedig : @haydenhw built off our conversations and came up with a working solution in https://github.com/sudomesh/monitor/pull/51 !
Thank you for getting the ball rolling on this!
For #35