-
Notifications
You must be signed in to change notification settings - Fork 283
Scaling OneBody
This document currently only applies if OneBody was installed using the Deb Package for Ubuntu and Debian. If you installed using another method, scaling is handled by Passenger (google it).
By default, OneBody only runs a single back-end server instance. This conserves RAM on small servers, but can also get bogged down if you have a lot of users hitting the server at the same time (especially if you use OneBody Check-in).
To increase the number of back-end servers and handle more concurrent users, follow these steps:
-
Set the number of back-end servers.
sudo onebody scale web=2
Replace
2
with the number of back-end servers you want to start.We recommend you only increment this by a small amount each time, taking special care not to start more than your machine can handle. See linuxatemyram.com for help using the
free
command on Linux to see memory usage. Also note that Rails processes tend to consume more RAM once their "warmed up" than they do when they're first started.Each back-end server has its own port, starting with 3000. Each back-end server beyond the first increments this number. So, if you have 2 back-end servers, your ports are 3000 and 3001.
You can see back-end servers running by listing Ruby processes:
$ ps x | grep ruby 715 ? Ssl 0:05 ruby /opt/onebody/vendor/bundle/ruby/2.2.0/bin/thin start -p 3000 2773 ? Ssl 0:03 ruby /opt/onebody/vendor/bundle/ruby/2.2.0/bin/thin start -p 3001
-
Modify your web server config to forward requests to all of the back-end servers.
Depending on which web server you are running, choose the appropriate section below:
Ningx
Your config file is probably at
/etc/nginx/sites-available/onebody
.Add a
upstream
server
entry for each back-end server, like this:upstream onebody { server 127.0.0.1:3000; server 127.0.0.1:3001; } server { listen 80; client_max_body_size 25m; location / { proxy_pass http://onebody; } }
Apache
Your config might be at
/etc/apache2/sites-available/000-default.conf
or similar.Add a
BalancerMember
entry for each back-end server, like this:<Proxy "balancer://onebody"> BalancerMember "http://localhost:3000" BalancerMember "http://localhost:3001" </Proxy> ProxyPass / balancer://onebody/ ProxyPassReverse / balancer://onebody/
-
Reload your web server:
sudo nginx -s reload
...or...
sudo service apache2 reload