Toncat is the world’s most famous Lightweight Application server based on the Java language. It is a completely open source and free Servlet container implementation. At the same time, it supports the processing of static resources such as HTML and JS, so it can be used as a lightweight Web server. As the beginning of the book, this chapter will give a brief introduction to the development of Tomcat and the basic installation and use of Tomcat, so that readers can get a preliminary impression of Tomcat. It mainly includes the following aspects.
- Introduce Tomeat
- Tomeat overall architecture
- Catalina
- Coyote
- Jasper
- Tomeat configuration management
- Web Server Integration
- Tomeat cluster
- Tomeat security
- Tomeat sex can be tuned
- Tomeat additional features
Tomeat overall architecture
As a well-known lightweight application server, The framework design of Tomcat (such as life cycle management, extensible container component design, class loading method) can provide a very good reference for our server middleware design and even application system component design. This chapter provides an overview of the overall architecture of Tomcat. Through this chapter, you can understand the basic concepts of Tomcat components and lay a good foundation for further understanding the components described in the following chapters.
Catalina
This chapter introduces Tomcat’s Servlet container implementation – Catalina. For Tomcat, the Servlet container is its core component. All JSP/ servlet-based Java Web applications need to rely on Servlet containers to run and provide services externally. Through Catalina, you can get familiar with how Tomcat works, including its various application forms. Deployment scenarios and Servlet specification considerations.
Coyote
Catalina is a Servlet container implementation provided by Tomcat. It processes requests from clients and outputs responses. However, only the Servlet container server cannot provide services to the outside world. The linker needs to receive the request from the client and parse it according to the established protocol (such as HTTP), and then submit it to the Servlet container for processing. It can be said that the Servlet container and the linker are the two core components of Tomcat, which form the basis of a Java application server.
This chapter mainly introduces the implementation of the linker provided by Tomcat, including its supported protocols and IO modes.
Jasper
To improve processing performance, the application server caches JSP classes and instances, periodically checks for updates to JSP pages, and recompiles if changes occur. Since ISP pages have separate classloaders, recompilation does not cause the entire application to reload, which is why we can update JSP pages at run state.
Let’s take a look at Jasper, Tomcat’s JSP engine.
- Jasper profile
- JSP compilation
- Principle of JSP compilation
Tomeat configuration management
While working with Tomcat, it was inevitable to customize its configuration to meet our requirements. These configurations may be JVM-specific, such as memory, system properties; It may be server-specific, such as ports, virtual hosts, IO, or Web application-specific, such as URL mapping, filters, and so on. These configurations can involve many aspects, such as development constraints, deployment architecture, performance, security, monitoring management, and so on. Therefore, whether the project is in development or already in production, it is important for both developers and architects to understand the configuration of Toncat to take advantage of the various features of Tomcat.
Web Server Integration
Although application servers such as Tomcat support HTML, JavaScript. The processing of static resources such as images can be used as Web servers. However, with the increase of concurrency and complexity of application deployment, the traditional Java-based application server can hardly play the role of Web server. This is mainly because application servers generally have relatively poor performance in handling static resources, whereas Web servers can take full advantage of the local IO of operating systems. Meanwhile, for static resources, Web servers can improve their access performance through various ways such as caching. In addition, Web servers generally support being front-loaded request schedulers to support load balancing. All of these things are missing from Java-based application servers.
Tomcat cluster
Clustering is an essential feature of application servers. Whether it is a high concurrency Internet application or a business-heavy enterprise application system, its deployment architecture needs to consider the support of cluster to varying degrees. Cluster not only requires the application server to provide related management, synchronization and other functions, but also requires the corresponding scalability of the application system, which puts forward higher requirements for the application system architecture.
Tomcat security
Security is one of the most important concerns in system architecture. Generally speaking, security covers network security, data security, operating system security, server security, application system security and many other aspects.
As an application server, Tomea can meet the security requirements of most scenarios by default, but it needs to be configured in a number of ways in relatively high security environments. This chapter introduces the security aspects of Tomcat from the following aspects. Some configuration and function realization.
Tomeat performance tuning
Performance is always important, but as Donald Knuth says, “premature optimization is the root of all evil.” We can arrange related performance stress tests at key points of the project (before the above line), which can avoid common performance problems (such as N+1 queries, etc.) in the development process. However, as for how to optimize the system and what performance indicators to achieve, We should consider the project situation comprehensively (such as the requirements of the project on the number of concurrent users and access response time, as well as the reasonable forecast of the future business development, etc.) and try to avoid excessive optimization. Developers who spend hours tweaking the performance of an infrequently used widget often discover that the real performance problem came from somewhere else.
Tomeat additional features
Finally, we’ll focus on a few features that Tomcat provides. These features are not complicated, but they are widely used in some application scenarios.
Thank you for your reading, but due to the limitation of the document about Tomcat architecture analysis in the form of pictures to show you, interested in this Tomcat architecture analysis friends pleasePlease forward it and add assistant VX: Yunduoa2019 after following it or scan the qr code below and follow the guidance of the assistant to obtain it by yourself