- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
请原谅新手类型的问题,但是,是什么决定了 rails 和 MySQL(我的服务器是 Ubuntu)消耗的 RAM?几乎没有任何请求进入服务器似乎徘徊在 2GB 的 1.5 左右。 MySQL 中存储了大约 100MB 的数据。该站点有大约 3500 名注册用户,当流量很高时,内存往往会达到 1.8 GB 左右的峰值。当流量较低或不存在时,它不会下降太多。
在 RoR 部署方面,RAM 消耗的主要因素是什么?我会假设数据库大小,但我的数据库大小远不及我的 RAM 消耗(但也许这是错误的思考方式?)。
谁能给我指点这方面的好资源,或者在这里向我解释一下?
谢谢。
最佳答案
我正在分析 Ubuntu 服务器中运行我的 Rails 3.2.6 应用程序的最精简配置是什么,使用 Nginx + Unicorn 配置时内存占用最少。并使用本地 postgres 数据库。
在 ubuntu 中删除了 whoopsie 和 apparmor 等许多服务后,只让最基本的过程我可以在两侧实例化我的 worker,nginx 和 unicorn,总共 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
根据这些信息,我可以确定我的操作系统使用 92 个进程来通过 1 个连接来托管我的应用程序,随着更多的进程从 Nginx 和 Unicorn 产生,进程的数量增加了 +1,与数据库的连接也增加了。
查看每个进程的内存使用情况也有助于确定应用程序的内存消耗量。
我使用一台旧笔记本电脑为我的应用设置基准,它只有 3GB 内存。将来我计划在具有低规范服务器的分布式环境中发布此应用程序,因此我想具体了解我的 Rails 应用程序中所有内容的足迹。
我一路上学到的一些东西是:
bundle install --without development test # 确保您的应用程序使用和加载仅在生产环境中使用的 Gem,而不是更多。
确保只加载请求所需的 ActiveRecord 模型,而不是更多。
关于mysql - 是什么决定了 Ubuntu 上使用 Rails 和 MySQL 的内存使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1512365/
这是一道函数依赖题。 我知道当 x->yz 然后 x->y 和 x->z 时。但是上面的依赖关系可能吗? 最佳答案 If xy determines z can x determine z and y
我有一个奇怪的问题。 Line 61: $this->_currentRoute = Default_Model_Routes::getInstance()->getCurrentRoute(); .
我正在开发一种工具来比较两个波形文件的波形相似性。例如,我有一个持续时间为 1 分钟的波形文件,我使用第一个波形文件制作了另一个波形文件,但每 5 秒生成一次数据,间隔为 5 秒至 0。 现在我的软件
我遇到了一个奇怪的问题,尽管我打赌有一个巧妙的方法可以解决它。 情况是我有一个具有三列排序状态的表:完全未排序,在这种情况下我不希望出现任何图标,按升序排序,在这种情况下我想要一个向上箭头,以及按降序
Java 语言规范提供了criteria用于确定(格式良好的)执行是否满足“Java 内存模型的因果关系要求”。让我们假设执行是有限的。我试图了解是否存在多项式时间算法来证明或反驳这种情况。 真的,我
Java 语言规范提供了criteria用于确定(格式良好的)执行是否满足“Java 内存模型的因果关系要求”。让我们假设执行是有限的。我试图了解是否存在多项式时间算法来证明或反驳这种情况。 真的,我
我正在编写一个简单的Bank类,其中包含Account。我希望人员能够开设一个新的受密码保护的银行帐户,并从其帐户中提取和存入资金。账户设在银行内。银行和帐户类应提供哪些服务? 假设 p 已在银行 b
我的标题概括了这一点。我有一个将要开发的简单业务线应用程序,并且很好奇如何确定我应该针对哪个 .NET 版本。支持 Win XP SP3 会很好,但不是必需的。它将用于索引多页 tiff,因此导入一批
已锁定。这个问题及其答案是locked因为这个问题是题外话,但却具有历史意义。目前不接受新的答案或互动。 你是否真的“尝试过”(意味着在其中编程,而不仅仅是阅读有关它的文章)Erlang并决定在项目中
我正在尝试使用 ExceptionFilterAttribute 为 Web Api 实现异常处理。我已经继承了ExceptionFilterAttribute 类并覆盖了onException 方法
前一段时间在一次编程比赛中我遇到了一个令人费解的问题,此后一直困扰着我。虽然我没有逐字记住,但我会尽力重现: Jack starts at 0 on the number line and jumps
我有什么: 我有一个主要内容区域,后面跟着两个旁白: #primary,#secondary,#tertiary{float:left; width:33%;} Primary
我无法正确操作键盘。 整个 View 充满了文本字段。 当我使用通知将 View 向上移动时,上方的文本框不再可见: override func viewDidLoad() { super.v
已结束。此问题正在寻求书籍、工具、软件库等的推荐。它不满足Stack Overflow guidelines 。目前不接受答案。 我们不允许提出寻求书籍、工具、软件库等推荐的问题。您可以编辑问题,以便
我在尝试获取父对象来过滤子事件时遇到问题。 在下面的示例中,我在旋转框上设置了一个事件过滤器。事件过滤器检测旋转框上的鼠标按下事件。然后,我希望父对象根据某些标准接受或忽略该事件。 问题是它似乎接受了
我使用从 std::system_error 继承的类进行错误处理,我想控制调用 what() 时返回的内容。原因:标准(C++11 和 C++1y CD 草案 - N3690,下面的 § 引用是后者
我正在用 Swift 构建一个 iOS 应用程序,它的起始页有 6 个按钮。这些按钮中的每一个都将连接到一个 TableView Controller ,其数据由 NSFetchedResultsCo
我想构建这样的东西 数据存储| mycode.py | RESTful API | mywebapp.py(Django 或 Tornado) 我检查了 Django 的 Piston,但似乎这样我就
究竟如何更改 RichTextBox 中的字体? 环顾四周给了我似乎不再有效的旧答案。我认为这就像执行 richtextbox1.Font = Font.Bold; 或类似操作一样简单。原来不是,所以
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 7 年前。 Improve this qu
我是一名优秀的程序员,十分优秀!