PythonAnywhere now supports Postgres


Finally!

tl;dr: upgrade to a Custom account and you can now add Postgres

Say no to multi-tenancy (aka The Whale vs the Elephant vs the Dolphin)

Postgres has been the top requested feature for as long as we’ve supported webapps (3 years? who’s counting!). We did have a brief beta based on the idea of a single postgres server, and multi-tenanted low-privileged accounts for each user, but it turned out Postgres really doesn’t work too well that way (unlike MySQL).

Our new solution uses Linux containers to provide an isolated server for each user, so everyone can have full superuser access. And, yes, it uses the ubiquitous Docker under the hood.

How to get it

  • You’ll need to upgrade to a Custom account, and enable Postgres, as well as choosing how much storage you need for your database.

  • Then, head on over to the Databases tab, and click the big button that says “Start a Postgres server”.

  • Once it’s ready, take a note of its hostname and port

  • Set your superuser passsword. We’ll save it to ~/.pgpass for convenience.

  • And now hit “Start a Postgres console” and take a look around!

How it works under the hood

We run several different machines to host postgres containers for our users. When you hit “start my server”, we scan through to find a machine with spare capacity, and ask it to build up a container for you.

It’s a docker container based on our postgres image, but each individual user’s is customised slightly. For example, we create a superuser account called “pythonanywhere_helper” with a unique, random password to enable us to perform some admin functions. (once you have your own superuser account you could theoretically delete this guy, but we’d rather you didn’t…)

We also set up a special permanent storage area for your database, which gives us the ability to migrate you to a different server if we need to.

You can read a bit more about our TDD process for developing this part of the codebase here

What it costs

Aha, the dreaded question. We’ve set the price for the basic service at $15/month which includes 1GB of storage, and subsequent gigs are 20cents/gig, which we think is pretty fair… Feel free to have a moan if you think it isn’t!

What to do next

That’s up to you! We’ve tried to supply you with everything you could need, including the bleeding-edge 9.4 version of Postgres, PostGIS, PL-Python and PL-Python3…. Let us know how you get on!

comments powered by Disqus