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. So far I had a lot of contact with AWS ECS and ELB service, but I admit, Python itself is still unknown to me. 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? Generally, both should be separate services in the ECS service I guess.
2. In such configuration do they both have to use some kind of WSGI server, like gunicorn? Is this a good solution to run inside Fargate with multiple vCPU?
3. There are quite a few questions and myths around Nginx for this solution. Until now I assumed that if I use Application Load Balancer it should be enough (after all it also acts as reverse proxy). Is it necessary to use Nginx as a sidecar in ECS, are there any benefits of this? Assuming that using Nginx would be advisable, should it be only for the frontend or also for 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. for front-end you can use Angular, React , Vuejs and so on. Python is backend technology and you can write strong restfull api to communicate with you front-end application
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
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.
Related
I have created a python notebook with many widgets connected to many dataframes and I can deploy it fine with Voilà on my local host. I would like to understand what is in the simplest way possible I can share the link with people on my internal network and also outside.
I read my articles suggesting to use Heroku, Binder (with GitHub), Google App Engine, PythonAnywhere...
So my question is what do you suggest for my needs? I would like to keep the interface generated with Voilà and I was hooping not to share it public or at least not to everyone.
Thank you
There are services which allow you to 'essentially' put your localhost on the web i.e. they allow people to remotely access a website hosted as localhost on your machine. I have personally used https://ngrok.io. I've also heard of localhost.run which is a recently launched service. With these services, you will get a URL that you can now send to the folks who you would like to access your service. If you do this, your local machine (the one hosting the service) has to be on.
You can also go with the option of deploying to a host like Google App Engine (GAE), PythonAnywhere, Heroku, etc. But you should add some form of authentication so that access is only granted to those who provide that authentication.
My post has been considered as a duplicate, but this is not...
This question How to access mongodb on GCE with GAE does not answer to how can I edit firewall rules of GCE for an GAE application. It mentioned only about how can how to get te URI to set on an app running on GAE.
This is not my issue. I'd like to make a firewall rule for a deployed GAE application, I already have the external IP of my GCE set on my GAE app.
For example : on my GAE server I can make a dig to get the local server IP (for example : 35.187.8.45), so I can add it to my GCE firewall rules, then in my GAE shell I can make a "python main.py" and access to my mongodb on GCE.
But when I run a "gcloud app deploy", it does not run on the same server anymore. So I have to know on which one to edit a new firewall rules and allow the deployed application.
Hope to be clearer this time...
Well, I finally find a way to achieve what I wanted.
The way to go is to create a GAE flexible, thus, I can find under Instances my diffent VM which have an IP and add them to my GCE (where is my MongoDB) firewall rules.
What I understand of it, but maybe I'm wrong, is in flexible environement, application of GAE is deployed in several VM, running on compute engine, which is not the case for standard environement.
So, for people needs same, and doesn't want to expose their app to whole internet (0.0.0.0/0), go to a flexible environement
I am a newbie in web development, I am an energy engineering student trying to make a project, so I apologize if I say something weird.
I've made an application using Dash (python). And now, I would like to deploy that app in my server. I have a remote server (debian, adress.com, IP, opened ports: 80 and 443...) with my ssh public key and all the required stuff.
I have read all the official documentation in the plotly dash page, and also in flask's, but I dont understand very well the thing. I need either Heroku, OpenShift... And I dont understand very well how them work.
Could you please recommend me an easy tutorial (for dummies!) or give me advices/examples about the deployment? I would really apreciate I've searched the Internet a lot, but I can't figure it out.
You describe two options:
1. using your own server to host your app and
2. using a service which will host your app (heroku, etc.)
Using your own server to host your app
You need to decide for a web server, which is serving your page on your server. A host will not magically answer on any port. There is for example apache, nginx, etc... After having chosen one, you need to find a tutorial: how to run your flask app on [yourwebserver] or something like that.
Suppose you have chosen apache, you will find something like this:
https://jackhalpinblog.wordpress.com/2016/08/27/getting-your-python-3-flask-app-to-run-on-apache/
(In this case, you will have to figure out how to run your flask app with python3 instead of python2, if you are running debian)
When your page serves your page, you need an ssl certificate in order to make use of your domain. An easy way of doing this is https://letsencrypt.org/getting-started/ (there are probably other similar services)
Using a service, which will host your app for you (heroku, etc.)
Alternatively do not host you app on your own server, but on heroku, aws, gcd, etc., in my opinion this is much easier than hosting it on your own server. The documentation on hosting service websites is normally very good.
For heroku a good starting point would be here:
https://devcenter.heroku.com/articles/getting-started-with-python. Nevertheless the other services are easy to use as well, i just use this as an example.
I need to implement a simple web service in python - it's my first experience with web services and REST APIs so I want to undertand what environment and tools would fit my needs. In my web service, I need to read some data from a database, do some simple logic, and support a GET call from another application (qualtrics).
I read and implemented a simple test web service with python using some useful blogs such as: Building a Basic RestFul API in Python | Codementor
but I need a real server so that I could call the API from external applications.
As I'm looking for a long term solution, I thought that using AWS EC2 instance may be a good solution for a server. I tried to implement it using some guidelines in blogs such as: Deploy a Flask app on AWS EC2 | Codementor
However, as I'm new to this and encountered some implementation/editing errors (e.g. handling of the wsgi file) and as I'm a windows person and the ubuntu stuff are not always easy to get used to, I was wondering what is the best framework for my needs?
Is there any recomended flow in which I'll be able to implement my simple python code and connect it to a small server (either AWS EC2 instance or any other recomended one) in a more convenient way?
Another important note - I will need to run it only from time to time, this web server and web service should not be contantly live (that's why I thought that aws virtual instance would fit best).
To begin, my recommendation would be to look at Elastic Beanstalk, Fargate and API Gateway with Lambda.
You can use Elastic Beanstalk to easliy provision out-of-the-box AWS environment to host your python app in Flask with minimal configurations required:
Deploying a flask application to Elastic Beanstalk.
The other thing to consider would be to develop your python app as a docker container using, e.g., tiangolo/uwsgi-nginx-flask as the base image. This would allow you to easily work with in on your localhost, and then just move your image to AWS for hosting.
You can host it on Fargate to save time on configuring container instances, or on Beanstalk as well which also supports docker.
Yet other choice is to go fully serverless and develop your Python REST api using API Gateway and lambda.
I have a few (python) microservices which serve as the backend of my web application.
I'm willing to deploy the microservices to some cloud platform (either AWS, Azure, etc).
Should I create 1 VM and deploy all the microservices on the same server, with different ports? If I should create 1 VM for each microservice, should they speak with each other through public IP?
Thanks in advance!
The short direct answer for you is YES. You can do that, directly to deploy all microservices on one VM using different ports is feasible. And you can set different public ports for a public IP in the NSG of networking setting on Azure VM.
However, it's not make sense and break the microservice architecture. But per my experience, you can try to use Nginx as reverse proxy or use Docker (even with Kubernetes) to manage yours microservices on a VM in the development or testing stage.
To use Nginx as reverse proxy to expose the same port with different request path to access the backend microservices with different ports. It will help to reduce the cost of migration in future.
Recommended. To use Docker with Kubernetes to deploy different microservices images like using different VMs. These microservices insider container bind the same port, and expose different ports outsider container. Then, to use Nginx as reverse proxy for these containers, too. In future, it will help to migrate them to Azure Kubernetes cluster easily, and get better price than VM.
Hope it helps.
Creating 1 server would kill the purpose for microservices. Services are deployed across
multiple nodes(servers) , more specifically multiple AZs (availability zones)
It also depends if you have stand alone services deployed directly using code behind server or are you using containers ? Because both will have different approaches to deploy and maintain.
As have said #Imran Arshad Deploy some microservice in one server is a bad idea.
If you are in starting phase of a project, you can use the ECS service of AWS with 1-2 ec2 instances. In this way, you can have HA at a low cost.