By using AWS re:Post, you agree to the Terms of Use
/Wordpress in Docker container on Fargate/

Wordpress in Docker container on Fargate

0

Hi all, A newbie here.

I want to run a small personal Wordpress blog (more like a CV/portfolio page with little content) on AWS. I am interested in learning how Fargate/containers work, that's why I set myself a challenge to run this blog as a container rather than on EC2.

I have configured Docker desktop and successfully run the WP container (based on WP and mySQL images) locally.

Now my idea is that I need to deploy this container to AWS (Next steps to register a domain via Route 53, etc, but I am not concerned about it now).

Questions:

  1. I googled first, but most of the proposed solutions for running a Wordpress site in a container on AWS mention also using EC2/RDS/S3. Why? My understanding is that if I run both WP + MySQL in a container, I shouldn't need any other AWS services.

  1. What would be the costs for running a simple container like that? In the Pricing Calculator one of the parameters is the length of the task, and I'm somewhat confused here. My idea is that I just start the container once and it keeps running till it fails for some reason, and then it just gets restarted.

Thank you!

Regards E

2 Answers
0

Hi

I understand that you would like to host a Simple WordPress application into the Cloud infrastructure. before jumping into your questions, I would like to add my opinion on your request. If you want to host an Simple wordpress application blog/portfolio you can use a small Ec2 instance like t2,t3.micro instance to host your website,

How to host Wordpress in Ec2 AWS ?

Solution 1:

Solution 2:

The above solutions 1 & 2 doesn't have scalability and HA, as you said your application you can use any of the above based on your preferred pricing.

Answers to your questions:

  1. Yes you can deploy Wordpess and Mysql in container, You can leverage AWS ECS with fargate or EKS Container based solutions. When you are deploying the Wordpress container and Mysql you need to think about persistent storage so if container is dead you shouldn't lose the data in this case for both containers you can use EFS as persistant storage when you are deploying the Containers.

You can find the AWS Example to deploy the Wordpress https://aws.amazon.com/blogs/containers/running-wordpress-amazon-ecs-fargate-ecs/

  1. Pricing Calculation for the Wordpress and EFS for 2 pods Example in Ohio region, Please check the Calculation link https://calculator.aws/#/estimate?id=e6da60cc5cba559e452e6829a3fcf121fb0562ae. this link will expire in 3 years.

If you still have any questions, I am happy to help you.

Thank You GK

answered 2 months ago
  • HI GK

    Thanks for your reply. Yes, your solutions make sense for my small project, a personal blog that doesn't need HA/scalability. Most likely I will go with the solution #2 as the most cost effective.

    However I am somewhat confused about the price. I checked your link and your estimate is ~ $20 per month, with 24 hr task time. While a reply from another member above suggests the running costs would be over $300 a month.

    Could you please explain?

    Thanks!

  • Hi

    Yes you are right, The estimation was 24hrs before and not 30days, Correcting my Calculator link https://calculator.aws/#/estimate?id=ba8bd55243bbcb7aba819277778463b2f51bf32b

    You can see full information here:

    Unit conversions management events Number of tasks or pods: 2 per day * (730 hours in a month / 24 hours in a day) = 60.83 per month Average duration: 30 days = 720 hours Pricing calculations 60.83 tasks x 0.25 vCPU x 720 hours x 0.04048 USD per hour = 443.23 USD for vCPU hours 60.83 tasks x 0.50 GB x 720 hours x 0.004445 USD per GB per hour = 97.34 USD for GB hours 20 GB - 20 GB (no additional charge) = 0.00 GB billable ephemeral storage per task 443.23 USD for vCPU hours + 97.34 USD for GB hours = 540.57 USD total Fargate cost (monthly): 540.57 USD

    Please let me know, if you have any questions Thank You

    GK

  • I hope your clear with your questions, If you need any help Let me know

0

Answers below. As long as you understand that when the container running the MYSQL DB is killed (for any reason), you will lose your data. When it restarts, the MYSQL DB will be like a fresh install of WP. Hence why most solutions have the DB on EC2 or RDS, so you dont lose data. A more easier solution, based on your use case may be Lightsail: https://aws.amazon.com/blogs/compute/launching-a-wordpress-website-using-amazon-lightsail-containers/

  1. It really depends on what you want. If you just want to use Fargate, and run both WP and the DB in containers, then you dont need other services (RDS). And then if you choose this option of using Fargate only, you can choose to have a single container (less preferred), with both WP and a DB, or separate containers for each (more preferred). If you have separate containers for WP and the DP, you can set Fargate to spin up multiple tasks/pods of the WP container (but then will need a shared filesystem like EFS), but only one of the DB (for obvious reasons, otherwise you going to have inconsistent data or data loss). But I suppose if you dont expect much traffic, and only you are adding content, then a single container for both could work, and again Fargate set to run only one task/pod, then that may be ideal for your scenario.
  2. Correct, Fargate pricing is based on time the task runs, so if you to run it for an entire month, then set the duration to the number of minutes in a month: 43800. So a .25 vCPU task will cost $324 for a month. (I dont know if .25 CPU will be enough for WP and a DB though...)
answered 2 months ago
  • Hi Yusuf Thanks for the answer. I indeed didn't realise that the running costs for a container would be that high, $300 a month definitely doesn't justify my experiment. Could try spinning it off for an hour or so just to see how it works though.

    Appreciate you explaining the theory!

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions