0

I am building a basic chat application for customer support of a website. It works flawlessly in development on local server. I pushed the changes to the server but it is behaving extremely slow. The application in itself works fast but the pub/sub to acioncable channels is slow.

I am using nginx, puma for webserver and redis for pub/sub. I have four channels and two of them have heavy client side (coffee.erb file).How can I reduce time for actioncable channels? How can I debug what is causing the lag? enter image description here

enter image description here

Thanking you in advance. If any code is required please mention in the comments of the question and I would add it to the question.

Vaibhav Maheshwari
  • 380
  • 1
  • 3
  • 18
  • 1
    So you checked server metrics like cpu, ram, disk util, response times and such and came to a conclusion that problem is in `actioncable` code itself? How many simultaneous connections you have? And how much is `extremely slow`? – Martin Apr 15 '18 at 12:11
  • It has 4 or 5 simultaneous connections (depending on what I am doing). Each connection is sending less than 100Kb of data via channel pub/sub. – Vaibhav Maheshwari Apr 15 '18 at 12:13
  • @MartinZinovsky It is taking 10 seconds for a subscription to happen which then communicates to a channel and send a notification to admin interface. 10 SECONDS! – Vaibhav Maheshwari Apr 15 '18 at 13:02

1 Answers1

2

The most common cause for things running way more slowly on a server than locally is because they don't have nearly the same amount of RAM and start swapping. Just like an app being ridiculously slow on older phones.

In one case, the system swaps in and out memory, in the other case, the app swaps in and out resources itself (often implicitly through resource caches provided by the API).

The effect is the same: massive I/O overhead that doesn't exist on your development system / modern phone, leading to runtime behavior that is slower by several orders of magnitude.

yeoman
  • 1,671
  • 12
  • 15
  • Initially I assumed the same and increased the RAM but I do not think that is the problem. I have added the screenshots in my question to explain how different processes are being consumed. – Vaibhav Maheshwari Apr 15 '18 at 12:11
  • Is it a virtual server? In that case, using over 25% of promised memory can already be an issue, meaning that instead of memory being swapped in and out, your virtual machine keeps getting quietly suspended... – yeoman Apr 18 '18 at 02:09
  • It is not virtual server. It is Compute Engine instance (40$/month droplet) – Vaibhav Maheshwari Apr 19 '18 at 13:09