What determines memory usage in Ubuntu with Rails and MySQL

Forgive the question like newbie, but what determines the RAM consumed by rails and MySQL (my Ubuntu server)? Hardly any requests coming to the server seem to fluctuate around 1.5 out of 2 GB. MySQL stores about 100 MB of data. About 3,500 users are registered on the site, and when the traffic is high, the amount of memory is about 1.8 GB. When traffic is low or non-existent, it doesn't drop much, though.

What are the main factors in RAM consumption when deploying RoR? I would guess the DB size, but the size of my database is nowhere near my memory consumption (but maybe this is the wrong way to think about this?).

Can someone point me to a good resource or explain it to me here?

Thanks.

+3
source share
2 answers

EngineYard had a good blog post discussing some potential sources of memory issues in Rails. How do you maintain your site? (Passenger? Mongrel?)

+1
source

I am analyzing what is the thinnest configuration on an Ubuntu server to run my Rails 3.2.6 application with a minimum memory size with Nginx + Unicorn configuration. And using the local postgres database.

After removing many services, such as whoopsie and apparmor, in ubuntu, and even if only the most basic processes, I can create an instance of my workers on both sides, nginx and unicorn, for a total of 500 MB.

. . :

$ free -mt
             total       used       free     shared    buffers     cached
Mem:          3001        550       2450          0         16        178
-/+ buffers/cache:        355       2646
Swap:          952          0        952
Total:        3954        550       3403

$ ps -ef | grep nginx
root      1232     1  0 12:54 ?        00:00:00 nginx: master process /usr/sbin/nginx
www-data  1233  1232  0 12:54 ?        00:00:00 nginx: worker process
www-data  1234  1232  0 12:54 ?        00:00:00 nginx: worker process
www-data  1235  1232  0 12:54 ?        00:00:00 nginx: worker process
www-data  1236  1232  0 12:54 ?        00:00:00 nginx: worker process
herminio  5292  1078  0 13:24 pts/1    00:00:00 grep nginx

$ ps -ef | grep unicorn
herminio  4863     1  0 13:01 ?        00:00:00 unicorn_rails master -c unicorn.rb -D -E production                                                          
herminio  4866  4863  2 13:01 ?        00:00:34 unicorn_rails worker[0] -c unicorn.rb -D -E production                                                                                                         
herminio  5296  1078  0 13:24 pts/1    00:00:00 grep unicorn

$ ps -ef | grep postg
postgres   935     1  0 12:54 ?        00:00:00 /usr/lib/postgresql/9.1/bin/postgres -D /var/lib/postgresql/9.1/main -c config_file=/etc/postgresql/9.1/main/postgresql.conf
postgres   940   935  0 12:54 ?        00:00:00 postgres: writer process                                                                                                    
postgres   941   935  0 12:54 ?        00:00:00 postgres: wal writer process                                                                                                
postgres   942   935  0 12:54 ?        00:00:00 postgres: autovacuum launcher process                                                                                       
postgres   943   935  0 12:54 ?        00:00:00 postgres: stats collector process                                                                                           
postgres  5215   935  0 13:12 ?        00:00:00 postgres: user_db pto_db_prod 127.0.0.1(47118) idle                                                                       
herminio  5300  1078  0 13:24 pts/1    00:00:00 grep postg

, 92 1 , Nginx Unicorn, +1, .

, .

, 3 . -, rails.

, , :

bundle install --without development test # , Gems, .

, ActiveRecord, , .

+2

Source: https://habr.com/ru/post/1719140/


All Articles