8889841cscaling.md000066600000001630150515662760006527 0ustar00--- title: ... but does it scale? order: 2 --- # ... but does it scale? Of course, this is not a question with an easy answer as your mileage may vary. But with the appropriate server-side configuration your WebSocket server can easily hold a **lot** of concurrent connections. This is an example benchmark that was done on the smallest Digital Ocean droplet, that also had a couple of other Laravel projects running. On this specific server, the maximum number of **concurrent** connections ended up being ~15,000. ![Benchmark](/img/simultaneous_users.png) Here is another benchmark that was run on a 2GB Digital Ocean droplet with 2 CPUs. The maximum number of **concurrent** connections on this server setup is nearly 60,000. ![Benchmark](/img/simultaneous_users_2gb.png) Make sure to take a look at the [Deployment Tips](/docs/laravel-websockets/faq/deploying) to find out how to improve your specific setup. _index.md000066600000000034150515662760006352 0ustar00--- title: FAQ order: 5 --- deploying.md000066600000003667150515662760007115 0ustar00--- title: Deploying order: 1 --- # Deploying When your application is ready to get deployed, here are some tips to improve your WebSocket server. ### Open Connection Limit On Unix systems, every user that connects to your WebSocket server is represented as a file somewhere on the system. As a security measurement of every Unix based OS, the number of "file descriptors" an application may have open at a time is limited - most of the time to a default value of 1024 - which would result in a maximum number of 1024 concurrent users on your WebSocket server. In addition to the OS restrictions, this package makes use of an event loop called "stream_select", which has a hard limit of 1024. #### Increasing the maximum number of file descriptors The operating system limit of open "file descriptors" can be increased using the `ulimit` command. The `-n` option modifies the number of open file descriptors. ```bash ulimit -n 10000 ``` The `ulimit` command only **temporarily** increases the maximum number of open file descriptors. To permanently modify this value, you can edit it in your operating system `limits.conf` file. You are best to do so by creating a file in the `limits.d` directory. This will work for both Red Hat & Ubuntu derivatives. ```bash $ cat /etc/security/limits.d/laravel-echo.conf laravel-echo soft nofile 10000 ``` The above example assumes you will run your echo server as the `laravel-echo` user, you are free to change that to your liking. #### Changing the event loop To make use of a different event loop, that does not have a hard limit of 1024 concurrent connections, you can either install the `ev` or `event` PECL extension using: ```bash sudo pecl install ev # or sudo pecl install event ``` #### Deploying on Laravel Forge If your are using [Laravel Forge](https://forge.laravel.com/) for the deployment [this article by Alex Bouma](https://alex.bouma.dev/installing-laravel-websockets-on-forge) might help you out.