ykdojo/editdojo

Decide how to deploy this app

ykdojo opened this issue Β· 30 comments

Python Anywhere's cheapest option might be just enough for now ($5/month for 1 GB disk, 2000 CPU-seconds per day with MySQL database).

Or should we use Heroku, Digital Ocean, Google Cloud, or anything else?

I think we should use Digital Ocean

Why Digital Ocean?

Because they have affordable VPS hosting plans.

If we deploy this to DigitalOcean, we need to make sure we're doing it right with a web server like nginx and gunicorn because we don't just use Django's built in development server. Why? Because it is a development server, and it is not meant for production. I would not recommend Apache (another web server) with mod_wsgi (an Apache module to host Python apps) because I've never gotten that to work. When I deploy an app to DigitalOcean, I always follow this guide to set it up with nginx and gunicorn. If we don't want to do that, our next best option is to go with Heroku or PythonAnywhere like @ykdojo said.

@Camnooten Thank you for the detailed explanation! I'm new to this, so this is super helpful to me personally.

You're welcome! I love adding my 2 cents to projects like this.

I think using Docker would open new directions for beginners and people on the intermediate level. Using docker with Digital Ocean would be the best for it will be easy to deploy it with Docker.

The benefits are simple,
It provides stabilization in a great way as you can run it anywhere and the installation do the running of the application would be same.
Also it is good in terms of isolation and security. We also don't have to install various other tools like Gunicorn for deploying as dockers containers are enough. More on docker could be found at http://docker.com

For a start I think pythonanywhere is a great fit for this projet, afterwards depending on how much money you're prepared to spend for the server I'd suggest DigitalOcean (cheaper) or any cloud solution (preferably AWS and GCP) (more expansive generally).

If we use DigitalOcean, the stack nginx + gunicorn (mentioned by @cameron-dahl ) with WSGI is a pretty popular / solid stack, we'll probably also need some deployment tools (I'd advise for ansible https://www.ansible.com/ or fabric https://github.com/fabric/fabric) ansible is more complete / robust / high-end but it needs some additional knowledge and some configuration.
Fabric is made in python and with python which is a plus and it is pretty useful for smaller deployment scripts or smaller projects. Cloud solutions have the advantage of having pre-configured environments and easier tooling for deployment.

Docker is a great tool but its complexity should be taken into account, I think it's a great tool to offer a stable development environment via docker-compose locally and it's also great to manage highly available applications through kubernetes and/or nomad but for our use-case I'm not sure it's the best / less complicated option available.

I have worked on Django before for my Web Application. For Deployment I used Digital Ocean. And as mentioned earlier by others, it is quite affordable and user

Digital Ocean has a server option dedicated to Django specifically. It uses Nginx and Gunicorn. Even though I knew nothing about hosting Django at that time, I was able to host my project in no time with the help of their guide and sentdex video tutorial

https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-18-04.
This is really helpful!

It also has access to certbot which helps you get access to SSL easily, Mekong your web application secure.

I could recommend AWS and Google Cloud since it’s free and easily scalable, but I found those extremely complicated. And they are mainly used for huge websites.

I don’t have much experience with Docker. But there are issues whenever I try to create one on my computer. I believe that Docker is not really required in this case.

I hope I was helpful.

BTW are you using SQLite or PostgreSQL?

digital ocean +1, I have use digital ocean for years, it stable and cheap enough, and have a independence VPS is convenient, you can do anything you want. and it can scale for config, if the app load have increase, you can Improve configuration easily

Hmm looks like Digital Ocean is pretty popular, at least among everyone here. Maybe I'll give it a try..

I'm thinking of using either MySQL or PostgreSQL for this project.

the both of MySQL and PostgreSQL is ok, I prefer to use mysql, because I have only used it, hah, but give it a try for PostgreSQL is a good idea too

I also have heard good things come of Digital Ocean. It was recommended to me by Isaac Ardis who is an ETC dev member. I lived with him in Hakodate for a couple months..

Okay, thank you, everyone!

I think I'll do some research on Digital Ocean, Heroku, and PythonAnywhere. I'll try and see which one's the best option for this particular project. I'll do some research on MySQL vs. PostgreSQL, too.

ZEDGR commented

Hello there!

I will like to give my humble opinion about the deployment of this awesome project/idea.

About the DB: I will suggest PostgreSQL. Because is the most favored database from the Python and Django community. Therefore you will see that for PostgreSQL the Django ORM has better support in many of its features.

About the Cloud Provider/Host: GCP and AWS is giving you 12-months free tier for many services. I think that GCP is a good place to start because it also offers extra $300 credits.

About Kubernetes & Docker I think that there are awesome technologies but there are "overkill" for now

Okay thank you! I will probably try using PostgreSQL for this then. Hmm based on that, GCP might be a good option from the cost perspective.

I highly recommend AWS, like @ZEDGR said - you get 12 months free usage for ec2 ( to host your server) and also 12 months free usage for RDS (host database). The free tier will be more than enough to build your MVP/prototype off of.

Check out more info at: https://aws.amazon.com/free/

AWS also has by far the best support in terms of stack overflow Q&A, making it much easier in terms of time spent debugging.

DB: I suggest PostgreSQL as well.

Jonathan

Okay, thanks Jonathan. I think I'll go with AWS then

I strongly recommend using Docker as it allows you develop in one environment and then deploy it anywhere without fuss. Something you should learn sooner rather than later. I too am fairly new to backend/web dev and am glad I took the time to learn it.

also take a look at AWS Elastic Beanstalk https://aws.amazon.com/elasticbeanstalk/ it handles deployment n scaling for you. And it doesn't have extra fee, you still pay only for the aws resource you use. c:

Okay sounds good! We are actually thinking of using Elastic Beanstalk now.

I've been trying to use AWS Elastic Beanstalk for a few days, but it's actually a huge pain to set up compared to Heroku.

I'm wondering if we should go with Heroku for now just to cut down the set up time at the beginning.

Also @Stunner, thanks for the info. I think I should learn it at some point, too. Dealing with different platforms (AWS and Heroku) has been such a pain...

Heroku is nice. Not on the production front but still offers good features. Plus anyone can use it without a credit card. I recommend using it for now so we could at least have a working example but in future use something like Digital Ocean or Docker

Hmm why is it not good on production?

If you're doing machine learning or other GPU-intensive work, Heroku might not be a great fit. With these lines in order I hope you understand. Also it's less scalable and more costly. It's architecture isn't good for production. Plus it gives you less customization.

I will give a +1 on DigitalOcean, i have some production servers hosted there.

I'd use Docker to containerize the application so that I'll be able to run the app in any environment very quickly without worrying about the configurations once it's set up once. I'd use Digital Ocean to host the app in the end. Personally, I find Digital Ocean more friendly than AWS. It's $5/month for 1GB of Memory and 1 CPU. I'd get SSL certificates for free with Let's Encrypt to have my website running on HTTPS because security first. I have my personal blog https://thetechgeek.io running on Digital Ocean. I also manage my DNS through Digital Ocean.