JAVA interview His influence (7): distributed architecture, micro-management services

80.session sharing scheme 
1. Broadcast: May cause intranet network storm, intensive broadband network 
2.IP_hash: nginx configuration and the same fixed ip find the same server, this program will result in poor service 
3. Use a third-party middleware (database, redis), we are using redis

 

 
82. The high concurrency issues: the index database synchronization
1. hard coded: increasing the index database synchronization code corresponding code. However, this method of coupling is too high, originally unrelated systems coupled together, likely to cause unpredictable errors, the electricity supplier is taboo project. 
2.spring of aop: write an indexed database synchronization method of using aop form of the method and its data updated database link. In this way also cause coupling. 
3. Message Queue: However, this method will cause a problem, and that is the message of consumer failures.
: Solve communication problems between the two systems. 
Message consumption failed: centralized index database synchronization, do a timed task. On the server where the message queue plus a database, we are using redis cache. A message queue for each message sent, this message will be persisted into the redis. Then the timing (we are in the evening, when a small amount of the user) will be taken from the message list redis out batch synchronization index database.

 

 
 
85. Why call between the service layer activeMq would be a message in the controller layer?
Because the transaction! If you are sending a message in the controller layer, the controller layer calls the service must have completed a transaction commit operation. If you are sending a message in the service layer, then the transaction may not have committed, it will cause a null pointer exception.

 

 
86. Why use an index database synchronization queue activemq the way? (The benefits of using the queue) 
1. The need to consider the message has not been Consumption 
2.queue, comes with persistence mechanism 
3. Business is more single, relatively safe

 

 
87. Message Queue problems: when the index database synchronization, content delivery Why is product information, but not for merchandise id?
Transfer of goods id: 
Benefits: The transfer of goods is id, less content transmission efficiency is relatively high, the message will not clog. 
Cons: Consumer goods need to query the database again out information, and an interactive database and more. 
Transmitting product information: 
Benefits: so consumers do not need to re-query the data from the database commodity information, reducing the interaction with the database. 
Cons: transmission of information is a commodity, transmission content is relatively small (reason: text information in the network transmission occupied a minimum of network resources), may produce message congestion problems, but due to send our message is not continuous, not there are too high concurrency (reason: the need for the operator's platform after approval sent when sending messages.)

 

Guess you like

Origin www.cnblogs.com/newbie27/p/10835998.html