Reputation: 75
I am running rails app using nginx and passenger on ec2-instance t2.small with 2GB RAM and 1 CPU Core.
App contains spree and related gems in development mode. Spree backend used to work fine but since last 3 days, it's taking too much time to respond and start up time is too high if remain idle for some time. I tried various combination of passenger methods in nginx but not helped so I omitted those and below is nginx file in current scenario
worker_processes 1;
events {
worker_connections 1024;
}
http {
passenger_root /usr/local/rvm/gems/ruby-2.2.1/gems/passenger-5.0.20;
passenger_ruby /usr/local/rvm/gems/ruby-2.2.1/wrappers/ruby;
passenger_app_env development;
#added two lines for setting user group
passenger_default_user root;
passenger_default_group root;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
passenger_spawn_method smart;
passenger_pool_idle_time 1000;
server {
listen 80;
server_name localhost;
root /var/www/html/apps/localfiles/public;
passenger_enabled on;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 80;
server_name abcd.com www.abcd.com;
root /var/www/html/apps/abcd/ComingSoon;
passenger_enabled on;
}
server {
listen 80;
server_name xyz.com www.xyz.com;
root /var/www/html/apps/xyz/ComingSoon;
passenger_enabled on;
}
}
Any light on what should be the right combination for nginx / passenger configuration would be highly appreciated.
Update: When I use Spree APIs, I need to hit an API 3-4 times to get proper response, it's throwing me this Web application could not be started
very often in between API calls. please help with this
Upvotes: 2
Views: 853
Reputation: 76774
DB Connection
In my experience, the DB Connection is the single biggest bottleneck for Rails apps.
I've found this mainly from Heroku, which uses Amazon's EC cloud - external databases seriously slow down applications.
--
You've neither mentioned whether you're pulling from a DB, nor what DB setup you're using.
The further away (geographically) the db server is to your web server, the slower the application runs.
I remember hooking our dev MYSQL db into our production app, and waiting 3/5 seconds to refresh; having db server in same data center pushed that time down to 0.25s.
I'd strongly recommend checking your production DB
Amazon provides its own MYSQL db functionality, which I'd strongly recommend you use.
If you have budget, go with RackSpace (they have MYSQL servers and web servers in the same data center) - Rails apps run blazingly fast with them.
Upvotes: 1