So my government petition tracker has been pretty heavily used in the last couple of days. I thought it was worth putting together a little article on how it works and how it’s handling being (a little bit) busy.
How it’s made
- The tool is built with Laravel on PHP and MySQL
- It has no login or back-end as such
- It uses the government petition site’s JSON API: you can stick ‘.json’ on the end of a URL and get a snapshot of the current count and the current counts by geographic region
- The system only collects data for petitions it knows about. You have to tell it to collect data for a specific petition. It does not collect data for all petitions.
- For each petition, the system collects the count data every 5 minutes (if it can! the goverenment’s system has been struggling this week)
- I only store the global count and a “delta” – the different between the current point and the precious point, to get an idea of growth rate
- The delta’s are a bit rubbish. I should average them out over the time since the last count was collected. It’s on my list!
- It runs on a $10 Digital Ocean droplet/VPS alongside a few other side projects of mine.
- I deploy using Git and Laravel Forge
How’s it doing?
Well, unlike the government site, it has stayed up! And it’s been performing fine. It’s not had HUGE traffic, but…well…here’s some stats. Bear in mind that I use my own very simple privacy-aware analytics, so numbers are helpful but won’t be the kind of super-accurate stuff you get from more sophisticated analytics tools:
- The petition tracker has had 22,500 page views in the last 24 hours (to 09:45 on Friday 22nd)
- It’s only had 30,100 page views in the last year, so 75% of the year’s traffic has been in the last 24 hours.
- The server peaked at 36.14% CPU and has averaged about 15% throughout the day
- Memory usage is pretty flat
And this despite me not really having any caching in place.
OK, so I’m getting 1,000’s views per day rather than per minute, but I’m pretty happy with this.
Though I am a bit scared that a retweet from the wrongright person could take the thing down!
Let’s see how today goes!