skip to Main Content

I have an app created in Django and React, but there are few problems that I am facing mainly :-

  1. As I will have a large database(postgres) exclusily for a single user, I am creating different AWS instance(t2.micro) for every user. (we are a startup so economical to use t2.micro)

  2. Whenever there is a new user then I have to go and manually install postgres, setup nginx and other important things and this is just for Django in EC2, I am not even talking about React in S3.

Solutions I am looking for :-

  1. If there is a way to automatically create an AWS EC2 instance and deploy backend also same thing for AWS S3 and deploy frontend, whenever there is a new user.
  2. There are a lot of things that I will be running when the backend starts namely Huey, Installing Postgres and Creating User for it, installing Redis, making migrations and other trivial stuff. Is there a way to automate every single thing?

Things to consider :-

We are a startup and can not depend on paid services really much.
Please do not ask me to use a single server for every user as we are
using 3rd party apis to get data and will face problems if there are
more users requesting from same IP, also it puts a lot of load on
the RAM.

Any suggestion would be greatly appreciated.

3

Answers


  1. Chosen as BEST ANSWER

    BTW This is the helper script I wrote if someone wanted to know -

    #!/bin/bash
    
    
    ip_add=`curl wgetip.com`
    
    echo $ip_add
    
    echo 'server {
    listen 80;
      server_name '$ip_add';
    
    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
    root /home/ubuntu/ThanosThriveAWS/Thanos;
    }
    
        location / {
        include proxy_params;
        proxy_pass http://unix:/home/ubuntu/ThanosThriveAWS/Thanos/Thanos.sock;
        }
    }
    ' >> /home/ubuntu/scripts/new_gunicorn
    
    sudo cp /home/ubuntu/scripts/new_gunicorn /etc/nginx/sites-available/gunicorn
    sudo systemctl restart nginx
    

  2. You can do everything you need by:

    1. Building an AMI. I would build an AMI with all of the packages pre-installed. You can even do this by creating an EC2 instance by hand, then creating an AMI from it.
    2. Using CloudFormation EC2 helper scripts. I would use EC2 init scripts to run all of the per instance scripting on an instance configured with the AMI created in (1).
    3. You can even use CloudFormation custom resources to copy objects to S3.
    Login or Signup to reply.
  3. I used travis for merges into master branch it redeploys your code whenever your master branch changes but I exactly don’t know they have an options you want, I recommend you to examine that site they may have a solution for you.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search