Answer the question
In order to leave comments, you need to log in
How to increase the number of concurrent connections when using unicorn?
Hello.
The server has 4 gigabytes of memory.
worker_processes in the unicorn settings is set to 10, with large values sometimes there are crashes associated with lack of memory.
Let's say that requests are made to the application, there can be 50-200 requests per second. The processing time of one request is about 500 milliseconds.
What options are there in this case (besides optimizing
the
application? :)
) recently.
Thanks in advance.
Answer the question
In order to leave comments, you need to log in
Can be put between the client and the nginx application! Then horizontal scaling is possible.
worker_processes should be set based on the number of processor cores (2 to 1, usually), not memory. In theory, even if you have 100 workers, ideally, each of them should load one core at 100%.
There are a lot of options for increasing RPS, but apart from the general ones that, as you indicated, you already use (caching, optimization), all the rest are completely dependent on the project and code.
Here's a nice article on the options:
merbist.com/2011/02/22/concurrency-in-ruby-explained
In principle, you can also try the simple steps as you wrote: take another web server. For example, start with puma. It should consume much less memory and run in threads. Although, you will hardly notice a big increase in RPS. Then you can try using, say, Rubinius (a really multi-threaded Ruby interpreter) for Puma. But what if.
Thin is unlikely to help here, but why not try - it's a matter of a few minutes.
PS
It should be noted that for a serious application and 200 RPS 4GB - this is usually staging for development.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question