OpenResty
1.OpenResty介绍
openResty是一个基于Nginx与lua的高性能的WEB平台。
openResty = nginx + lua(脚本语言) + 第三方模块(redis 、mysql、mq…)
官方网站: www.openresty.com
openResty的目标是期望成为高性能的web服务器,不过现在在实际应用中常被用于秒杀、高并发场景。例如:秒杀前先在redis授权,在秒杀时候先经过openresty有权限的用户才能下单扣减库存。也可以直接通过openresty将需要扣减库存的消息落到mq中。
tomcat并行连接数是200,nginx并行连接数50000;
2.nginx的流程定义
http请求处理时候分为11个阶段
1.post-read
接收到完整的http头部后处理的阶段,在uri重写之前,一般跳过
2.server-rewrite
location匹配前,修改uri的阶段,用于重定向,location块外的重写指令(多次
执行)
3.find-config
uri寻找匹配的location块配置项(多次执行)
4.rewrite
找到location块后再修改uri,location级别的uri重