Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why would you start multiple thin servers? [closed]

Tags:

thin

In the Thin website: http://code.macournoyer.com/thin/usage/ it says that you can start multiple servers using:

thin start --servers 3
  1. Why would you need to do this?
  2. Is each server assigned a different port or something?
like image 867
Albert Peng Avatar asked Nov 25 '12 07:11

Albert Peng


1 Answers

  1. You would start more than one instante of thin if you may have concurrent requests to process. To manage concurrent requests (Simultaneous connections) you need a cluster of "thin".

  2. Yes, you can easily see this:

let's try a single-server thin

 thin start -R fart.ru
 Thin web server (v1.5.0 codename Knife)
 Maximum connections set to 1024
 Listening on 0.0.0.0:3000, CTRL+C to stop

check:

 netstat -an | grep 300
 tcp4       0      0  *.3000                 *.*                    LISTEN     

ok, we have a thin listening on one port.

now let's try a --servers 3

 thin start -R fart.ru --servers 3
 Starting server on 0.0.0.0:3000 ... 
 Starting server on 0.0.0.0:3001 ... 
 Starting server on 0.0.0.0:3002 ... 

check:

 netstat -an | grep 300
 tcp4       0      0  *.3002                 *.*                    LISTEN     
 tcp4       0      0  *.3001                 *.*                    LISTEN     
 tcp4       0      0  *.3000                 *.*                    LISTEN    

voilà you have 3 port listening.

 ps -ef | grep thin 

reports 3 processes running, each one can manage a concurrent request.

Ultimately to concurrently process requests you have to start a cluster of thin and reverse proxy your virtual host then load balance the request on the various thin you've started.

This blogpost can make the point: Scaling Rails with Apache 2, mod_proxy_balancer and Thin Clusters

like image 106
Franco Rondini Avatar answered Oct 13 '22 08:10

Franco Rondini