preface

Not scholars, although exist, that the walking dead ear

omg

Because your company has asked me to make this part, so I stepped on the pit, the record, this provides a Linux centos version, remember, if it is installed in my side, when installation, be sure to step by step according to the following link to install, I just belong to the young do not understand, don’t listen to the old man advised, directly from the beginning of the installation, the results make me half a day, Young people should never steal, cheat, or down to earth.

The interview will be asked

What is load balancing?

  • To execute bai lines on multiple operation units, such as Web server, FTP server, enterprise critical application server, and other critical task servers, to jointly complete work tasks

What are the benefits of tomcat clustering?

  • Service performance, concurrency, and high availability.
  • Horizontal scalability of the object architecture.

How to solve the session sharing problem?

  • The third type of Nginx policy, IP streaming (of course, this also brings experience issues, not discussed here)
  • Discard session mode, use JWT, and start a Redis to save user information
  • Wait…

Install nginx

Refer to the link: www.cnblogs.com/hellojesson…

Nginx prospects

Nginx (Engine X) is a high-performance HTTP and reverse proxy Web server that also provides IMAP/POP3/SMTP services. Nginx was developed by Igor Sesoyev for the second most visited rambler.ru site in Russia (р а блер), the first public version 0.1.0 was released on 4 October 2004

Nginx load balancing policy

  • polling
    • Each request is allocated to a different back-end server in chronological order, one at a time for you and one at a time for me (two Tomcats).
  • The weight
    • Specify the polling probability, weight is proportional to the access ratio, used in the case of back-end server performance is not equal to 10, one is 8, one is 2, not in 10, the weight is 8, two is 2, just say the ratio problem,
  • ip_hash
    • Session sharing can be resolved because a user is already assigned to a Tomcat
  • Fair (Third Party)
    • Requests are allocated based on the response time of the back-end server, with priority given to those with short response times
  • Url_hash (third party)
    • Requests are allocated based on the hash result of the url so that each URL is directed to the same backend server, which is more efficient when the backend server is cached

Configuring Load Balancing (Tomcat Cluster)

There are two steps to getting directly into nginx.conf

  • The first step
    • The configuration file

  • The second step
    • The reference configuration

Remember to reload nginx after configuration. Note: both steps must be under the HTTP node.

test

Now there are three nodes with more than 30 concurrent requests. You can download a JMeter testNow close two and leave only one As you can see, the results are different and the throughput is increased

I’m just showing the throughput improvements here. If you want to see a different tomcat effect, you can show the ports on the page

It can be deployed on different machines, as SHOWN here on a single multi-node machine.

Refer to the address

Blog.csdn.net/qq_35119422…

At the end

Here the configuration is successful, install half a day, configure a few minutes… Accept criticism, I want to improve myself, come on. Talk a lot and grow.