php - 增加php websocket最大连接数

标签 php websocket ratchet

我目前正在运行带有 PHP 和 Apache 的 Debian 8 机器。

在这台机器上,我安装了一个 Ratchet websocket 服务器,尽管我最近在我运行的网站上访问了超过 1000 个并发用户。
这导致 Ratchet 套接字出现问题,因为在 1020 个连接时,它似乎会自动拒绝所有新连接。

我已经增加了ulimit -n和 debian 本身类似,但我开始怀疑问题是否出在我的 php 默认配置或我正在使用的 Ratchet websocket 中。

关于我应该更改什么配置的任何想法都非常感谢。

最佳答案

你只需要阅读部署中的官方文档
部分:它说:

The libev and libevent projects implement high-performance asynchronous event driven C libraries. The PHP extensions ev and event are available to interface with these libraries. They allow an application to transparently use the best kernel level evented I/O method (select, poll, epoll, kqueue, or event ports) available for the operating system it is running on.

The ev PHP extension bundles the libev C library in its source and requires no prior setup. If you want to use the event PHP extension, you need to first install the libevent library along with its headers for your operating system. For example on Debian/Ubuntu:



- $ sudo apt-get install libevent libevent-dev

You may then install the ev or the event extension, either through your preferred package manager, or directly using pecl:



- $ sudo pecl 安装 ev

- $ sudo pecl 安装事件

No further setup is necessary; if either of these extensions is present, the evented I/O loop toolkit used by Ratchet will automatically utilize them, which will drastically improve concurrency. here is the link: http://socketo.me/docs/deploy

关于php - 增加php websocket最大连接数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37093457/

相关文章:

javascript - 使用 HTML5 websocket 检测本地设备

php - 使用 PHP 比较数据库中的值

php - 在 MVC 应用程序中生成路由的最佳位置在哪里?

php - Mongodb 安装不使用 PHP

Laravel 5.1 : Run Custom Artisan Command in Background

PHP 响应并行请求

php - Websockets 和 Vagrant

php - wp_nav_menu 没有应用 css

javascript - WebSocket,即使在触发 onopen 事件后,仍处于 CONNECTING 状态

javascript - 在 Node.js 中不使用库使用 websockets 的简单方法是什么?