Nginx load balancing strategy

The answer:

Node polling (default)

  • Summary: Each request is sequentially assigned to a different back-end server

  • Scenario: Low reliability and unbalanced load distribution may occur. This scenario is suitable for static file servers

Weight Weight configuration

  • Description: Weight is proportional to the access ratio. The larger the number, the higher the traffic allocated

  • Scenario: This scenario is used when server performance varies greatly

Upstream LBS {server 192.168.159.133:8080 weight=5; Server 192.168.159.133:8081 weight = 10; }Copy the code

Ip_hash (fixed distribution)

  • Summary: Allocate the hash result of the access IP based on the request, so that each user has fixed access to one back-end server

  • Scenario: A single point is required for server service partitioning, service caching, and sessions

upstream lbs {

ip_hash;

server 192.168.159.133:8080;

server 192.168.159.133:8081;

}
Copy the code

Do beans in the Spring IOC container default to singletons or multiinstances

Answer: Singleton by default, Scope is determined by the Scope attribute

  • When a bean is identified as a singleton, spring’s IOC container contains only one of that bean
<! --<bean id="video" class="net.xdclass.sp.domain.Video" scope="singleton"> --> <bean id="video" class="net.xdclass.sp.domain.Video" scope="prototype"> <property name="id" value="9"/> <property name="title" Value ="Spring 5.x course "/> </bean>Copy the code
  • Ototype: multiple cases, calling the getBean method to create different objects, frequently creating and destroying objects causes a lot of overhead

Iii. Zabbix monitoring system has two monitoring modes, which are they? And briefly explain the difference between them, if there are thousands of servers, which monitoring mode should be adopted?

The answer:

The two modes are active mode and Passive mode.

The difference between:

  • Passive mode: Zabbix adopts passive mode by default. The agent waits for the server to collect data

  • Active mode: In active mode, the Agent sends data collected by itself to the server

If you want to monitor thousands of servers in passive mode

What is the difference between datetime and timestamp

The answer:

type Occupy the byte The scope of Time zone problem
datetime 8 bytes 1000-01-01 00:00:00 to 9999-12-31 23:59:59 Storage is time zone independent and does not change
timestamp  4 bytes 1970-01-01 00:00:01 to 2038-01-19 11:14:07 The store is time zone dependent and changes with the database’s time zone

Five, Mybatis level 1, level 2 cache usage scenarios and invalidation policies

The answer:

Mybatis level 1 cache

  • The scope of level 1 cache is SQLSession. If the same SQL query (same SQL and parameters) is executed in the same SQLSession, the database will be queried and written to the cache for the first time, and the cache will be directly fetched for the second time

  • HashMap local cache based on PerpetualCache

  • Level 1 caching is enabled by default

  • Invalid policy: If an operation is added, deleted, or changed between two SQL queries, that is, insert, UPDATE, or delete will be cleared after the SQLSession cache is committed. For example, sqlSession is closed or cleared

Mybatis level 2 cache

  • Level 2 cache is namespace-level cache. Multiple SQLsessions can share level 2 cache. If two Mapper have the same namespace, (even if two Mapper have the same namespace, The data from the two mapper’s SQL queries will also be stored in the same level 2 cache area, but will end up in a separate namespace for each mapper.

  • HashMap local cache based on PerpetualCache, with custom storage sources such as Ehcache/Redis, etc

  • Level 2 caching is disabled by default

  • Operation process: The SQL under a namespace is invoked for the first time to query information. The queried information is stored in the level-2 cache area corresponding to the Mapper. The second time to call the mapper mapping file under the same namespace, the same SQL to query information, will go to the corresponding level 2 cache to get the result

  • Invalid policy: After the SQL is added, deleted, or modified in the mapepr mapping file of the same namespace and the COMMIT operation is performed, the level-2 cache is cleared