0

My web application ruby on rails is getting more and more throughput. With New Relic, i got Apdex score < 0.7

My app is running on my Debian server(ex: ip pulic is 123.235.23.16) with Nginx and THIN. The codes and database mysql is all in this server.

My app has 3 app instances which are created by THIN (0.0.0.0:3000, 0.0.0.0:3001, 0.0.0.0:3002). And In Nginx http config, i use Load balancing methods:

upstream myapp1 {
        server 127.0.0.1:3000;
        server 127.0.0.1:3001;
        server 127.0.0.1:3002;
    }

server {
        listen 80;
        ...
        location / {
            proxy_pass http://myapp1;
        }
        ...
    }

I want to know if I add another Debian server (ex: ip pulic is 123.235.23.17) to help the first server to hundle throughputs, Which server should be configured as nginx load balaancing server ? How to hundle mysql database io with two different servers and different app instances ? mysql remote ?

Ori Marko
  • 56,308
  • 23
  • 131
  • 233
孙悟空
  • 1,215
  • 1
  • 11
  • 26

1 Answers1

1

Adding more physical servers or hosts will only affect your Apdex score if the response time is caused primarily by queue time, which happens but is relatively rare in Rails production workloads.

The most common place for Rails apps to spend time is in I/O with its database. Check query counts for N+1 explosions, check slow query logs either in NewRelic or your DB itself to see if adding indexes can help. Investigate using some caching if the performance hit is limited to some small number of pages.

It's also very common for the home page to be quite slow, but other pages are OK. See if your Apdex score is being primarily influenced by a few bad pages rather than overall application slowness.

Jim Van Fleet
  • 1,110
  • 7
  • 12
  • You mean, adding more physical servers is not a good solution, Even in my case that the 4 CPUs are High CPU Usage ? I haven't n+1 query problem. Memcached is running. – 孙悟空 Sep 07 '16 at 13:44
  • The high CPU usage is worth looking into-- is there a test suite you can run where you can turn on time profiling? That can indicate which parts of the app need to be sped up. There are limits to what can be done operationally to speed a slow app. Also, is every page low Apdex or just a few? – Jim Van Fleet Sep 07 '16 at 13:58
  • Thank you for your answer, I choose New Relic to monitor my app. When there are 168 rpm, every page is slowdown. But at 3h, there are no-visitors, my app is fast. – 孙悟空 Sep 07 '16 at 14:48