简体   繁体   English

如何衡量Rack或Sinatra应用程序的内存使用情况?

[英]How to measure memory usage of a Rack or Sinatra app?

How do you measure memory usage of a Rack or Sinatra app? 如何衡量Rack或Sinatra应用程序的内存使用情况?

I understand that probably depends a lot on how it is deployed. 据我所知,这可能在很大程度上取决于它的部署方式。 But how do you get a basic idea of how much memory it uses? 但是,您如何基本了解它使用了多少内存?

如果您正在使用乘客,您可以尝试乘客记忆统计数据,这可以让您按站点分割出一个很好的概览,否则您可以通过使用top,shift-M和寻找红宝石过程来了解内存使用情况。

Despite it's name, I've successfully used the derailed_benchmarks gem to dynamically benchmark memory usage in a Padrino (built on Sinatra) app. 尽管它的名字,我已成功使用derailed_benchmarks gem动态地对Padrino(基于Sinatra)应用程序中的内存使用情况进行基准测试。 The docs describe how to do this for a non-Rails Rack app - you just need to define DERAILED_APP in a simple Rake task to tell it how to boot your app. 文档描述了如何为非Rails Rack应用程序执行此操作 - 您只需在简单的Rake任务中定义DERAILED_APP即可告诉它如何启动您的应用程序。

It can be run with a real server (I use Unicorn) on your localhost and potentially even with your production database (define DATABASE_URL ). 它可以在本地主机上使用真实服务器(我使用Unicorn)运行,甚至可以使用生产数据库(定义DATABASE_URL )运行。 It can also be used to test any endpoint and bypass authentication, if necessary. 如有必要,它还可用于测试任何端点和绕过身份验证。 Use cases include memory use over time (to find leaks) and profiling gems/required library memory at boot for a given endpoint (lots of memory use at boot). 用例包括随着时间的推移使用内存(查找泄漏)以及在启动时为给定端点分析gems /所需的库内存(启动时使用大量内存)。

As an example, the command bundle exec derailed exec perf:mem gives the output below for my app's root at boot (here hiding < 3 MiB usage). 例如,命令bundle exec derailed exec perf:mem在启动时为我的应用程序根提供下面的输出(这里隐藏<3 MiB使用率)。 Around 70 MiB tallies with what Heroku's stats are telling me on my production server. 在我的生产服务器上,Heroku的统计信息告诉了我大约70 MiB的标签。 My app is called 'padfoot' btw. 我的应用程序被称为'padfoot'顺便说一句。

TOP: 71.75 MiB mechanize: 19.0898 MiB (Also required by: /Users/me/dev/padfoot/lib/parsers/transaction_table_parser.rb, /Users/me/dev/padfoot/lib/scrapers/app_details_scraper.rb, and 4 others) mechanize/pluggable_parsers: 11.1055 MiB mime/types: 10.9766 MiB (Also required by: /Users/me/.rvm/gems/ruby-2.3.1/gems/rest-client-1.8.0/lib/restclient/request, /Users/me/.rvm/gems/ruby-2.3.1/gems/rest-client-1.8.0/lib/restclient/payload) padrino: 13.1016 MiB padrino-core: 8.0273 MiB (Also required by: padrino-cache, padrino-admin) padrino-core/application: 3.3555 MiB sinatra/base: 3.1406 MiB (Also required by: padrino-core/ext/sinatra, sinatra/main) padrino-helpers: 3.707 MiB (Also required by: padrino-cache, padrino-admin) padrino/rendering: 3.3203 MiB (Also required by: /Users/me/dev/padfoot/app/app.rb) /Users/me/dev/padfoot/config/apps.rb: 6.9805 MiB /Users/me/dev/padfoot/app/app.rb: 6.8906 MiB aws-sdk-core/s3: 6.3711 MiB /Users/me/dev/padfoot/lib/scrapers/gps/gps_scraper.rb: 4.25 MiB linguistics/en: 4.1523 MiB /Users/me/dev/padfoot/lib/scrapers/digimap/digimap_scraper.rb: 3.0547 MiB

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何配置Sinatra Rack应用程序以使用Figaro - How to configure a sinatra rack app to use figaro 如何在Sinatra / Rack应用程序中设置应用程序/服务器/机架范围的时区? - How to set app/server/Rack-wide timezone in Sinatra/Rack apps? Rack :: MiniProfiler无法在Sinatra应用程序中捕获续集查询 - Rack::MiniProfiler not capturing Sequel queries in Sinatra app 如何从Sinatra App释放内存 - How to release memory from Sinatra App 如何在机架会话中设置会话[:expires](Sinatra) - How to set session[:expires] in rack session (Sinatra) 如何从sinatra应用程序中的类将数据传递到websocket机架? - How can I pass data to websocket-rack from a class in my sinatra app? 如何获得正在通过机架测试测试的Sinatra应用程序实例? - How do I get the Sinatra app instance that's being tested by rack-test? 如何测试带有Memcache的Heroku上的Rack :: Cache是​​否可与Sinatra应用一起使用? - How do I test if Rack::Cache is functioning with Sinatra app on Heroku with memcache? 如何使用机架/测试来测试Sinatra重定向? 该应用程序有效,但测试不起作用 - How do I use Rack/Test to test Sinatra redirects? The App works, but the test doesn't 使用Rack在非根路径上托管Sinatra应用 - Host Sinatra app off a non-root path using Rack
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM