Nginx and Dart Server - nginx

I learned Dart as my first web development language and produced my first web server, learned some Docker for deployment, but I keep seeing terms like apache, nginx, load balancing, etc.
Nginx big plus is that asynchronous but Dart is all ready asynchronous, I already serve static files with shelf, so what would be good reasons to learn and use nginx?

I don't know nginx myself but such servers are usually optimized for serving static resources like images or CSS or any other files with good caching. I t might be a good idea to not expose your application directly to the web for security reasons and shield it by a well tested server. Such servers also might provide some features like, caching, load balancing or virtual domains, and probably many more.

Related

Firebase hosting configuration

It might be a stupid question but curious to know. I have deployed an Angular app in Firebase hosting which loads the application faster. But whereas the same application deployed in the Windows server takes too long to load.
I would like to know what would be the configuration used in Firebase hosting**(RAM, Memory)**.
From the Firebase docs, I could able to see that it uses SSD-Backed hosting but where could i find the other details like how much RAM is used and does it uses any CDN.
There doesn't seem to be any configuration for the backend or if the resources are dedicated for a website listed in the documentation. Although it's not just about the server configuration especially since your app is a SPA and is just serving some HTML, JS files, so CDN seems to be making the difference here.
Firebase Hosting does cache your website on a global CDN and hence loading quickly everywhere. I'm not sure if you are using a CDN with your Windows server but if not then the difference sounds obvious (especially if your server is located far away from you). Firebase hosting also serves the files compressed using GZIP or Brotli compression.

Fundamentals of web-applications vs http server

I am required to preface this question with a disclaimer:
Im sorry if the question is silly and I am sure this information is on the Internet somewhere, but the reason why I ask here is because, I lack the knowledge to begin my research anywhere useful I don't need to read what an http server is, but rather what it's place in a backend environment is. Somehow, I was not able to find anything useful, which is why I believe that the idea I have of this issue at this moment is completely wrong.
I am fairly new to the ins and outs of how the web works. I believe I have good knowledge on how the http protocol works, frontend development and programming. But I don't seem to be able to connect the pieces.
What happens after the request reaches the http server?
Specifically, I can't seem to understand what exactly the back-end means. For example, if someone were to use Django as their backend framework -> what would be the role the application written in python(django) plays? Does it interpret the server request and if so, what are applications such as apache http server used for in a situation such as this?
I don't understand the link between the http server and the web application.
How would you get a web application to run on a server?
I understand that if you just need a web server to serve static html files than apache server would be enough. But how does it work when user data has to be inserted into the html file, or when the database has to be updated as a result of a http request.
I believe this would be the responsibility of the web application, but how do they interact?
tl;dr:
What is the role of an http-server vs role of a web application?
How do they interact?
To point is an http server software such as apache or nginx necessary?
What is the role of an http-server vs role of a web application?
An HTTP-Server is roughly an application that serves files to clients. Basically those files are of HTML type, thus contains hyperlinks that refers to other files.
A web application is just a set of related HTML files, that the user navigates through.
That is the base; as that model can be extended : files can be generated dynamically, of type different than HTML, etc.
How do they interact?
The server manages the files and send them to the client application (usually a web browser).
To point is an http server software such as apache or nginx necessary?
Sure it is, as it is the core infrastructure of a web application. Your web application is a set of HTML files that are accessed through a web-browser that ask the HTTP-server to obtain them.

Multi-host deployment of ASP.NET Core applications

I am quite confused as I haven't seen any blogs or instructions on how to host ASP.NET Core/.NET Core applications with HA and multi-host deployments. All examples are either:
1) One NGINX reverse-proxy, one Kestrel
2) One IIS reverse-proxy, one Kestrel
And both components on same host. In real-life production environments, you have LB maybe service discovery, multiple frontends, multiple backends, etc. But for this case there are no instructions whatsoever. So my questions would be for multi-host environments:
Do I deploy one IIS/NGINX as LB/Reverse-proxy, and redirect requests to Kestrels running on many separate VM:s, i.e. various different IP:s?
Or do I run an NGINX/F5 for load-balancing on one host, then route http traffic to various VM:s that run IIS+Kestrel, or just Kestrel? Is IIS required in this setup as NGINX acts as LB?
If I run IIS or NGINX as reverse-proxy, can they keep alive Kestrels on different VM:s, or does each Kestrel require exactly one IIS/NGINX to keep it alive? I.e. the Kestrel process must be on the same same host as the reverse-proxy?
All answers are very welcome, and thanks a lot in advance! :)
I'm running NGINX at the edge as a load balancer and for SSL Termination and multiple servers with IIS + Kestrel serving MVC. This is working well for us. You may not need it but I've found NGINX to be quite a bit more sophisticated and powerful than anything you could do with IIS. Obviously F5 or something would work as well. Previously I also ran for a while using AWS ELB load balancers which also worked fine, just didn't have much configurability. So depends on your needs.
As was mentioned already, IIS is needed on each box running kestrel to manage the process. You could do this some other way, but using IIS is the easiest.
I have a setup with one VM using (IIS as LB) + several VMs with (IIS + Kestrel). It's working fine for my usage, but I'm curious to see if other people have different suggestions. Then it depends on what you are doing, if you use encryption, machine key needs to be shared between VMs, you might also needs to share session between VMs (https://www.exceptionnotfound.net/finding-and-using-asp-net-session-in-core-1-0/), store things in database ...

Is using XSP4 from Mono behind Nginx as a reverse proxy production proof?

When reading the Mono docs, it says that XSP is not suited for production:
For quickly getting started, get familiar with Mono and ASP.NET, XSP
is the ideal solution. Keep in mind that XSP is a very limited server
and is only useful to get acquainted with ASP.NET and Mono, it only
support HTTP 1.0 and does not provide much extensibility or
configuration.
We are developing a REST API, and are thinking of the following setup:
Linux server
ASP.NET with Mono
Run in XSP4
Nginx as reverse proxy (which can handle load balancing, caching, static files, etc.)
But I'm wondering whether the remarks about XSP not suited for production only apply to the configuration part, or would it also be for performance?
Our performance demands are mainly for large requests, not so much for processing high number of requests (but if necessary, we could scale up with multiple instances of the application in XSP4).

Why use uWSGI and supervisor with a Flask app, and not just supervisor?

I usually run my Flask applications with uWSGI and an nginx in front of it.
But I was thinking that the same could be achieved with just supervisor and nginx, so I googled around and found a lot of posts on how to setup and the benefits of the uWSGI-supervisor-nginx stack. I've decided to turn to SO, risking getting axed online for such a question.
So what are the benefits of running a Flask application behind uWSGI, supervisor and nginx?
Why does apparently no one run Flask applications with only supervisor?
An app server such as gnicorn or uWSGI (used to host the flask applications) is used with nginx. nginx is a reverse proxy server which acts as a middleman. This helps with load balancing - handling multiples requests efficiently by distributing workloads over the resources. On top of this, supervisor is just used to monitor and control the server processes (gunicorn or uWSGI in our example).
From my understanding, the web server that comes with Flask (werkzeug server) is not production ready and should be used for development purposes only.
It's all about performance. Usually servers build into frameworks like Flask or Django are design for development environment, when you can quickly and easily reload code which you changed.
When you are running your application in production environment you don't have to worry about debugging and reloading your code often. Your biggest concerns are performance, security and configuration. During setting up production environment you can choose between uWSGI, Gunicorn , mod_wsgi and many others.
You can find plenty of blog posts with benchmarks between them and choose one which works best for you.

Resources