Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could performance issues imerge when using ActionCable in Production?

I'm planning to have a Rails App that has a very content rich interactive page where many users will connect to.

Development has went well and small time testing on the Dev servers went without a hitch either.

Problems started when we started alpha testing with selected groups of people. the sever would grind to a halt suddenly. Nginx would stop because of queue being full. I was at a lose for a while, but after looking around, came to the conclusion that the live actioncable was completely eating up my memory.This especially gets bad when the user reloads the page multiple times that subscribes to actioncable, causing additional process to become active, completely stopping the server, only being cured by a nginx reboot.

I currently run a 2core 1GB memory SSD run VPS server for alpha testing, perhaps at tops 20 concurrent users.Should I be running into performance problems with such load? or should tuning the code or redis, passenger fix this?

I know its hard to say any definitive things without more specifics, but could a ballpark estimate be done with the information?

like image 269
Saifis Avatar asked Jan 23 '26 20:01

Saifis


2 Answers

After some gogoling and testing Nginx settings, adding this directive to the nginx settings for passenger has seemed to dramatically improve the performance issue.

   location /special_websocket_endpoint {
       passenger_app_group_name foo_websocket;
       passenger_force_max_concurrent_requests_per_process 0;
   }

more info here

https://www.phusionpassenger.com/library/config/nginx/tuning_sse_and_websockets/

like image 97
Saifis Avatar answered Jan 25 '26 16:01

Saifis


20 concurrent users plus multiple tabs per user is still less than about 100 concurrent websocket connections, it is not that lot.

First thing I'd look for is leaks - when for some reason websocket connection or other resources (open files etc.) does not get freed when actual user disconnects. Make sure you're running fresh versions of rails/passenger, as there was a bug in rails causing similar behaviour (see https://blog.phusion.nl/2016/07/07/actioncable-under-stress-p1/ for details)

Also while actioncable+passenger inside nginx allows you to run everything inside single process, it is not a good idea when you expect some load. When running a clean nginx and separate rails servers for regular requests and cable - at least other parts of the app will continue some kind of working in such conditions.

like image 28
Vasfed Avatar answered Jan 25 '26 16:01

Vasfed



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!