Some Bits: Nelson's log

6 posts about logs-of-lag

Logs of Lag outage

Oh boy did I screw up. Back on September 1 I pushed a tiny change to Logs of Lag, an old service I still run for League of Legends players. It was such a simple change, just adding an HTML link, so I didn’t test it carefully. Turns out I made that change on top of the master branch which had some other changes I’d committed but never tested or deployed back in 2015, and that new-but-old code didn’t work. The site’s been broken for 7 weeks now and I only found out when a user wrote me.

I love this commit comment past-me wrote:

Potentially breaking change: webapp use new stats. This change has not been tested manually, hence the warning in deploy.sh

I did read the commit log before pushing again, but apparently I didn’t read back far enough. Also I didn’t use my deploy script to deploy the server. Talk about shooting yourself in the foot. I even have a tiny bit of monitoring on the service but it didn’t show this kind of error, not that I pay attention to the monitor anyway.

The real problem is that I’ve abandoned this project; I haven’t done real development on it in 4 years. It’s kinda broken now too as the file format the code parsers has changed over time and I haven’t kept up. I’m now 100% fed up with League of Legends and Riot Games, given how sexist and awful that company is. So I have no motivation to do more. But the tool is still useful so I’ve tried to keep it online. (Past me did one thing right: the site is mostly just running static files, so it’s not hard to keep running.)

The site doesn’t get a lot of usage, my estimate last year was 50-100 unique users a day with about ~450 uses of the tool a day. Here’s a graph of the rate of usage; you can see an organic falloff over the whole year, then it falls sharply Sep 1 when I broke the site. I wonder if it will recover.

logsoflag2-year.png

More Logs of Lag aggregate stats

Following on my analysis of the average LoL game, here’s some scatterplots and histograms of various statistics for games. Specifically, for each game I’m looking at match length (0-3600 seconds is typical), best ping (10-150ms is typical), median ping (10-150ms is typical), and packets lost / minute (0-1 is typical, but long tail).

A huge caveat for this data: this is not a valid statistical sample of all LoL players. This is a random sample of Logs of Lags users, almost certainly biased towards people with network problems. I don’t intend to publish this data widely because it’s not a fair sample.

Honestly, the scatter plot is not the best treatment here; too many dots, not enough correlation. The histograms at top and right examining single variables are probably more interesting. Some notes:

  • Median ping and best ping are pretty tightly correlated. No big surprise there; they are nearly identical on a connection with low jitter and no packet loss. Not sure about the diagonal lines above the x=y line, maybe an artifact of how the game synthesizes a fake ping number in the presence of packet loss?
  • People’s pings are an interesting bimodal distribution, roughly peaking at 50ms and 110ms. I can’t account for the relative unpopularity of 80ms. Well if this were all North American data I’d say it was west coast vs. east coast, but I get a fair amount of European uploads too.
  • Packet loss / minute has a lovely long tail distribution. FWIW, I call anything over 5 a “bad link”; that’s ~30% of my logs, perhaps I should move that number up.
  • I was hoping to see evidence of correlation between packet loss and best ping, on the theory longer connections would be worse. I don’t see any evidence of that in the picture, it’s just a mess of dots. Need a better analysis tool. Same problem with packet loss vs. match length
  • Similarly, I can’t draw any conclusion from median ping vs. match length. That previous graph I did suggests the average ping for players does not go up during the game.

Data storage for Logs of Lag

My little Logs of Lag project is doing pretty well, I need to create some sort of more serious datastore for it. It’s a small service, at most 1000 logfiles uploaded a day (each about 20k per file), but over time that adds up. Right now my data store is “put a file with a random name in a directory”. And I have no database or analysis of all the files.

The high-end solution would be to start putting data files in AWS and create a local Postgres database for aggregate statistics. I know how to build this. But that adds two big moving parts, one of which I have to maintain myself. And it’s kind of overkill for the relatively small amount of traffic I have (and am likely to ever have).

So I’m thinking now just to keep storing the files themselves on the filesystem, but spread it out over a bunch of directories so I don’t have a single giant directory. The Linux kernel no longer chokes on lots of files but shell tools are still a PITA. File names are base 64 encoded things so maybe hash by the first two characters, for 4096 directories. That’ll carry me to about 16M log files (4096 files per directory), good enough. The file system only has 60M inodes available anyway. (Unfortunately - is a valid leading character in the filenames. Oops.)

I definitely want a database, I’m curious about aggregate stats. I’m thinking of keeping this all asynchronous. When a user uploads a log it doesn’t go straight to the database, just written to a file. Then a cron job picks up the files and does the postprocessing. That works fine as long as the database data still isn’t needed by the user application. It’s not right now, in fact the server isn’t needed at all, the user gets 95% of the value solely in client side javascript.

What database? I should probably bite the bullet and just use Postgres, but I hate having to manage daemons. I wonder if SQLite is sufficient? It supports concurrent read access but only one writer at a time, and the writer blocks readers “for a few milliseconds”. I think that constraint isn’t a problem for me. Right now I’m tempted to go for that, just for the fun of doing something new.

Another problem to solve is the log parsing code. Right now logs are parsed by the client browser, in Javascript, and the client sends both the raw log text file and the parsed data (as JSON) to my server. (The server is a Python CGI which just writes the files to disk.) I’d like to retain that client-only capability, but also start parsing logs on my server. I don’t really want to maintain a second parser in Python.

So maybe I write the server parser / database stuff in Node to reuse the Javascript parser. Here’s MapBox’s node-sqlite. There’s zero need for me to make these scripts asynchronous, so the Node paradigm is not a great match, but I can certainly make it work.

(Naively I’d thought Node startup times would be bad, like Java, but that’s not true. From Node v0.10 on Ubuntu: “NODE_PATH=/tmp time node -e 1” is about 27ms, compare Python 15ms. Not enough difference to matter. strace shows Node makes about 230 system calls for an empty script (it’s nondeterministic!), compare Python’s 883.

Logs of Lag summary stats

My Logs of Lag tool now has collected some 25,000+ logfiles. It’s a heavily biased sample: people mostly bring logs to my site if they have network trouble, but some stats nonetheless. Numbers are the average of each stat, with SD in parentheses

  • Best ping: 85ms (153)
  • Median ping: 97ms (389)
  • Packets lost / minute: 8 (120)
  • Game length: 28 minutes (13 minutes)

Would be nice to publish something from this data. I sure wish I had a way to get a representative sample. I wonder if I can convince some group of players to just upload their logs, whether they have problems or no. Would still be biased but maybe useful.

Here’s the kludgey script I use to generate a CSV file of all the results, which I can then feed to my 20 year old C program that calculates averages and standard deviations. Very quick and dirty, I should tackle a project of handling user data as more than flat JSON files.

for f in *; do
  ~/lol-netlog/logToJson.js < $f | 
  jq '"\(.matchLength),\(.packetsLost),\(.packetsLost/.matchLength),\(.medianPing),\(.bestPing)"'
; done > /tmp/logs.csv

Some quick ad campaign stats

I ran some simple ads to promote Logs of Lag, my League of Legends netlog parser. I’m having a hard time getting attention and thought it’d help to get a bit of paid traffic. I invested, oh, $20 in all of this, trying to bottom feed some traffic. Results after a week or two of trying:

Google Adwords

0.18% CTR. 4468 impressions, 8 clicks, $2.73

Screen Shot 2014-06-26 at 2.03.14 PM

Very bad results, particularly on the search ads. Google’s minimum bid for a relevant keyword like [league of legends lag] seems to be at least $1, and apparently Google is happier showing no ads than showing cheap ads. 4339 of the impressions were via the Display Network. Near as I can tell AdWords gives me no way to see where those ads actually displayed. Bummer.

Bing Ads

0.59% CTR. 848 impressions, 5 clicks, $0.17

Straight-up clone of the Google ad campaign. But Bing Ads is quite happy to show ads for $0.10 CPC, so the good keywords I wanted got some impressions and clicks. No display ads at all; not sure if I wasn’t eligible or there was just no inventory.

Twitter Ads

Too early to tell. But my ad is a poor match for Twitter. All you can promote is a tweet, and I didn’t want to write a special ad tweet for my website. Also hard for me to imagine a Twitter user will be inspired to try my tool by a Twitter ad, particularly on a mobile device. I think Twitter Ads may be better suited for brand campaigns.

Reddit Ads

0.94% CTR, 14030 impressions, 132 clicks, $10.

Screen Shot 2014-06-26 at 2.11.33 PM

 

By far the most successful of my ads. In part because I could target it so specifically to /r/leagueoflegends, a big community. Also Reddit ads are cheap. It’s a pretty interesting ad product really, particularly the way ads become stories that get Reddit votes, comments, etc. I’m surprised it’s not better known. Reddit has a blanket $0.75 CPM rate which seems fairly cheap to me, particularly given the value of Reddit’s audience. The ad tool sure is primitive though. I’m left wondering why Reddit doesn’t pursue an ads business more aggressively.

Conclusion

Small ad campaigns are cheap. OTOH I didn’t set up any way to measure actual conversion. What I want is to get my tool in people’s minds so they remember to try it a month from now, and I’m not about to do the necessary work for such a small side project of mine. I don’t regret the $12.90 I spent though. I’d definitely go back to Reddit ads to get attention for something there, particularly if the organic way of getting Reddit attention doesn’t work out.

 

Logs of Lag ready to go

My Logs of Lag site is ready to launch. It works well, a clean and simple way to drop a League of Legends logfile onto a web page and see some statistics.

Not sure how to properly “launch” this yet. Success would be some visibility on the League of Legends Reddit, I’ll probably post it on Monday but it’s a crapshoot of the first 15 minutes whether it gets upvotes or not. I don’t expect an amazing response, this kind of tool is really something more useful to hang around and be available for months or years when people need it.

I’m pretty happy with how the final project came together. I was worried for a long time about the visual style. I still don’t think it’s great, but adding a basic background image texture and switching the fonts from Helvetica/Arial made a big difference in making it feel “real”. And I don’t want to do the over-produced glitzy graphics thing that’s popular with most gaming sites, I find that a useless distraction.

Ideas for future features:

  • Highlight “bad” data. Ie; if the loss/second is greater than some threshold, make that show up in big angry red warning font. I want to collect some logfiles from users to see what is typical before building a classifier.
  • Parse broken logs. In particular the logfile gets wonky if the game disconnects, would be nice to parse that correctly.
  • An analyzer for a whole directory of files. This is the way lolparse.com works, presenting summary statistics for gameplay in many games. It’d be useful to characterize lag for many games as well. Totally feasible given all the work is client-side, it could be fast. A histogram showing the distribution of median ping and median packets/s loss would be a good start.

And ideas for the server:

  • Replace the Python CGI with a real server. I have a Node version but I’m not sure I like Node. Porting the CGI to Gunicorn would suffice for scaling.
  • Or.. Remove the server entirely. Just make the client Javascript upload stuff to S3.
  • Or.. commit to a real server, and add logins and user data management.