Choosing a database and hosting an app on a Raspberry Pi

pi

This week I attempted to make my own application centered around energy and green button data. However before even working on that app I ran into a speed bump. The default database that comes with django is sqlite3 and while this suffices for tutorials and pre-production apps it does not fair as well for production applications, especially for hosting on popular virtual servers like Heroku. For my purposes I wanted to start with the right database even during test production because migrating databases is a challenge I would rather actively prevent. The popular database for web applications is postgresql because of the many advanced features that come included. I decided to go with postgresql as my SQL database of choice because it is recommended as a best practice from the book Two Scoops of Django.

I had many options for hosting my database and hosting this test production app, I could use a one year free trial of Amazon EC2 to host the application and scale appropriately for more users later on. I could push my application to Heroku and use their 5 mb of free storage. Or I could self-host the application and database through my own home-built server. Because I had a raspberry pi that I was playing with I decided to make this miniature $35 computer my home test server. This small computer might not be able to handle tens of thousands of users an hour but it has been known to be able to handle a few thousand users an hour. Because I have an 8gb sd card in this little computer and the energy cost to run it all year comes out to about $7 this actually makes economic sense for test production. It took a bit of time to sort out which database to use for django, setup my raspberry pi server, and understand the appropriate services to host one’s application but I am now ready to get back to coding my app!

Here are the tutorials I used on setting up a postgresql database using Ubuntu, and settting up my raspberry pi server!

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s