Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yosuke-furukawa/6822031 to your computer and use it in GitHub Desktop.
Save yosuke-furukawa/6822031 to your computer and use it in GitHub Desktop.
dstat入れた => リソース状況調査
$ sudo yum install dstat
mysqlのslow query log取ろうと思ったけど、よくわからないまま、色々やってた。
my.cnfをいじってみた。
弄る前に場所を確認
$ mysql --help | grep my.cnf
/etc/my.cnfっぽいので、そこを修正。
[tuning]
skip-name-resolve
max_connections=500
thread_cache_size=200
table_cache=400
key_buffer_size=256M
query_cache_size=512M
sort_buffer_size=128M
read_buffer_size=128M
read_rnd_buffer_size=128M
tmp_table_size=128M
join_buffer_size=128M
innodb_buffer_pool_size=1024M
innodb_flush_method=O_DIRECT
skip-innodb_doublewrite
これだけで2 => 2.5
全然だと思ったので、ruby側の設定チューニング。
よくわからないけど、development.rbをいじる。
Tuningathon::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.action_controller.perform_caching = true
config.cache_classes = true
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_controller.perform_caching = true
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false
# Print deprecation notices to the Rails logger
config.active_support.deprecation = :log
# Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin
# Raise exception on mass assignment protection for Active Record models
config.active_record.mass_assignment_sanitizer = :strict
# Log the query plan for queries taking more than this (works
# with SQLite, MySQL, and PostgreSQL)
# config.active_record.auto_explain_threshold_in_seconds = 0.5
# Do not compress assets
config.assets.compress = false
# Expands the lines which load the assets
config.assets.debug = false
config.action_controller.allow_forgery_protection = false
end
なんとなく、早くなりそうなところだけはイジっといた。
ここで 2.5 => 5.9位になった。
そこから色々調べてやり始めるけどよく分からず。
最終的にRubyのバージョンを上げてみようと思う。
Ruby 1.8 => Ruby 1.9
これ超大変だった。Gemがないとか怒られすぎてよくわからんくなった。
でも色々調べてやり直したら、すごく改善した。
5.9 => 11!!
11だったんだけど、これからexport でGC設定をチューニング。
11 => 17, 18にもなった。
これぐらいが関の山かと思って、niceでruby のCPU優先度を上げておいた。
$nice -20 xxxx
[上位者]
unicorn nginx エンタープライズ版で
mysqlは全部inmemory db
memcachedでキャッシュ出来るようにした。
[上位者]
1179!
http://netmark.jp/2012/07/tuningathon-4.html
rails に行かないように vanishを建てる。
railsに行かないようにして、cacheをメインに。
rvmで1.9系の最新
ruby GCを切る
unicornを入れる
productionのrubyのcache
vanishを入れてgetをcache、postの時にcacheをpergeする。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment