Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to make the official cluster configuration instructions for Tomcat

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

What this article shares to you is about how to carry out the official cluster configuration instructions for Tomcat. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article. Let's take a look at it.

As we all know, in order to deal with a large number of requests, when a single Tomcat can not be satisfied, a series of measures need to be taken, such as diversion, clustering and so on.

When carrying out Tomcat clustering, the most important thing to pay attention to and implement is the sharing of Session data among multiple Tomcat instances, so that when nodes crash, other nodes can be used to respond.

With regard to the cluster, the commiter of Tomcat and the main maintainer Mark Thmoas do it on ApacheCon.

Cluster's sharing is described as follows:

When do I need to use Cluster?

In theory, never.

Why? that's what Thomas said.

Adds configuration complexity

Requires additional processing

Debugging is lot harder

And what you may really need is

Load-balancing plus sticky sessions

If a node fails, sessions will be lost

Clustering should be the last option.

In our previous article, we wrote about the principles and steps of using Redis/Memcached to store Session to achieve Session data sharing among multiple instances. (explain in detail the implementation principle of high availability of Session in the cluster)

In fact, Tomcat officially provides a built-in Cluster function without the support of a third-party plug-in.

Tomcat official cluster (Cluster) configuration instructions

The configuration of the entire cluster can be divided into the following steps:

Configure the Engine of each Tomcat instance and increase the jvmRoute value

Configure the application deployed in the cluster, modify its web.xml, and add configuration.

Use Apache for load balancing, and configure Session sticky and Map path to accept request forwarding. For the configuration of Apache, you can refer to the previous article

Look at Apache, that second-street dealer (1)

Look at Apache, that second-street dealer (2)

Modify the Cluster configuration of each Tomcat instance. The simplest configuration is to open the contents of the default comments:

This simplest SimpleTcpCluster uses memory to store Session data, and Tomcat instances across clusters back up data to each other. Heartbeats are detected by multicast among the instances.

The data transmission of session data is carried out through Tcp Connection.

The following figure shows the check information received by other instances when one instance is disconnected

Of course, we may also define various properties of Cluster, such as the Manager,multicast of Session and the implementation of data transfer. If we are worried that the Session is in memory, we can use other Manager implementations.

Tomcat provides three ways of Session sharing strategy:

‍ Session data persistence, saving data to a shared file system

Sesion persistence, data is saved to a shared database, and data is stored through JDBCStore

Using memory for sharing, using Tribes

‍ 5. Continue to use session in examples for feature checking. At this point, you will find that data can be shared among multiple instances without the support of other third-party plug-ins.

The above is how to carry out the Tomcat official cluster configuration instructions, the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report