Learn to become an online project extension (for interviews)

The homepage uses Vue, and the homepage category menu and published courses are stored in Redis.

The course detail page uses a static page for SEO and uses CMS to publish to the Nginx server.

Xuecheng online try to combine with Cloud E Office and Grain Mall.

Use JMeter for stress testing, use jvisualvm to monitor memory leaks, track garbage collection, execute memory, cpu analysis, thread analysis, etc.
Stress test (press menu query interface):
Grain Mall (147 episode 16:30) MySQL optimization, indexing the parent_cid field.
Grain Store (Episode 149) jvisualvm shows frequent GC in the new generation and multiple GC in the old generation, so adjust the JVM parameters: -Xmx1024m -Xms1024m -Xmn512m. (Performance improvement is not obvious
) Query business optimization of Grain Mall (150 episodes).

Pay attention to the problems of cache penetration, cache avalanche, and cache breakdown when storing data in Redis.
Empty result cache, solve cache penetration (or use Bloom filter);
set expiration time (plus random value), solve cache avalanche;
lock, solve cache breakdown.
Realize distributed locks based on Redis.

Insert picture description here


Insert picture description here


Insert picture description here


Insert picture description here


Insert picture description here


Insert picture description here


Query interface plus distributed lock pseudo code:

public 返回值 接口方法() {
	while(true){
		查询Redis;
		if(从Redis中查到了结果){
			return 结果;
		}
		查不到
		去Redis占锁;    String uuid = UUID.randomUUID().toString();
					   Boolean lock = redisTemplate.opsForValue().setIfAbsent("lock",uuid,300,TimeUnit.SECONDS);
		if(占到了锁){
			try{
				返回结果=查询MySQL;
				存结果到Redis;
			}finally{
				删除锁;(原子操作)    String script = "if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('del', KEYS[1]) else return 0 end";
									 redisTemplate.execute(new DefaultRedisScript<Long>(script, Long.class) , Arrays.asList("lock"), uuid);
			}
			return 结果;
		}
	}
}

The Redisson tool can be understood, which is equivalent to changing the local lock under the JUC package to a distributed lock based on Redis.