Which service should we use to host Codidact?

Disclaimers:

  • The following assumes that we use Amazon Web Services (AWS) to host both the actual Codidact instance in the future and to deploy the develop branch.

  • I have almost no practical experience with hosting applications. The only websites that I ever hosted were either completely static or I had access to the actual hardware (it was a raspberry pi.) Please take the following with care and do your own research.

  • Days ago, I did not even know what AWS is other than what the name suggests. I know my ways with systemd and docker but I am far from being an expert, please read the following with care and do your own research.

Amazon offeres a ton of services to host web applications. Over the past few days I did some research and would like to ask which service we should use to host Codidact.

The following are options that I consider reasonable: (There are more services availiable like Amazon Lightsail but I think it is not viable for this type of application.)

  • EC2: This is a service from Amazon were you rent a virtual machine and gain full control over it. Services would be managed with systemd.

    Updating the service would have to be done manually for the most part. (That is not necessarly a bad thing, because it’s a lot simpler to just do something than to write a script that does it, but deploying a develop branch would be close to impossible.)

    I do not think this scales well, but it is easy to setup.

  • ECS (EC2): We also rent a virtual machine, but run docker on it. Each of our services becomes a docker container.

    This means additional work configuring the docker containers. (This would be a lot of work, do not underestimate this.) Updating would be done automatically either by pushing a new docker image or by commiting to the develop (or master) branch.

    A positive side effect is that anyone else can run the docker images on their own machine. We could additionally configure docker compose which would mean that anyone with docker installed could run docker compose up and have a complete Codidact instance running on their machine.

  • ECS (FARGATE): Very similar to ECS (EC2) but we do not control the virtual machine(s) that the containers run on. This is Amazons recommended way of running applications.

    The idea is that we say “run these docker containers” and then Amazon does all the heavy lifting. But we would have to make structural changes to our application to really benefit from this. (If Codidact becomes really large like some people seem to expect it, this would likely be the way to go.)

    However, the downside is that we can not host the database this way. Fargate does not support persistent storage on it’s own. We would have to host the database with one of the options above or use RDS. (RDS is Amazon’s database service which could be used to run a Postgres database, this is probably what we would do in this scenario.)

    Another downside is that we can only use a very limited subset of docker’s features because the individual containers might run on completely different machines and we really know nothing about the environment.

Personally, we should deploy the develop branch with ECS (FARGATE) since we do not need the database to be persistent and this seems to be the most “modern” approach. I have no idea what would be best for the actual instance though.

Again, I lack any practical experience to make a well founded recommendation.


Note. I am posting this shortly before going to bed so I likely won’t respond immediately.


Addendum

  • It should be noted that switching would be feasible from ECS (FARGATE) to ECS (EC2) and from ECS (EC2) to EC2 but the other way around would be difficult.
3 Likes

There are other options, too. AWS has a ridiculous number of services.

The simplest (and cheapest) way to start is to run a single EC2 instance on which we run everything - authentication server, application server, and database server. That’ll likely be fine for what we need to start with. As we start scaling or the sysadmin requirements become greater, we’ll want to start looking at other services - whether we use ECS and Docker, and whether we use RDS for a dedicated database server (or just a second EC2 instance). We’ll also need to start looking at things like load balancing.

Deploying a production app at scale requires a lot of sysadmin however you do it. The easiest way to start is a single EC2 instance, so I’d recommend we start there and use the experience of running that to work out whether we need any additional services.

2 Likes

Don’t forget to consider https://aws.amazon.com/elasticbeanstalk/

I highly recommend EC2 + RDS. RDS makes the job of setup, backup, administration, automatic failover (not needed initially but vital in a true production environment), expansion, etc. far easier than hosting the database ourselves (e.g., on an EC2 instance). If the instances were to stay small then hosting our own database on the same EC2 as the web server might make sense. But RDS can start small too and be expanded as needed.

Docker is an interesting concept. I have one project where I use it - and I frankly still don’t understand it and the person who originally set it up for my customer…never totally understood it either, as far as I can tell. Might it make sense at some point, particularly if we want to have containers of some sort to spin up new instances as needed? Yes. Do we need it now? No.

But RDS makes sense even early on. Migration of a database from a small server to a large server changes from

  • configure new server
  • make sure privileges are just right
  • put the web server into read-only mode
  • backup from old
  • restore to new
  • change credentials to point to new server
  • test to make sure nothing to lost in the process

to

  • Go into RDS admin page and change the size
1 Like

I suggested going with ECS because I thought that their Code Deploy service only worked for that, but it seems that it is possible to set this up with EC2 too. I’ll try to get something running this way.

That would run the service in a Windows Server environment. I might be a bit biased here because I prefer Linux, but web servers should really be hosted on Linux.

This really depends on how we do things. Currently, we have Entity Framework’s migrations which deals with all of that but the idea was to do “Database First” so I am a bit confused about whether this is just temporary.

No, where did you see this limitation? I dont remember this being the case while deploying these. Its just a wrapper for EC2 to make it managed automatically like the RDS

1 Like

There is only a “.NET on Windows Server” option:

http://static.asynts.com/2020/04/elastic-beanstalk.webm

They mean .net 4.5 which needs IIS to run which only does on windows.

Well if you choose Docker multicontainer platform then its ECS inside of a managed EC2. Same price as EC2 as I understand

What is the advantage of using it then? We could do ECS (EC2) manually with more control if I understand this correctly.

Load balancing autoscaling other stuff and you can connect to it just like a normal EC2 so its the same amount of control. Again its just a wrapper.

In the end of the day if you feel more comfortable doing just EC2 thats fine with me too

I’ll go ahead and try go get something running with EC2, we can try out the beanstalk thing later.

1 Like

(On Docker)

TRUTH!

Same here. I use it for some projects as well, and I mostly just keep it the same because I didn’t do the initial configuration, and it is based on a pre-built recipe someone else made.

1 Like