細水長流

Debian 11 + OneinStack 如何调整 memcached 内存大小?

Memcached 是一套高性能分布式内存对象高速缓存系统,用于动态 Web 应用减轻数据库负载以提高动态 web(如 WordPress)响应速度。Memcached 通过在内存中缓存数据和对象来减少数据库查询次数提高动态、数据库驱动网站的速度。

「Debian 11 + OneinStack 如何调整 memcached 内存大小?:https://uxtt.com/7」

Memcached 简介

Memcached 官网:http://www.memcached.org

What is Memcached?

Free & open source, high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.

「Debian 11 + OneinStack 如何调整 memcached 内存大小?:https://uxtt.com/7」

Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering.

Memcached is simple yet powerful. Its simple design promotes quick deployment, ease of development, and solves many problems facing large data caches. Its API is available for most popular languages.

相关资料:PHP 手册 Memcached

「Debian 11 + OneinStack 如何调整 memcached 内存大小?:https://uxtt.com/7」

Debian 11 如何调整 memcached 内存大小?

昨天在 CloudCone 买了个个美国 VPS 服务器,使用 CentOS 7 系统,加 OneinStack 搭建 LNMP 环境,试了两次,memcached 都无法启动,后来换 Debian 11 就可以了。

Debian 11 + OneinStack 如何调整 memcached 内存大小?或者调整连接数等?

修改 /usr/lib/systemd/system/memcached.service 文件:

「Debian 11 + OneinStack 如何调整 memcached 内存大小?:https://uxtt.com/7」

[Service]
Environment=PORT=11211
Environment=USER=memcached
Environment=MAXCONN=1024
Environment=CACHESIZE=192
Environment=OPTIONS="-l 127.0.0.1"
ExecStart=/usr/bin/memcached -p ${PORT} -u ${USER} -m ${CACHESIZE} -c ${MAXCONN} $OPTIONS

MAXCONN 为最大连接数、CACHESIZE 为内存大小,根据实际环境调整,修改完成保存。然后执行下面代码重启 memcached 即可:

systemctl daemon-reload
systemctl restart memcached
systemctl status memcached

其它相关文章:VPS 启用 Memcached 动态缓存数据库 优化加速 WordPress 博客

退出移动版