The focus of Tomcat and Nginx

Tomcat

Tomcat is an open source WEB application server developed by the Apache Software Foundation. Similar functions include JBoss and Jetty. However, Tomcat is written in Java and needs to run on a Java virtual machine, so you generally need to install JDK first. Provide operating environment.

There are several ways to deploy Tomcat

  1. Put the web project directly under webapps, and Tomcat will automatically deploy it.

  2. Configure the node on the server.xml file and set the relevant attributes.

    <Context path="/wuli" docBase="C:\Users\Administrator\Desktop\wuli_war_exploded" />
    
  3. Under conf/catalina/localhost, create an xml file whose name is the name of the site and configure the way to write XML.

    <Context path="/wuli" docBase="C:\Users\Administrator\Desktop\wuli_war_exploded" />
    

Tomcat working mode?

  • There are three types as a servlet container
    • Standalone servlet container
    • In-process servlet container
    • Out-of-process servlet container
  • Requests to access Tomcat can be divided into two types of work modes
    • As a standalone server: The request comes from a web browser.
    • As an application server: The request comes from the front-end web server.

Tomcat tuning

  1. Separate dynamic and static, do not parse static files, only parse dynamic files such as JSP/Servlet.
  2. Configuration file optimization, server.xml, such as setting the minimum number of idle threads, upload timeout time, compression type.
  3. JVM optimization.

Nginx

Nginx is a lightweight HTTP server. It was developed by Russian programmer Igor Sisov. It has excellent performance. The official test nginx can support 5W concurrent connections, and the consumption of resources such as cpu and memory is very Low, the operation is very stable.

Features

Reverse proxy

Proxy server, after receiving the request, the reverse proxy server selects the internal target server, and the internal server passes the result to nginx after processing, and nginx returns the result to the client. At this time, the reverse proxy server and the target server are external servers that are exposed Is the proxy server address, hiding the real server IP address.

Static resources

Nginx, as a static resource server, can achieve dynamic separation

Load balancing

The proxy server distributes the received requests to each server in a balanced manner. Load balancing mainly solves the problem of network congestion, improves server response speed, achieves better access quality, and reduces background server concurrency pressure

The difference between Tomcat and Nginx

  1. analyse file

    Tomcat is an application server that parses dynamic resources.

    Nginx is an http server that parses static resources.

  2. use

    Tomcat is often used as a servlet container.

    Nginx is often used for reverse proxy servers, static resource servers, and load balancing servers.

  3. performance

    The concurrency of Tomcat is between 200-400.

    nginx supports 5W+ concurrency.

Guess you like

Origin blog.csdn.net/numbbe/article/details/109322411