Project front desk construction

1. Project architecture design

Note: under the distributed condition, a web server obtains data from the back-end business server Obtain business data by remote calling through http request protocol, and return it in more general json mode in the future Realize data access across systems
And each node builds clusters of different sizes according to different user visits So as to realize the high concurrent access of users
After tuning, tomcat can support about 1000 hops per second, just increase the memory of tomcat operation

2 project web creation

2.1 description of Web project creation

1. Port number: 8092
2. Domain name: http://www.jt.com
3. The web server does not need to link the database
4. Packaging: war (JSP page)
5. Precautions: inherit the parent jt / dependent tool apijt common / configure maven plug-in

2.2 creating a JT web project


2.3 add Inheritance / dependency / Plug-in

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <artifactId>jt-web</artifactId>
    <!--Set packing method-->
    <packaging>war</packaging>

    <!--Add inheritance-->
    <parent>
        <artifactId>jt</artifactId>
        <groupId>org.example</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <!--Add dependency-->
    <dependencies>
        <dependency>
            <groupId>org.example</groupId>
            <artifactId>jt-common</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    </dependencies>

    <!--Add plug-in-->
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

2.4 importing static resource files

Description: import the static resource file

2.5 configuring web project startup items

2.6 description of web project configuration data source

SpringBoot features: out of the box!!!
Error Description: because jt web inherits jt, the automatic configuration of data source will be loaded when the web server is started However, because the web does not need to link the database, it leads to program exceptions

2.7 project startup effect

2.8 configuring nginx

Requirement Description: the user passes http://www.jt.com Access the server localhost:8092. After modification, restart nginx

#Build JT web server
	server {
		listen 80;
		server_name www.jt.com;

		location / {
			proxy_pass http://localhost:8092;
		}
	}

2.9 modify hosts file

3 disable https in Google browser

Step description:
1. Browser typing chrome://net-internals/#hsts

4. Add the configuration class of web

4.1 edit configuration class

Function: Spring MVC is required to intercept to html terminated request

@Configuration						  //Configure web XML configuration file
public class MvcConfigurer implements WebMvcConfigurer{
	
	//Open the matching suffix configuration, which is prepared for the jump of static pages in the program in the future
	@Override
	public void configurePathMatch(PathMatchConfigurer configurer) {
		
		configurer.setUseSuffixPatternMatch(true);
	}
}

5 working principle of search engine

5.1 about html description

General search engines can only retrieve static page information, not retrieval jsp and other dynamic page structures, so generally in order to improve the exposure of the website and make the products easier to be retrieved by users, so the general product pages are html

5.2. How search engines work

Requirement: assuming there are 100 million records in the database, how can the search engine retrieve all the data after 1 second and return it effectively?
Inverted index: search the position of articles according to keywords

5.3 why can search engines only record html page

5.4 pseudo static

Pseudo static is relative to real static. Usually, in order to enhance the friendliness of search engines, we generate static pages from the content of articles, but some friends want to display some information in real time. Or you want to use dynamic scripts to solve some problems. You can't display the website content in a static way. But this will lose the friendly side of the search engine. How to find an intermediate method between the two? This leads to pseudo static technology. Pseudo static technology means that it is displayed in the form of static pages such as html, but it is actually handled by dynamic scripts such as ASP.
Summary: Based on HTML ending "dynamic page" Scripting Technology (.JSP/.html)

Expand knowledge

The introduction of cache may cause the following problems under the premise of high user experience:

Cache penetration

Features: in the environment of high concurrency of users, accessing data that does not exist in a database is called cache penetration!!!
Solution: limit the number of visits per unit time and block the IP address Gateway filtering

Cache breakdown

Features: some high - frequency access data will cause cache invalidation due to improper operation So that a large number of users can directly access the database (one)
Solution: configure multi-level cache

Cache avalanche

Features: due to the high frequency of keys in redis, a large number of keys fail at the same time It causes the user's request to directly access the database, resulting in the risk of downtime (flushAll)

Solution: configure multi-level cache and set different timeout

Posted by gr8dane on Tue, 17 May 2022 08:36:41 +0300