What is the difference between application server and web server?

前端 未结 27 1943
攒了一身酷
攒了一身酷 2020-11-22 17:03

What is the difference between application server and web server?

相关标签:
27条回答
  • 2020-11-22 17:14

    Drawing my conclusion from posts of awesome SO evangelists above, I conclude that both are software that resides on actual metal servers(physical servers). Both work hand in hand to get service to the end-user. Then, depending on the setup, we can choose what to call it, which means how to describe it depends on the actual setup in use. If they both reside on the same bare metal(physical server), we call it web and application server...simple! If on separate machines, obviously, we have two distinct bare metals(physical servers) at our hands. Then we can label these servers according to their function: one web server and the other application server.

    0 讨论(0)
  • 2020-11-22 17:16

    Actually Apache is a web server and Tomcat is an application server. When as HTTP request comes to web server. Then static contents send back to browser by web server. Is there and logic do to done, then that request send to the application server. after processing the logic then response send to web server and send to the client.

    0 讨论(0)
  • 2020-11-22 17:16

    From https://en.wikipedia.org/wiki/Web_server

    A web server is a computer system that processes requests via HTTP, the basic network protocol used to distribute information on the World Wide Web. The term can refer to the entire system, or specifically to the software that accepts and supervises the HTTP requests.

    From https://en.wikipedia.org/wiki/Application_server#Application_Server_definition

    An application server runs behind a web Server (e.g. Apache or Microsoft Internet Information Services (IIS)) and (almost always) in front of an SQL database (e.g. PostgreSQL, MySQL, or Oracle).

    Web applications are computer code which run atop application servers and are written in the language(s) the application server supports and call the runtime libraries and components the application server offers.

    0 讨论(0)
  • 2020-11-22 17:18

    While there may be overlaps between the two (some web servers may even be used as application servers) the biggest difference IMHO is in the processing model and the session management:

    In Web server processing model, the focus is on handling requests; the notion of "session" is pretty much virtual. That is to say that "session" is simulated by transferring the representation of state between client and server (hence REST) and/or serializing it to an external persistent storage (SQL Server, Memcached etc).

    In Application server the session is usually more explicit and often takes form of an object living in memory of the application server for the entire duration of the "session".

    0 讨论(0)
  • 2020-11-22 17:19

    Web server

    Run python -m 'SimpleHTTPServer' and go to http://localhost:8080. What you see is a web server at its workings. The server simply serves files over HTTP stored on your computer. The key point is that all this is done on top of the HTTP protocol. There also exist FTP servers for example which do exactly the same thing (serving stored files) but on top of a different protocol.

    Application server

    Say we have a tiny application like below (snippet from Flask).

    @app.route('/')
    def homepage():
        return '<html>My homepage</html>'
    
    @app.route('/about')
    def about():
        return '<html>My name is John</html>'
    

    The small example program maps the URL / to the function homepage() and the /about to the function about().

    To run this code we need an application server (e.g. Gunicorn) - a program or module that can listen for requests from a client and using our code, return something dynamically. In the example we simply return some very bad HTML.

    What's the business logic all the other people talk about? Well, since a URL maps to somewhere specifically in our codebase, we are hypothetically showing some logic about how our program works.


    Recapping

    web server - serves files stored somewhere (most commonly .css, .html, .js). Common web servers are Apache, Nginx or even Python's SimpleHTTPServer.

    application server - serves files generated on the fly. Essentially most web servers have some sort of plugins or even come with built-in functionality to do that. There exist also strict application servers like Gunicorn (Python), Unicorn (Ruby), uWSGI (Python), etc.

    Notice that you can actually build a web server with the code of the application server. This is done in some cases during development where you do not want to have a gazillion of different servers running on your computer.

    0 讨论(0)
  • 2020-11-22 17:20

    An application server is typically designed and deployed to facilitate longer running processes that will also be more resource intensive.

    A web server is used for short bursts that are not resource intensive, generally. This is mostly to facilitate serving up web based traffic.

    0 讨论(0)
提交回复
热议问题