In the Thin website: http://code.macournoyer.com/thin/usage/ it says that you can start multiple servers using:
thin start --servers 3
- Why would you need to do this?
- Is each server assigned a different port or something?
In the Thin website: http://code.macournoyer.com/thin/usage/ it says that you can start multiple servers using:
thin start --servers 3
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".
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
--servers
parameters will start up several ruby processes, not threads. This is an important distinction, because the GIL can only affect threads within the same process, not separate processes. By that chain of logic, you wouldn't be able to run completely different ruby programs on the same machine, because their GIL's would affect each other. –
Muttonhead © 2022 - 2024 — McMap. All rights reserved.