在 Unix 套接字和 TCP/IP 套接字上运行 PHP-FPM 有什么区别? [英] What are the differences from running PHP-FPM over an Unix Socket vs a TCP/IP Socket?

查看:59
本文介绍了在 Unix 套接字和 TCP/IP 套接字上运行 PHP-FPM 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有这两种运行 PHP-FPM 的方式.我知道在技术上没有什么是防弹的,但这两种方法的优缺点是什么?

There are these two ways of running PHP-FPM. I know that nothing is bullet-proof in tech, but what are the pros and cons from both methods?

推荐答案

不同之处主要在于使用完整的网络堆栈来打包"和解包"每条数据所增加的开销.请注意,大多数部署的开销可以忽略不计

The difference is mainly the added overhead of using the full network stack to "pack" and "unpack" every piece of data. Mind you that the overhead is negligible for most deployments

  • 当前端(例如 Nginx)和 php-fpm 在同一个框内时,使用套接字(例如 listen = '/tmp/php-fpm.sock')是有意义的

  • Using a socket (e.g. listen = '/tmp/php-fpm.sock') makes sense when both the front-end (e.g. Nginx) and php-fpm are in the same box and

  1. 您可以选择同时水平扩展前端和后端(假设您正在构建一个包含两者的容器,并且您可以创建更多容器,每个容器都有一个工作对)或
  2. 您唯一的选择是垂直缩放您正在使用的一个盒子"(例如,您添加更多 CPU、RAM 等)

  • 使用 TCP 连接(例如 listen = 127.0.0.1:9000)是有意义的,如果您想分离前端和后端,例如,如果您决定通过以下方式扩展您的环境单个 Nginx 接收连接并将工作通过网络传递到一组 php-fpm 盒子

  • Using a TCP connection (e.g. listen = 127.0.0.1:9000) makes sense if you want to de-couple the front and the back-end, for example, if you decide to scale up your environment by having a single Nginx receiving connections and passing the work via the network to a cluster of php-fpm boxes

    每个环境都是不同的,所以与往常一样,唯一正确的选择是从一个看起来正确的设置开始,负载测试,并不断测量性能,这样您就可以随着负载需求的变化尝试不同的选项(通常,您选择实施成本更低或更易于维护的方法,因为两者都是经过实战考验的可靠方法)

    Every environment is different, so as always, the only true option is to start with the one setup that seems right, load-test, and keep measuring the performance so you can try different options as your load requirements evolve (normally, you go with the one that is cheaper to implement or easier to maintain, since both are solid, battle-tested approaches)

    这篇关于在 Unix 套接字和 TCP/IP 套接字上运行 PHP-FPM 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆