Accumulated basis - Cache problem penetrating the basics

1. What is nginx

nginx是由俄罗斯生产的, 底层使用C语言编写的, 一个负载均衡器, 反向代理服务器, http服务器

Action:
. A may be used as a load balancer nginx use, accept all requests, and dispatches requests to be processed tomcat cluster
B nginx may be used as a reverse proxy server may accept all requests, and in accordance with the address request url, distribution. tomcat to handle different projects
. c can be used as a http server, nginx can run html, js, css, pictures and other static resources.
nginx performance is very good, stand-alone can withstand the amount of fifty thousand requests per second.

Three functions illustration:

1. Load balancing:

Here Insert Picture Description

2. Reverse Proxy features:

Here Insert Picture Description

3.http server function (mainly static storage resources):

Here Insert Picture Description

2. What is openResty:

openResty是一个开源的, 对nginx的封装, 其实就是nginx, 但是里面加入了对lua语言的支持, 还加入了
lua语言说使用的例如调用mysql, 调用redis等第三方工具包.

3. Cache penetrating question:

1. 访问者访问nginx, nginx本地缓存中找不到数据, 则从redis中找,
 redis中找不到数据, 则从数据库中找.
2. 数据库中也没有这样的数据, 所以redis中和nginx本地缓存中不缓存
3. 如果黑客利用这样的逻辑漏洞, 就专门找你网站不存在的数据, 每秒高并发
访问, 直接会导致数据库副服务器宕机.
这种问题就叫做缓存穿透, 因为透过了各种缓存, 直接访问了数据库, 导致数据库宕机.

4. The buffer solution penetrates:

1. 缓存预热, 通过数据库的变化, 来更新redis中的数据, 查询的时候如果redis
中查询不到数据直接返回null, 不直接查询数据库
2. 布隆过滤器
3. 如果从数据库中查询, 查询到结果为null, 可以将这个数据缓存入redis, 
超时时间设定为1-3秒, 如果黑客想以短时间, 高并发来访问, 则被redis拦截住,
因为redis中有这样的数据, 但是值是null, 如果黑客不访问这个数据了,
因为数据设置了超时时间, 超过这个时间会被redis自动销毁,
也不会产生大量的垃圾数据.

Illustration:
1. General Access:
Here Insert Picture Description
2 by the database cache data:
Here Insert Picture Description

Published 122 original articles · won praise 1 · views 7316

Guess you like

Origin blog.csdn.net/qq_36079912/article/details/104849808