我正在分析Ubuntu服務器中最簡單的配置是什麼,以便使用Nginx + Unicorn配置以最低的內存佔用量運行我的Rails 3.2.6應用程序。並使用本地postgres數據庫。
在ubuntu下刪除了很多像whoopsie和apparmor這樣的服務,並且只讓基本的流程能夠實例化我的工作人員,nginx和獨角獸總共500MB。
這純粹是應用程序的香草推出。只有一個數據庫連接。 這是與所述第一用戶執行以基線的命令的結果:
$ 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
有了這個信息我可以確定我的OS使用92個流程主機我應用與1個連接,隨着越來越多的過程是從Nginx的產卵並且獨角獸的進程數量增加了1,並且還增加了與數據庫的連接。
研究每個進程的內存使用情況也有助於確定應用程序的內存消耗量。
我正在使用舊筆記本電腦來設置我的應用程序基準,並且它只有3GB的內存。 將來我打算在低規格服務器的分佈式環境中發佈這個應用程序,因此我想特別瞭解我的Rails應用程序中所有內容的佔用空間。
一些我一路上學到的東西是:
捆綁安裝--without開發測試#爲了使那些只在生產環境中使用,而不是更確保您的應用程序使用和負載寶石。
請確保您只加載您的請求需要而不是更多的ActiveRecord模型。
乘客。我有一個2GB的切片(slicehost) – chrishomer 2009-10-03 00:22:06
還有幾個問題:什麼是Ruby版本?什麼是您的PassengerMaxPoolSize? Nginx還是Apache?我想我的博客文章中有一些內容可以幫助你,但額外的信息不會受到傷害。 – 2009-10-03 00:36:15
紅寶石1.8.7 Apache PassengerMaxPoolSize - >我還沒有設置這個(所以6?),但現在,我查看它,也許我應該? – chrishomer 2009-10-03 20:15:47