For many years I have been using a VPS. Before that, I used shared hosting providers where you get an account but no real access to configure things. I manage personal projects and some sites for customers. In most cases these are small sites, nothing too fancy, no high traffic.

The VPS worked fine. I was using GoDaddy and honestly had no problems. The only thing I had to do was upgrade the instance once because I was running tight on disk space. That upgrade also gave me more CPU, and after that the capacity was much higher than what I actually needed.

So why move?

The Real Reason

I have worked with AWS before. Many years ago I managed a migration from on-premises dedicated servers to AWS. We were reaching a point where we could not scale well with the physical servers, and the cloud was taking form at that moment. I configured everything: the scaling groups, the instances, all of it. AWS is not unknown to me.

But after that experience, I never had full administrator access to another AWS account. In the jobs that followed, I only touched very particular things, or connected to use S3, which is what you use most often. I did not have the chance to go deeper.

I decided to move these projects to AWS to have that chance. To explore Terraform and Ansible, which were completely unknown to me before this. The best way to learn is to implement while you study, and that is what I did.

I know this sounds overkill for sites that were already working fine. But I took it as a learning experience with real responsibility. These sites are in use. I could not just break things. I had to learn while keeping everything running.

Why Not Kubernetes

Kubernetes was on my radar. I have plans to study it. But for this particular case it was really overkill. At the end I have only one EC2 instance. Kubernetes is not necessary for that.

Even considering that this is a learning experience, the cost was more than I wanted to invest every month just for learning. Almost $100 extra per month was unreasonable and out of my budget.

I have seen tutorials about running Kubernetes on local machines. I will probably explore that path for learning. But for this project with real sites, it did not make sense.

Why I Used an Application Load Balancer

The ALB was not strictly necessary either. I could have pointed the domains directly to the EC2 instance. I could have configured Nginx with virtual hosts to route the requests, like I was doing on the VPS. I could have kept using certbot for SSL certificates.

But using the ALB gives me a few things.

First, I get to learn this way of organizing requests. It is knowledge I did not have before.

Second, there is a layer of separation. The domains point to the load balancer, which will not change. The EC2 instance might change its URL at some point. Maybe I replace it, maybe something happens. With the ALB in between, I do not need to update DNS records for every site if that happens.

The ALB costs around $15 per month. For what it gives me in flexibility and learning, I decided it was worth it.

One thing I have not explored yet is Route 53. I am using Cloudflare for DNS on most of my sites and it works well. Route 53 is there if I want to investigate it later.

Why Docker Compose Instead of ECS

Regarding costs, one important decision was about container orchestration. I could have used ECS with Fargate, which is simpler and convenient. But the cost was considerably more than just managing Docker Compose myself.

There was also a dilemma. While investigating ECS, the main recommendation was to have a NAT Gateway for security in production. That would cost around $30 more per month. I could have worked without it, but it was not the ideal setup. I preferred not to make that compromise.

So I decided to go with Docker Compose on the EC2 instance. I will evaluate ECS again in the future as an improvement, but for now this was the best option considering cost and best practices.

Instance Sizes

I use small sizes for both the EC2 instance and the RDS database. I could not go smaller than that, especially for RDS. With the managed database handling multiple sites, going smaller would have caused resource problems.

What Is Running

The setup handles mostly two types of sites. Laravel, which is my main framework as a developer. And WordPress, which I have used since forever. I started working with WordPress around 18 years ago, and despite it not being my primary framework, I have never stopped being involved with it.

There is some customization in the configuration for each type. I also have some pure PHP sites and static sites hosted on S3.

I am working on handling JavaScript applications too, for some other experiments and customer work. That will come soon.

Monitoring

This is an ongoing experience. I have CloudWatch alarms configured to monitor problems and resource usage. I also have some Lambda functions that send me reports about certain sites.

I will be monitoring everything and looking for ways to reduce costs further.

The Code

Here is the repository: https://github.com/raulprdev/aws-shared-hosting

Take a look if you find this interesting. Maybe it gives you ideas for your own setup.