简体   繁体   English

AWS ECS Fargate + Python + Nginx

[英]AWS ECS Fargate + Python + Nginx

Hey,嘿,

I would like to start a small website that will be entirely handled in Python. I will be using the Flask framework for this.我想创建一个小型网站,完全由 Python 处理。我将为此使用 Flask 框架。 So far I had a lot of contact with AWS ECS and ELB service, but I admit, Python itself is still unknown to me.到目前为止,我接触过很多AWS ECS和ELB服务,但我承认,Python本身对我来说仍然是未知的。 That's why I have a few questions:这就是为什么我有几个问题:

1. I understand that from the point of view of a software engineer it is better to separate the backend and frontend - so it is best to create two separate Python projects based on Flask - one will be the API, the other the frontend, right? 1.我理解从软件工程师的角度来看,最好将后端和前端分开 - 所以最好基于 Flask 创建两个单独的 Python 项目 - 一个是 API,另一个是前端,对吧? Generally, both should be separate services in the ECS service I guess.一般来说,我猜这两者应该是ECS服务中的独立服务。

2. In such configuration do they both have to use some kind of WSGI server, like gunicorn? 2.在这样的配置中,他们是否都必须使用某种 WSGI 服务器,比如 gunicorn? Is this a good solution to run inside Fargate with multiple vCPU?这是在具有多个 vCPU 的 Fargate 内部运行的好解决方案吗?

3. There are quite a few questions and myths around Nginx for this solution. 3.这个解决方案围绕Nginx有很多问题和神话。 Until now I assumed that if I use Application Load Balancer it should be enough (after all it also acts as reverse proxy).到目前为止,我一直认为如果我使用 Application Load Balancer 就足够了(毕竟它还充当反向代理)。 Is it necessary to use Nginx as a sidecar in ECS, are there any benefits of this? Nginx作为ECS中的sidecar有必要吗,这样做有什么好处吗? Assuming that using Nginx would be advisable, should it be only for the frontend or also for API?假设使用 Nginx 是可取的,它应该只用于前端还是也用于 API?

Thank you really in advance for any supportive advice here - I know that I have asked for a lot of things.在此先感谢您提供的任何支持性建议 - 我知道我已经要求了很多东西。

In my consideration在我的考虑中

1- if you want to have a microservice concept you can separate you application with front-end and back-end each of them has their freameworks. 1-如果你想要一个微服务概念,你可以将你的应用程序与前端和后端分开,每个应用程序都有自己的框架。 for front-end you can use Angular , React , Vuejs and so on.对于前端,您可以使用AngularReactVuejs等。 Python is backend technology and you can write strong restfull api to communicate with you front-end application Python是后端技术,你可以写strong restfull api来和你前端应用通信

2- if you containerize your application with for example Docker and write Dockerfile for each service witch it is most common in microservice it is okay to run your container with any servers like nginx,apache or WSGI server(i did not work with this) then expose port (if it is needed) to be accessible 2-如果您使用例如Docker容器化您的应用程序并为每个服务编写 Dockerfile 这在微服务中最常见,那么可以使用任何服务器运行您的容器,例如 nginx、apache 或 WSGI 服务器(我没有使用它)然后公开端口(如果需要)以供访问

3- when you run your service in AWS Fargate it is possible to connect loadbalancer to your service and a service itself run tasks each task actually is one or more container with may be nginx server or something else, if you mean that it is normal to have nginx in your container. 3-当您在 AWS Fargate 中运行您的服务时,可以将负载均衡器连接到您的服务并且服务本身运行任务每个任务实际上是一个或多个容器,可能是 nginx 服务器或其他东西,如果你的意思是它是正常的在您的容器中有 nginx。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM