Where to Host a Twitter Bot

Reading time ~3 minutes

A troll carrying a club

A while back I created the Daily Patent. A Twitter bot that gets a random patent and tweets it out periodically. I started by hosting this on a Google Cloud virtual machine but eventually decided to look for something more suited to this kind of task.

Here’s my review of several places you can run a simple Twitter bot.

The Twitter logo

Now any old server could run my bot as it’s a very basic Python script that runs for a fraction of a second each invocation. My core criteria here was “What is both the cheapest and easiest way to host my bot?”. I don’t need much processing power at all so I really just wanted something quick and hands-free to run on a schedule.

Azure, Google and AWS Virtual Machines

Initially I figured I’d take a look at a bunch of virtual machine options.

I started with Google Cloud. This ended up being a fun experience with small instances and the Google Cloud Platform, but resulted in disappointment at the price. I ran this before Google expanded their time window for using a $300 credit they give you for free so I only had 60 days of testing. Which meant on day 61 I had to start paying ~$4 a month for the cheapest instance money could rent. They’ve since expanded their offering to 12 months and $300 of play-around cash.

Then I took a look at AWS. The t2.nano would run me about the same thing, slightly under $5 a month. While I could use AWS free tier for a year, mine has already expired on other projects so I decided against this too. If you haven’t signed up for AWS yet, using this with the free tier isn’t a bad option either, so long as you realize after a year this is another option you’ll have to start paying for.

I also glanced at Azure but my options started at $13 a month so I didn’t look at it very seriously.

So because of my innate frugality I ruled out all the virtual machine options from what are probably the top three providers. If I wanted to pay that much to send stupid tweets generated by a 20-line python script I’d buy a Raspberry Pi and plug it into my router (not a bad idea actually).

Serverless Functions

Next, I took a look at ‘serverless’ options that I’d only be charged for when I briefly ran the code for the Twitter bot.

Again, I started with Google. The Google Cloud Functions offering is currently in Beta, but is free to use. Unfortunately, at the time of writing this I couldn’t find an easy way to set up regular, cron-like scheduled triggers for Google Cloud Functions. Maybe they have some by the time you read this. Go check. If you can find a way to trigger these off a scheduled event or you don’t need that functionality, these might be a good option for you.

Azure and AWS both have decent offerings in the severless functions department. Azure Functions and AWS Lambda both offer 1 million free function invocations and a significant amount of GB/s compute allocation. They also both provide me a way to schedule functions on a cron schedule. Because of this I’d strongly suggest trying either one out for your next bot project as you’ll be able to play around without paying a penny.

Currently the Daily Patent is up and running on AWS Lambda because I decided I liked the AWS platform better, but the services as comparable for this kind of project, so check them both out.

comments powered by Disqus