首页 > 编程知识 正文

高速缓存和主存哪个快,nginx http

时间:2023-05-04 14:02:46 阅读:152853 作者:64

一、构建nginx缓存使用memc-nginx和srcache-nginx模块构建高效透明的缓存机制

传统缓存策略:

传统的缓存策略由php控制生命周期,而高效的缓存策略由memc srcache缓存在nginx的一部分。

OpenResty是一个基于Nginx和Lua的高性能Web平台,内置了许多精密的Lua库、第三方模块和大多数依赖项。 用于构建超高并发性、可扩展的动态Web APP应用程序、web服务和动态网关。

OpenResty通过聚合精心设计的Nginx模块(主要由OpenResty团队自行开发),有效地将Nginx转变为强大的通用web APP应用程序平台。 因此,Web开发人员和系统工程师使用Lua脚本语言动员Nginx支持的各种c和Lua模块,快速构建高性能的web APP应用系统,充分支持10K以上、1000K以上的独立并发连接

由于Openresty包含nginx模块和缓存模块,因此要使用缓存,需要运行Openresty中的nginx

软件: https://openresty.org/cn/

[ root @ server 1至] # lftp 172.25.254.250 lftp 172.25.254.2503360至CD pub/docs/lamp/lftp 172.25.254.250360 lampgetopenresty-1.19.9.1.tar.gz 5166658 bytestransferredlftp 172.25.254.250:/bytetttttttttttttttttttttralatttttpralattttioransttt cdopenresty-1.19.9.1 [ root @ server1openre sty-1.19.9.1 ] # ls # #中有配置文件,makebundleconfigurecoprecopre

[ root @ server1openre sty-1.19.9.1 ] #./configure-- with-http _ SSL _ module # #加参数

[ root @ server1openre sty-1.19.9.1 ] # make make install # #安装

软件配置:

[ root @ server1openre sty-1.19.9.1 ] # CD/usr/local/openre sty/[ root @ server1openre sty ] # ls刻苦的奥特曼copyrightluajitlualibnginxpodresty.indexsite [ root @ server1openre sty ] # cdnginx/[ root @ server1nginx ] lsconf html logs s拼命奥特曼[ root @ server1nginx ] # CD conf/[ root @ server1conf ] # pwd/usr/local/openre sty/nginx /

[ root @ server1conf ] # vim nginx.conf

修改用户,将并发计数更改为auto,将openfile更改为65535

添加memcache参数

继续编辑配置文件:

如果请求的uri以“. php”结尾,则首先在memcache中检查是否有以$uri$args为key的数据,如果有,则直接返回; 否则,运行location逻辑,如果返回的http状态代码为200,则在输出前将$uri$args作为key存储在memcache中

[ root @ server1conf ] #打开systemctlstartmemcached.service # # memcache

[ root @ server1conf ] #检查netstat-an TLP # #端口是否为11211

[ root @ server1conf ] # which nginx/usr/local /拼命奥特曼/nginx[root@server1 conf]# nginx

将/usr/local/nginx/html下的nginx默认发布目录文件复制到/usr/local/openre sty/nginx/html的默认发布目录中:

[ root @ server1html ] # CP/usr/local/nginx/html/example.PHP。

[root@server1 html]# ls

50x.html example.php index.html

[ root @ server1html ] # systemctlstartphp-fpm.service

在真机测试: ab -c10 -n 5000 http://172.25.52.1/example.php

同时数1364,停止local下的nginx,打开/usr/local/openresty/nginx的nginx

[ root @ server1conf ] # nginx-s stop # # [ root @ server1conf ] #/usr/local/openre sty/nginx/s拼命的奥特曼/nginx-s nginx.confsyntaxisoknginx :配置文件/usr/local/openre sty/nginx/conf nginx.conftestissuccessful [ root

真机测试:ab -c10 -n 5000 http://172.25.52.1/example.php

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。