n5321 | 2024年8月30日 17:49

Tags: 运维


web server’s primary role is to serve web pages for a website.

If you want to host your web application on the internet, in many cases you will need a web server.

When you visit http://www.digitalocean.com, you begin with entering a URL that starts a request over the internet. This request passes through multiple layers, one or more of which will be a web server. This web server generates a response to your request, which in this case is the DigitalOcean website, specifically the homepage. Ideally, this happens quickly and with 24/7 availability.

网站的本质。

in reality most modern web pages today are a combination of many resources. Web servers act as an intermediary between the backend and the frontend, serving up resources like HTML and CSS files to JSON data, all generated dynamically on the fly or served statically.

If you intend to work with websites or online apps in any capacity, it is extremely useful to familiarize yourself with the basics of what a web server is, and how it works.

A web server handles requests on the internet through HTTP and HTTPS protocol, and is also called an HTTP server.A web server is distinct from other types of servers in that it specializes in handling these HTTP and HTTPS requests, differentiating itself from application servers (e.g. Gunicorn) and servers for other protocols (i.e. WSGI). 

好多新名词。

Here are some common tasks handled by web servers:

  • Serves HTML, CSS, and JavaScript files.
  • Serves images and videos.
  • Handles HTTP error messaging.
  • Handles user requests, often concurrently.
  • Directs URL matching and rewriting.
  • Processes and serves dynamic content.
  • Compresses content for optimized data usage and speed.
  • Enables browser caching for your static content.

In practical terms, here are some personal projects that would involve a web server:

  • You want to make a website.
  • You want to make an app that connects to the internet.

Goals of a Web Server

看一个Web server的goals对比一个电机的goals,or  ansys的goals,好像没有standard。

Web servers cater to an audience with expectations of speed, availability, reliability, and more. They have a shared purpose of serving content on the internet, and in order to be considered a viable web server solution, the following aspects must be considered:

  • Uptime: This refers to the time a web server is online and operational. Websites need to be online at all times to serve users, so a high uptime is the goal. This also translates to stability and predictability. When a user enters a URL or clicks a link to your website, the expected page should load every time, and at any given time. The only exceptions should be planned downtimes for updates or maintenance. A web server that is buggy or crashes at random times adversely affects your users’ experience.
  • Speed: Your web pages should load as fast as possible. Users want their request fulfilled immediately, otherwise you risk losing them. On a slow loading web page, even if the user sits through the first load, every subsequent long load will exponentially decrease their willingness to stay or visit again.
  • Concurrency: This refers to the handling of multiple requests coming in at the same time. Having too many people trying to visit your website at once seems like a good thing, but this becomes a real problem when load times slow down to a crawl and your whole server crashes. Your physical or virtual server only has so many resources such as RAM and CPU compute power, and web servers must use these resources efficiently.
  • Scalability: Scalability refers to either making your existing servers more powerful through vertical scaling, or adding more servers to your setup through horizontal scaling. As you grow your audience, you may reach a point where you need more than one or two small web servers.
  • Ease of set up: Getting a project up and running quickly is key to the iteration of your project. A straightforward and repeatable install process is important for the first web server you set up, and the multiple web servers afterwards when you scale up.
  • Documentation: Web servers are complex. The most common setups will get you on your feet quickly, but your needs will grow over time. Oftentimes you will need features that are not as commonly used. When that time comes, good documentation is essential to creating custom solutions for your needs.
  • Developer support: If the core developers are not committed to their own project, you shouldn’t commit your project to theirs. This includes both plans for long term support for their software, along with immediate short term support they provide in the form of bug fixes and patches.
  • Community support: A core development team will handle most of the heavy lifting, but a thriving community contributes to filling in the gaps. With open source projects, this can mean contributions to the actual code base, but a strong community will also answer your questions and help with your specific issues.


Structure of Configuration Files

对web服务器的关键就是对他们的配置?!

Web servers store their settings in configuration files. You can customize your web servers by editing these files.