SwiftKit Statistics

0 Flares Filament.io 0 Flares ×

One feature for SwiftKit we’ve always wanted to add was a way to count the current active users. We tried a number of methods a few years ago but all were unsuccessful, mainly due to not putting the proper thought required into the process. This time however, we stood back, looked at what needed to be done and took our available resources into account.

If we had a big beefy dedicated server at our disposal the implementation of such a feature would most likely of been quite trivial. A simple connection between SwiftKit and the server with a ping pong type system to validate connectivity would of been fine, then we could of just counted the number of connections and voila. The problem was we knew the number of SwiftKit users at any given time would be anywhere between 5 and 20 thousand. So we couldn’t do the method mentioned above on the resources that were available to us.

Eventually we came up with a viable solution, one that would work with the resources we had. Every three minutes SwiftKit would silently load a webpage(less than 1kb) on one of our servers. This webpage contained only a script that would add an entry to our Users Online database, adding a unique id and an expire time which was the current time plus 200 seconds. Since this is done every 3 minutes we add an entry once, after that we use the unique id to update the expire time. Finally a script is run on the server every five minutes that remove any entries in the database that are less than the current time. In other words, it deletes all the expired entries.

So with this method, we finally have a way to count the number of active SwiftKit Users and not use up too many resources on our server. The SwiftKit update 1.30 was when we added it in, but no mention of it was made as we wanted to test it first. Initially there were a few problems with the database server, the main one was it kept hitting the max connection limit. A few tweaks and optimizations were made(mainly replacing Apache with Lighttpd) the server began to handle it just fine. In fact better than expected, this weekend should be interesting though as the weekends are the busiest time.

So now on the SwiftKit website you can check out how many active SwiftKit users there are. Currently at the time of writing this there are a bit over 11,000  users using it at once. For kicks we added a % of current RuneScape players figure, this figure is a little off though as the SwiftKit Users figure also takes into account those who have left SwiftKit open and are logged off.

If you are aware of a better method for counting users of a desktop application I’d love to hear about it. Obviously our method isn’t mind blowing, but it seems to be working. Feel free to leave a comment or some constructive criticism if you have it.


0 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 0 Reddit 0 Filament.io 0 Flares ×